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)",
{
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
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)); \
long long ull, *ullp;
long ul1, ul2;
char **cp;
- int ret = 0, is_time = 0;
+ int ret = 0;
dprint(FD_PARSE, "__handle_option=%s, type=%d, ptr=%s\n", o->name,
o->type, ptr);
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)
ret = fn(data, ptr);
break;
}
- case FIO_OPT_STR_VAL_TIME:
- is_time = 1;
- case FIO_OPT_INT:
- case FIO_OPT_STR_VAL: {
- fio_opt_str_val_fn *fn = o->cb;
+ case FIO_OPT_STR_VAL_TIME: {
+ fio_opt_str_val_fn *fn;
- if (is_time)
- ret = check_str_time(ptr, &ull);
- else
- ret = check_str_bytes(ptr, &ull, data);
+ ret = check_str_time(ptr, &ull);
+ case FIO_OPT_INT:
+ case FIO_OPT_STR_VAL:
+ ret = check_str_bytes(ptr, &ull, data);
if (ret)
break;
return 1;
}
+ fn = o->cb;
if (fn)
ret = fn(data, &ull);
else {