"Expand" random number from 32-bit to 64-bit when necessary
authorJens Axboe <jens.axboe@oracle.com>
Thu, 25 Mar 2010 22:12:04 +0000 (23:12 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 25 Mar 2010 22:12:04 +0000 (23:12 +0100)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
io_u.c

diff --git a/io_u.c b/io_u.c
index 4d3116b7fd4fc0901f4419e8690270c2c18a2d43..3558a0734711a0c80518d11903b9b9f885e73713 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -1218,7 +1218,12 @@ void io_u_fill_buffer(struct thread_data *td, struct io_u *io_u,
 
        if (!td->o.zero_buffers) {
                while ((void *) ptr - io_u->buf < max_bs) {
-                       *ptr = __rand(&__fio_rand_state);
+                       unsigned int r = __rand(&__fio_rand_state);
+
+                       if (sizeof(r) != sizeof(*ptr))
+                               r *= GOLDEN_RATIO_PRIME;
+
+                       *ptr = r;
                        ptr++;
                }
        } else