[PATCH] Fix int vs long problems in parsing some options
authorJens Axboe <axboe@suse.de>
Fri, 3 Nov 2006 07:17:09 +0000 (08:17 +0100)
committerJens Axboe <axboe@suse.de>
Fri, 3 Nov 2006 07:17:09 +0000 (08:17 +0100)
The type needs to match strictly, or we get into problems on big
endian architectures.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
init.c
parse.c
parse.h

diff --git a/init.c b/init.c
index 616c51f27ff738e7d2d2bd3eddbf7c924d693c3b..689c495b6ac648059a513c325d92620b7bd82beb 100644 (file)
--- a/init.c
+++ b/init.c
@@ -138,17 +138,17 @@ static struct fio_option options[] = {
        },
        {
                .name   = "bs",
-               .type   = FIO_OPT_STR_VAL,
+               .type   = FIO_OPT_STR_VAL_INT,
                .off1   = td_var_offset(bs[DDIR_READ]),
        },
        {
                .name   = "read_bs",
-               .type   = FIO_OPT_STR_VAL,
+               .type   = FIO_OPT_STR_VAL_INT,
                .off1   = td_var_offset(bs[DDIR_READ]),
        },
        {
                .name   = "write_bs",
-               .type   = FIO_OPT_STR_VAL,
+               .type   = FIO_OPT_STR_VAL_INT,
                .off1   = td_var_offset(bs[DDIR_WRITE]),
        },
        {
@@ -513,9 +513,9 @@ static void fixup_options(struct thread_data *td)
        if (!td->max_bs[DDIR_READ])
                td->max_bs[DDIR_READ] = td->bs[DDIR_READ];
        if (!td->min_bs[DDIR_WRITE])
-               td->min_bs[DDIR_WRITE]= td->bs[DDIR_READ];
+               td->min_bs[DDIR_WRITE]= td->bs[DDIR_WRITE];
        if (!td->max_bs[DDIR_WRITE])
-               td->max_bs[DDIR_WRITE] = td->bs[DDIR_READ];
+               td->max_bs[DDIR_WRITE] = td->bs[DDIR_WRITE];
 
        td->rw_min_bs = min(td->min_bs[DDIR_READ], td->min_bs[DDIR_WRITE]);
 
diff --git a/parse.c b/parse.c
index 9f2ee0d653c7fcdc781caa4eea1a46eee4776074..f37878f1cbc8d6a94f8d21aac91ea04a08deff5d 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -133,9 +133,9 @@ static struct fio_option *find_option(struct fio_option *options,
 
 static int handle_option(struct fio_option *o, const char *ptr, void *data)
 {
-       unsigned int il, *ilp;
+       unsigned int il, *ilp1, *ilp2;
        unsigned long long ull, *ullp;
-       unsigned long ul1, ul2, *ulp1, *ulp2;
+       unsigned long ul1, ul2;
        char **cp;
        int ret = 0, is_time = 0;
 
@@ -148,7 +148,8 @@ static int handle_option(struct fio_option *o, const char *ptr, void *data)
        }
        case FIO_OPT_STR_VAL_TIME:
                is_time = 1;
-       case FIO_OPT_STR_VAL: {
+       case FIO_OPT_STR_VAL:
+       case FIO_OPT_STR_VAL_INT: {
                fio_opt_str_val_fn *fn = o->cb;
 
                if (is_time)
@@ -165,8 +166,13 @@ static int handle_option(struct fio_option *o, const char *ptr, void *data)
                if (fn)
                        ret = fn(data, &ull);
                else {
-                       ullp = td_var(data, o->off1);
-                       *ullp = ull;
+                       if (o->type == FIO_OPT_STR_VAL_INT) {
+                               ilp1 = td_var(data, o->off1);
+                               *ilp1 = ull;
+                       } else {
+                               ullp = td_var(data, o->off1);
+                               *ullp = ull;
+                       }
                }
                break;
        }
@@ -193,14 +199,14 @@ static int handle_option(struct fio_option *o, const char *ptr, void *data)
                ret = 1;
                if (!check_range_bytes(p1, &ul1) && !check_range_bytes(p2, &ul2)) {
                        ret = 0;
-                       ulp1 = td_var(data, o->off1);
-                       ulp2 = td_var(data, o->off2);
+                       ilp1 = td_var(data, o->off1);
+                       ilp2 = td_var(data, o->off2);
                        if (ul1 > ul2) {
-                               *ulp1 = ul2;
-                               *ulp2 = ul1;
+                               *ilp1 = ul2;
+                               *ilp2 = ul1;
                        } else {
-                               *ulp2 = ul2;
-                               *ulp1 = ul1;
+                               *ilp2 = ul2;
+                               *ilp1 = ul1;
                        }
                }       
                        
@@ -219,8 +225,8 @@ static int handle_option(struct fio_option *o, const char *ptr, void *data)
                if (fn)
                        ret = fn(data, &il);
                else {
-                       ilp = td_var(data, o->off1);
-                       *ilp = il;
+                       ilp1 = td_var(data, o->off1);
+                       *ilp1 = il;
                }
                break;
        }
@@ -230,8 +236,8 @@ static int handle_option(struct fio_option *o, const char *ptr, void *data)
                if (fn)
                        ret = fn(data);
                else {
-                       ilp = td_var(data, o->off1);
-                       *ilp = 1;
+                       ilp1 = td_var(data, o->off1);
+                       *ilp1 = 1;
                }
                break;
        }
diff --git a/parse.h b/parse.h
index be3d24ac43f1634a39a57b77ab84491cf7142b25..563712eede06dca557bfbdcbaae8ecbb73123dfe 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -7,6 +7,7 @@
 enum fio_opt_type {
        FIO_OPT_STR = 0,
        FIO_OPT_STR_VAL,
+       FIO_OPT_STR_VAL_INT,
        FIO_OPT_STR_VAL_TIME,
        FIO_OPT_STR_STORE,
        FIO_OPT_RANGE,