From 74ba1808c32e978229eefa7cf28c08bcb73b5b5d Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 15 Jul 2011 09:09:15 +0200 Subject: [PATCH] Make string-set options behave more like bool options Before this change, string-set options (like time_based) would not complain if passed an argument, they would just always evaluate to being set. This is very confusing if someone uses them negated, ala: time_based=0 since fio would interpret that as the option being set. Now we'll do the right thing, time_based=0 will be identical to not having the option set. And time_based=1 or just time_based will equate to the option being set. Signed-off-by: Jens Axboe --- parse.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/parse.c b/parse.c index ef23fbe9..ad2782f0 100644 --- a/parse.c +++ b/parse.c @@ -498,10 +498,17 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, break; } - case FIO_OPT_BOOL: { + case FIO_OPT_BOOL: + case FIO_OPT_STR_SET: { fio_opt_int_fn *fn = o->cb; - ret = check_int(ptr, &il); + if (ptr) + ret = check_int(ptr, &il); + else if (o->type == FIO_OPT_BOOL) + ret = 1; + else + il = 1; + if (ret) break; @@ -537,27 +544,6 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, } break; } - case FIO_OPT_STR_SET: { - fio_opt_str_set_fn *fn = o->cb; - - if (fn) - ret = fn(data); - else { - if (first) { - if (o->roff1) - *(unsigned int *) o->roff1 = 1; - else - val_store(ilp, 1, o->off1, 0, data); - } - if (!more) { - if (o->roff2) - *(unsigned int *) o->roff2 = 1; - else if (o->off2) - val_store(ilp, 1, o->off2, 0, data); - } - } - break; - } case FIO_OPT_DEPRECATED: fprintf(stdout, "Option %s is deprecated\n", o->name); break; -- 2.25.1