Shawn Lewis <shawnlewis@google.com> reports:
---
verify.c: fill_random_bytes() doesn't work as intended.
drand48 on linux returns a double whose value is evenly distributed between
0.0 and 0.1. This is not the same as having an 8-byte value where each bit
has the same chance of being 0 as it does of being 1.
I'd fix this but it should probably be done in a cross-platformish way and
I'm not quite sure how to do it. Maybe just use smaller randoms? Have an
os_random_uint32?
---
I just got rid of os_random_double() and used os_random_long(),
truncating that to an unsigned integer.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-static inline double os_random_double(os_random_state_t *rs)
-{
- double val;
-
- val = (double) rand_r(rs);
- return val;
-}
-static inline double os_random_double(os_random_state_t *rs)
-{
- double val;
-
- drand48_r(rs, &val);
- return val;
-}
-
static inline int fio_lookup_raw(dev_t dev, int *majdev, int *mindev)
{
struct raw_config_request rq;
static inline int fio_lookup_raw(dev_t dev, int *majdev, int *mindev)
{
struct raw_config_request rq;
-static inline double os_random_double(os_random_state_t *rs)
-{
- double val;
-
- val = (double) rand_r(rs);
- return val;
-}
-
unsigned char *p, unsigned int len)
{
unsigned int todo;
unsigned char *p, unsigned int len)
{
unsigned int todo;
- r = os_random_double(&td->verify_state);
+ r = os_random_long(&td->verify_state);
/*
* lrand48_r seems to be broken and only fill the bottom
/*
* lrand48_r seems to be broken and only fill the bottom