]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: test_sync_io: zero buffers prior to read
authorSage Weil <sage@newdream.net>
Mon, 13 Jun 2011 23:23:28 +0000 (16:23 -0700)
committerSage Weil <sage@newdream.net>
Mon, 13 Jun 2011 23:23:28 +0000 (16:23 -0700)
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>
qa/workunits/direct_io/test_sync_io.c

index 9df5570b11d7ef03b4b7ee4f70516c939c3743a2..a5b8c6a251a356bcc49f579dbe58f613e659d970 100644 (file)
@@ -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);