}
}
-static unsigned long long __get_mult_bytes(const char *p, void *data)
+static unsigned long long __get_mult_bytes(const char *p, void *data,
+ int *percent)
{
unsigned int kb_base = fio_get_kb_base(data);
unsigned long long ret = 1;
pow = 2;
else if (!strcmp("k", c) || !strcmp("kb", c))
pow = 1;
+ else if (!strcmp("%", c)) {
+ *percent = 1;
+ return ret;
+ }
while (pow--)
ret *= (unsigned long long) mult;
return ret;
}
-static unsigned long long get_mult_bytes(const char *str, int len, void *data)
+static unsigned long long get_mult_bytes(const char *str, int len, void *data,
+ int *percent)
{
const char *p = str;
if (len < 2)
- return __get_mult_bytes(str, data);
+ return __get_mult_bytes(str, data, percent);
/*
* Go forward until we hit a non-digit
*/
while ((p - str) <= len) {
- if (!isdigit(*p))
+ if (!isdigit((int) *p))
break;
p++;
}
- if (!isalpha(*p))
+ if (!isalpha((int) *p) && (*p != '%'))
p = NULL;
- return __get_mult_bytes(p, data);
+ return __get_mult_bytes(p, data, percent);
}
/*
if (*val == LONG_MAX && errno == ERANGE)
return 1;
- if (kilo)
- *val *= get_mult_bytes(str, len, data);
- else
+ if (kilo) {
+ unsigned long long mult;
+ int perc = 0;
+
+ mult = get_mult_bytes(str, len, data, &perc);
+ if (perc)
+ *val = -1ULL - *val;
+ else
+ *val *= mult;
+ } else
*val *= get_mult_time(str[len - 1]);
return 0;
{
char *s = *p;
- while (isspace(*s))
+ while (isspace((int) *s))
s++;
*p = s;
p = s;
s = p + strlen(p);
- while ((isspace(*s) || iscntrl(*s)) && (s > start))
+ while ((isspace((int) *s) || iscntrl((int) *s)) && (s > start))
s--;
*(s + 1) = '\0';
long long ull, *ullp;
long ul1, ul2;
char **cp;
- int ret = 0;
+ int ret = 0, is_time = 0;
dprint(FD_PARSE, "__handle_option=%s, type=%d, ptr=%s\n", o->name,
o->type, ptr);
ret = fn(data, ptr);
break;
}
- case FIO_OPT_STR_VAL_TIME: {
- fio_opt_str_val_fn *fn;
-
- ret = check_str_time(ptr, &ull);
+ case FIO_OPT_STR_VAL_TIME:
+ is_time = 1;
case FIO_OPT_INT:
- case FIO_OPT_STR_VAL:
+ case FIO_OPT_STR_VAL: {
+ fio_opt_str_val_fn *fn = o->cb;
+
+ if (is_time)
+ ret = check_str_time(ptr, &ull);
+ else
+ ret = check_str_bytes(ptr, &ull, data);
- ret = check_str_bytes(ptr, &ull, data);
if (ret)
break;
return 1;
}
- fn = o->cb;
if (fn)
ret = fn(data, &ull);
else {