Fix signed int/long truncation on 32-bit architectures
authorJens Axboe <jaxboe@fusionio.com>
Wed, 11 May 2011 06:15:18 +0000 (08:15 +0200)
committerJens Axboe <jaxboe@fusionio.com>
Wed, 11 May 2011 06:15:18 +0000 (08:15 +0200)
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>
filesetup.c
io_u.c
trim.c

index 2b690c8930d91cc39eeac8e4fb8a845409c96a86..1350857ffb04d9f4ed1274298675f9a94adf44a8 100644 (file)
@@ -208,7 +208,7 @@ static int pre_read_file(struct thread_data *td, struct fio_file *f)
 static unsigned long long get_rand_file_size(struct thread_data *td)
 {
        unsigned long long ret, sized;
 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);
 
        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 787f382e2c73db251690fa296da787913b49e957..d35b8441b313b6efb28c9f65647aa0cb08b6cb3d 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -346,7 +346,7 @@ static unsigned int __get_next_buflen(struct thread_data *td, struct io_u *io_u)
        const int ddir = io_u->ddir;
        unsigned int uninitialized_var(buflen);
        unsigned int minbs, maxbs;
        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));
 
 
        assert(ddir_rw(ddir));
 
@@ -423,7 +423,7 @@ static void set_rwmix_bytes(struct thread_data *td)
 static inline enum fio_ddir get_rand_ddir(struct thread_data *td)
 {
        unsigned int v;
 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);
 
        if (td->o.use_os_rand) {
                r = os_random_long(&td->rwmix_state);
@@ -849,7 +849,7 @@ static struct fio_file *get_next_file_rand(struct thread_data *td,
 
        do {
                int opened = 0;
 
        do {
                int opened = 0;
-               long r;
+               unsigned long r;
 
                if (td->o.use_os_rand) {
                        r = os_random_long(&td->next_file_state);
 
                if (td->o.use_os_rand) {
                        r = os_random_long(&td->next_file_state);
diff --git a/trim.c b/trim.c
index a9b15d686606bee6856b3998e5b7104bc633ac18..de792dc46fd499beed43baffcc9b68184b04cf13 100644 (file)
--- a/trim.c
+++ b/trim.c
@@ -70,7 +70,7 @@ int get_next_trim(struct thread_data *td, struct io_u *io_u)
 int io_u_should_trim(struct thread_data *td, struct io_u *io_u)
 {
        unsigned long long val;
 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;
 
        if (!td->o.trim_percentage)
                return 0;