projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fio 1.30
[fio.git]
/
parse.c
diff --git
a/parse.c
b/parse.c
index d653f5e489458236a6d441a1157fab15396314ed..5043374405d8a1e262687a5a1bdcac90f18990cf 100644
(file)
--- a/
parse.c
+++ b/
parse.c
@@
-46,7
+46,10
@@
static void show_option_range(struct fio_option *o)
if (!o->minval && !o->maxval)
return;
if (!o->minval && !o->maxval)
return;
- printf("%20s: min=%d, max=%d\n", "range", o->minval, o->maxval);
+ printf("%20s: min=%d", "range", o->minval);
+ if (o->maxval)
+ printf(", max=%d", o->maxval);
+ printf("\n");
}
static void show_option_values(struct fio_option *o)
}
static void show_option_values(struct fio_option *o)
@@
-112,13
+115,18
@@
static unsigned long get_mult_bytes(char c)
*/
int str_to_decimal(const char *str, long long *val, int kilo)
{
*/
int str_to_decimal(const char *str, long long *val, int kilo)
{
- int len;
+ int len
, base
;
len = strlen(str);
if (!len)
return 1;
len = strlen(str);
if (!len)
return 1;
- *val = strtoll(str, NULL, 10);
+ if (strstr(str, "0x") || strstr(str, "0X"))
+ base = 16;
+ else
+ base = 10;
+
+ *val = strtoll(str, NULL, base);
if (*val == LONG_MAX && errno == ERANGE)
return 1;
if (*val == LONG_MAX && errno == ERANGE)
return 1;
@@
-272,8
+280,8
@@
static int __handle_option(struct fio_option *o, const char *ptr, void *data,
}
case FIO_OPT_STR_VAL_TIME:
is_time = 1;
}
case FIO_OPT_STR_VAL_TIME:
is_time = 1;
- case FIO_OPT_
STR_VAL
:
- case FIO_OPT_STR_VAL
_INT
: {
+ case FIO_OPT_
INT
:
+ case FIO_OPT_STR_VAL: {
fio_opt_str_val_fn *fn = o->cb;
if (is_time)
fio_opt_str_val_fn *fn = o->cb;
if (is_time)
@@
-298,7
+306,7
@@
static int __handle_option(struct fio_option *o, const char *ptr, void *data,
if (fn)
ret = fn(data, &ull);
else {
if (fn)
ret = fn(data, &ull);
else {
- if (o->type == FIO_OPT_
STR_VAL_
INT) {
+ if (o->type == FIO_OPT_INT) {
if (first)
val_store(ilp, ull, o->off1, data);
if (!more && o->off2)
if (first)
val_store(ilp, ull, o->off1, data);
if (!more && o->off2)
@@
-368,7
+376,6
@@
static int __handle_option(struct fio_option *o, const char *ptr, void *data,
break;
}
break;
}
- case FIO_OPT_INT:
case FIO_OPT_BOOL: {
fio_opt_int_fn *fn = o->cb;
case FIO_OPT_BOOL: {
fio_opt_int_fn *fn = o->cb;
@@
-421,15
+428,25
@@
static int __handle_option(struct fio_option *o, const char *ptr, void *data,
ret = 1;
}
ret = 1;
}
+ if (ret)
+ return ret;
+
+ if (o->verify)
+ ret = o->verify(o, data);
+
return ret;
}
return ret;
}
-static int handle_option(struct fio_option *o, const char *ptr, void *data)
+static int handle_option(struct fio_option *o, const char *
__
ptr, void *data)
{
{
- c
onst char
*ptr2 = NULL;
+ c
har *ptr,
*ptr2 = NULL;
int r1, r2;
int r1, r2;
- dprint(FD_PARSE, "handle_option=%s, ptr=%s\n", o->name, ptr);
+ dprint(FD_PARSE, "handle_option=%s, ptr=%s\n", o->name, __ptr);
+
+ ptr = NULL;
+ if (__ptr)
+ ptr = strdup(__ptr);
/*
* See if we have a second set of parameters, hidden after a comma.
/*
* See if we have a second set of parameters, hidden after a comma.
@@
-440,6
+457,8
@@
static int handle_option(struct fio_option *o, const char *ptr, void *data)
(o->type != FIO_OPT_STR_STORE) &&
(o->type != FIO_OPT_STR)) {
ptr2 = strchr(ptr, ',');
(o->type != FIO_OPT_STR_STORE) &&
(o->type != FIO_OPT_STR)) {
ptr2 = strchr(ptr, ',');
+ if (ptr2 && *(ptr2 + 1) == '\0')
+ *ptr2 = '\0';
if (!ptr2)
ptr2 = strchr(ptr, ':');
if (!ptr2)
if (!ptr2)
ptr2 = strchr(ptr, ':');
if (!ptr2)
@@
-453,12
+472,17
@@
static int handle_option(struct fio_option *o, const char *ptr, void *data)
*/
r1 = __handle_option(o, ptr, data, 1, !!ptr2);
*/
r1 = __handle_option(o, ptr, data, 1, !!ptr2);
- if (!ptr2)
+ if (!ptr2) {
+ if (ptr)
+ free(ptr);
return r1;
return r1;
+ }
ptr2++;
r2 = __handle_option(o, ptr2, data, 0, 0);
ptr2++;
r2 = __handle_option(o, ptr2, data, 0, 0);
+ if (ptr)
+ free(ptr);
return r1 && r2;
}
return r1 && r2;
}
@@
-649,7
+673,6
@@
static void show_option_help(struct fio_option *o)
const char *typehelp[] = {
"string (opt=bla)",
"string with possible k/m/g postfix (opt=4k)",
const char *typehelp[] = {
"string (opt=bla)",
"string with possible k/m/g postfix (opt=4k)",
- "string with range and postfix (opt=1k-4k)",
"string with time postfix (opt=10s)",
"string (opt=bla)",
"string with dual range (opt=1k-4k,4k-8k)",
"string with time postfix (opt=10s)",
"string (opt=bla)",
"string with dual range (opt=1k-4k,4k-8k)",