X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=parse.c;h=bb138e55f967fbeb6aa09690b79fa4b18092cbb4;hb=3be8007107a6e4bad3f1b7ea9ea80b51a2dddfc4;hp=e03592d8bd4ee0b7850e2067a847f4caae814f70;hpb=57fc29faae372cb474b5f2ef921638ab28bb9dc0;p=fio.git diff --git a/parse.c b/parse.c index e03592d8..bb138e55 100644 --- a/parse.c +++ b/parse.c @@ -79,6 +79,7 @@ static void show_option_help(struct fio_option *o, FILE *out) const char *typehelp[] = { "invalid", "string (opt=bla)", + "string (opt=bla)", "string with possible k/m/g postfix (opt=4k)", "string with time postfix (opt=10s)", "string (opt=bla)", @@ -169,6 +170,9 @@ static unsigned long long get_mult_bytes(const char *str, int len, void *data) { const char *p; + if (len < 2) + return __get_mult_bytes(str, data); + /* * if the last char is 'b' or 'B', the user likely used * "1gb" instead of just "1g". If the second to last is also @@ -278,6 +282,17 @@ static int check_int(const char *p, int *val) return 1; } +static int opt_len(const char *str) +{ + char *postfix; + + postfix = strchr(str, ':'); + if (!postfix) + return strlen(str); + + return (int)(postfix - str); +} + #define val_store(ptr, val, off, or, data) \ do { \ ptr = td_var((data), (off)); \ @@ -320,7 +335,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, strlen(ptr))) { + if (!strncmp(vp->ival, ptr, opt_len(ptr))) { ret = 0; if (o->roff1) { if (vp->or)