From 27ea68a59f0b17abead399311e24933897ab3da0 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 25 Mar 2010 23:12:04 +0100 Subject: [PATCH] "Expand" random number from 32-bit to 64-bit when necessary Signed-off-by: Jens Axboe --- io_u.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/io_u.c b/io_u.c index 4d3116b7..3558a073 100644 --- 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 -- 2.25.1