X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=parse.c;h=f3497440aade02ca875dc7c0f9e07469c4030595;hp=ffe2dc0feb28aef5dc6560a2f894a5915b202f9f;hb=2a988d8bcb447eb098fc382835cc507587c6ba66;hpb=1e5324e723116a5faf9da686993cc79c14d62d4b diff --git a/parse.c b/parse.c index ffe2dc0f..f3497440 100644 --- a/parse.c +++ b/parse.c @@ -343,6 +343,11 @@ static int opt_len(const char *str) return (int)(postfix - str); } +static int str_match_len(const struct value_pair *vp, const char *str) +{ + return max(strlen(vp->ival), opt_len(str)); +} + #define val_store(ptr, val, off, or, data) \ do { \ ptr = td_var((data), (off)); \ @@ -360,7 +365,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, long long ull, *ullp; long ul1, ul2; double uf; - char **cp; + char **cp = NULL; int ret = 0, is_time = 0; const struct value_pair *vp; struct value_pair posval[PARSE_MAX_VP]; @@ -387,7 +392,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, if (!vp->ival || vp->ival[0] == '\0') continue; all_skipped = 0; - if (!strncmp(vp->ival, ptr, opt_len(ptr))) { + if (!strncmp(vp->ival, ptr, str_match_len(vp, ptr))) { ret = 0; if (o->roff1) { if (vp->or) @@ -535,8 +540,6 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, cp = td_var(data, o->off1); *cp = strdup(ptr); - } else { - cp = NULL; } if (fn) @@ -550,7 +553,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, if (!vp->ival || vp->ival[0] == '\0') continue; all_skipped = 0; - if (!strncmp(vp->ival, ptr, opt_len(ptr))) { + if (!strncmp(vp->ival, ptr, str_match_len(vp, ptr))) { char *rest; ret = 0;