Fix signed int/long truncation on 32-bit architectures
With using our internal random generator, we generate
unsigned ints. But by mistake this was assigned to
a signed long, that doesn't work so well on 32-bit machines.
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
diff --git a/filesetup.c b/filesetup.c
index 2b690c8..1350857 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -208,7 +208,7 @@
static unsigned long long get_rand_file_size(struct thread_data *td)
{
unsigned long long ret, sized;
- long r;
+ unsigned long r;
if (td->o.use_os_rand) {
r = os_random_long(&td->file_size_state);
diff --git a/io_u.c b/io_u.c
index 787f382..d35b844 100644
--- a/io_u.c
+++ b/io_u.c
@@ -346,7 +346,7 @@
const int ddir = io_u->ddir;
unsigned int uninitialized_var(buflen);
unsigned int minbs, maxbs;
- long r, rand_max;
+ unsigned long r, rand_max;
assert(ddir_rw(ddir));
@@ -423,7 +423,7 @@
static inline enum fio_ddir get_rand_ddir(struct thread_data *td)
{
unsigned int v;
- long r;
+ unsigned long r;
if (td->o.use_os_rand) {
r = os_random_long(&td->rwmix_state);
@@ -849,7 +849,7 @@
do {
int opened = 0;
- long r;
+ unsigned long r;
if (td->o.use_os_rand) {
r = os_random_long(&td->next_file_state);
diff --git a/trim.c b/trim.c
index a9b15d6..de792dc 100644
--- a/trim.c
+++ b/trim.c
@@ -70,7 +70,7 @@
int io_u_should_trim(struct thread_data *td, struct io_u *io_u)
{
unsigned long long val;
- long r;
+ unsigned long r;
if (!td->o.trim_percentage)
return 0;