summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2011-06-13 16:23:28 -0700
committerSage Weil <sage@newdream.net>2011-06-13 16:23:28 -0700
commit8ce98b22de134482ccf34ddaf51bd74e0bd9ff6e (patch)
treea60fa74cf1de78299a4bb929c4cc0d98daba267d /qa
parentd89c9a1303ea89984ce1c1152ade189d323a08c5 (diff)
downloadceph-8ce98b22de134482ccf34ddaf51bd74e0bd9ff6e.tar.gz
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 <sage@newdream.net>
Diffstat (limited to 'qa')
-rw-r--r--qa/workunits/direct_io/test_sync_io.c4
1 files changed, 4 insertions, 0 deletions
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);