X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=parse.c;h=d15d22ba3f7ed03a68e77614a02b44616d64daa5;hp=0bbb0b30dafd5c8b57ac842e28bdaeba789c6022;hb=4b919f7740f4875d73c0619a08d269d5c679e19f;hpb=237cc3b1e297a9b934a424c6271971b07efc7a66 diff --git a/parse.c b/parse.c index 0bbb0b30..d15d22ba 100644 --- a/parse.c +++ b/parse.c @@ -344,6 +344,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)); \ @@ -361,7 +366,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]; @@ -388,7 +393,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) @@ -536,8 +541,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) @@ -551,7 +554,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; @@ -1093,6 +1096,9 @@ void option_init(struct fio_option *o) o->maxval = UINT_MAX; } if (o->type == FIO_OPT_FLOAT_LIST) { +#ifndef NAN +#define NAN __builtin_nanf("") +#endif o->minfp = NAN; o->maxfp = NAN; }