projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[PATCH] Fix int vs long problems in parsing some options
[fio.git]
/
parse.c
diff --git
a/parse.c
b/parse.c
index ae8d0d91e2a0a8bc6748d48bd8c98affe3712a03..f37878f1cbc8d6a94f8d21aac91ea04a08deff5d 100644
(file)
--- a/
parse.c
+++ b/
parse.c
@@
-133,9
+133,9
@@
static struct fio_option *find_option(struct fio_option *options,
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)
{
- unsigned int il, *ilp;
+ unsigned int il, *ilp
1, *ilp2
;
unsigned long long ull, *ullp;
unsigned long long ull, *ullp;
- unsigned long ul1, ul2
, *ulp1, *ulp2
;
+ unsigned long ul1, ul2;
char **cp;
int ret = 0, is_time = 0;
char **cp;
int ret = 0, is_time = 0;
@@
-148,7
+148,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:
+ case FIO_OPT_STR_VAL_INT: {
fio_opt_str_val_fn *fn = o->cb;
if (is_time)
fio_opt_str_val_fn *fn = o->cb;
if (is_time)
@@
-165,8
+166,13
@@
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 {
- ullp = td_var(data, o->off1);
- *ullp = ull;
+ if (o->type == FIO_OPT_STR_VAL_INT) {
+ ilp1 = td_var(data, o->off1);
+ *ilp1 = ull;
+ } else {
+ ullp = td_var(data, o->off1);
+ *ullp = ull;
+ }
}
break;
}
}
break;
}
@@
-178,7
+184,7
@@
static int handle_option(struct fio_option *o, const char *ptr, void *data)
char tmp[128];
char *p1, *p2;
char tmp[128];
char *p1, *p2;
- str
cpy(tmp, ptr
);
+ str
ncpy(tmp, ptr, sizeof(tmp) - 1
);
p1 = strchr(tmp, '-');
if (!p1) {
p1 = strchr(tmp, '-');
if (!p1) {
@@
-193,14
+199,14
@@
static int handle_option(struct fio_option *o, const char *ptr, void *data)
ret = 1;
if (!check_range_bytes(p1, &ul1) && !check_range_bytes(p2, &ul2)) {
ret = 0;
ret = 1;
if (!check_range_bytes(p1, &ul1) && !check_range_bytes(p2, &ul2)) {
ret = 0;
-
u
lp1 = td_var(data, o->off1);
-
u
lp2 = td_var(data, o->off2);
+
i
lp1 = td_var(data, o->off1);
+
i
lp2 = td_var(data, o->off2);
if (ul1 > ul2) {
if (ul1 > ul2) {
- *
u
lp1 = ul2;
- *
u
lp2 = ul1;
+ *
i
lp1 = ul2;
+ *
i
lp2 = ul1;
} else {
} else {
- *
u
lp2 = ul2;
- *
u
lp1 = ul1;
+ *
i
lp2 = ul2;
+ *
i
lp1 = ul1;
}
}
}
}
@@
-219,8
+225,8
@@
static int handle_option(struct fio_option *o, const char *ptr, void *data)
if (fn)
ret = fn(data, &il);
else {
if (fn)
ret = fn(data, &il);
else {
- ilp = td_var(data, o->off1);
- *ilp = il;
+ ilp
1
= td_var(data, o->off1);
+ *ilp
1
= il;
}
break;
}
}
break;
}
@@
-230,8
+236,8
@@
static int handle_option(struct fio_option *o, const char *ptr, void *data)
if (fn)
ret = fn(data);
else {
if (fn)
ret = fn(data);
else {
- ilp = td_var(data, o->off1);
- *ilp = 1;
+ ilp
1
= td_var(data, o->off1);
+ *ilp
1
= 1;
}
break;
}
}
break;
}
@@
-267,7
+273,7
@@
int parse_option(const char *opt, struct fio_option *options, void *data)
char *pre, *post;
char tmp[64];
char *pre, *post;
char tmp[64];
- str
cpy(tmp, opt
);
+ str
ncpy(tmp, opt, sizeof(tmp) - 1
);
pre = strchr(tmp, '=');
if (pre) {
pre = strchr(tmp, '=');
if (pre) {