X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=parse.c;h=1071d4031693449fe165fc1852edad4596ee9d91;hp=4c6a9ea984ee28475c0f47eeabec549d68e7c55e;hb=39d9ef6a390466ccf58b8579ed2da508456594d0;hpb=b347f9daece7d65a6e596cd3bd0ef3602e40b059 diff --git a/parse.c b/parse.c index 4c6a9ea9..1071d403 100644 --- a/parse.c +++ b/parse.c @@ -277,8 +277,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_INT: { + case FIO_OPT_INT: + case FIO_OPT_STR_VAL: { fio_opt_str_val_fn *fn = o->cb; if (is_time) @@ -303,7 +303,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, if (fn) ret = fn(data, &ull); else { - if (o->type == FIO_OPT_STR_VAL_INT) { + if (o->type == FIO_OPT_INT) { if (first) val_store(ilp, ull, o->off1, data); if (!more && o->off2) @@ -373,7 +373,6 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, break; } - case FIO_OPT_INT: case FIO_OPT_BOOL: { fio_opt_int_fn *fn = o->cb; @@ -429,12 +428,16 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, return ret; } -static int handle_option(struct fio_option *o, const char *ptr, void *data) +static int handle_option(struct fio_option *o, const char *__ptr, void *data) { - const char *ptr2 = NULL; + char *ptr, *ptr2 = NULL; int r1, r2; - dprint(FD_PARSE, "handle_option=%s, ptr=%s\n", o->name, ptr); + dprint(FD_PARSE, "handle_option=%s, ptr=%s\n", o->name, __ptr); + + ptr = NULL; + if (__ptr) + ptr = strdup(__ptr); /* * See if we have a second set of parameters, hidden after a comma. @@ -445,6 +448,8 @@ static int handle_option(struct fio_option *o, const char *ptr, void *data) (o->type != FIO_OPT_STR_STORE) && (o->type != FIO_OPT_STR)) { ptr2 = strchr(ptr, ','); + if (ptr2 && *(ptr2 + 1) == '\0') + *ptr2 = '\0'; if (!ptr2) ptr2 = strchr(ptr, ':'); if (!ptr2) @@ -458,12 +463,17 @@ static int handle_option(struct fio_option *o, const char *ptr, void *data) */ r1 = __handle_option(o, ptr, data, 1, !!ptr2); - if (!ptr2) + if (!ptr2) { + if (ptr) + free(ptr); return r1; + } ptr2++; r2 = __handle_option(o, ptr2, data, 0, 0); + if (ptr) + free(ptr); return r1 && r2; }