From 8ce98b22de134482ccf34ddaf51bd74e0bd9ff6e Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 13 Jun 2011 16:23:28 -0700 Subject: [PATCH] qa: test_sync_io: zero buffers prior to read Be extra paranoid to ensure we read back the correct data and didn't just find it in undefined memory. Signed-off-by: Sage Weil --- qa/workunits/direct_io/test_sync_io.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qa/workunits/direct_io/test_sync_io.c b/qa/workunits/direct_io/test_sync_io.c index 9df5570b11d..a5b8c6a251a 100644 --- a/qa/workunits/direct_io/test_sync_io.c +++ b/qa/workunits/direct_io/test_sync_io.c @@ -64,6 +64,7 @@ int read_direct(int buf_align, uint64_t offset, int len) void *rawbuf; posix_memalign(&rawbuf, 4096, len + buf_align); void *buf = (char *)rawbuf + buf_align; + memset(buf, 0, len); pread(fd, buf, len, offset); close(fd); int r = verify_pattern(buf, len, offset); @@ -79,6 +80,7 @@ int read_sync(int buf_align, uint64_t offset, int len) void *rawbuf; posix_memalign(&rawbuf, 4096, len + buf_align); void *buf = (char *)rawbuf + buf_align; + memset(buf, 0, len); pread(fd, buf, len, offset); close(fd); int r = verify_pattern(buf, len, offset); @@ -101,6 +103,7 @@ int write_direct(int buf_align, uint64_t offset, int len) fd = open("foo", O_RDONLY); void *buf2 = malloc(len); + memset(buf2, 0, len); pread(fd, buf2, len, offset); close(fd); @@ -128,6 +131,7 @@ int write_sync(int buf_align, uint64_t offset, int len) fd = open("foo", O_RDONLY); void *buf2 = malloc(len); + memset(buf2, 0, len); pread(fd, buf2, len, offset); close(fd);