init: option parsing fixes
cover init: option parsing fixes
Patch 1 changes --minimal from optional_argument to no_argument. There seems to be no reason why optional_argument was used (the option doesn't use optarg).
Patch 2 fixes a segfault when --output-format is used without an argument.
Stefan Hajnoczi (2):
init: --minimal does not take an optional argument
init: log error on missing --output-format argument
init.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Signature · 1 line
1.8.5.3
PATCH 1/2 init: --minimal does not take an optional argument
--- init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
init.c +1 -1
@@ -100,7 +100,7 @@ static struct option l_opts[FIO_NR_OPTIONS] = { }, { .name = (char *) "minimal", - .has_arg = optional_argument, + .has_arg = no_argument, .val = 'm' | FIO_CLIENT_FLAG, }, {
Signature · 1 line
1.8.5.3
PATCH 2/2 init: log error on missing --output-format argument
In reply to Stefan Hajnoczistrcmp(optarg, "foo") will crash if --output-format was given without an argument. Log an error and exit properly instead of crashing.
--- init.c | 6 ++++++ 1 file changed, 6 insertions(+)
init.c +6 -0
@@ -1652,6 +1652,12 @@ int parse_cmd_line(int argc, char *argv[], int client_type) output_format =FIO_OUTPUT_TERSE ;break ;case 'F' : +if (!optarg) { +log_err ("fio: missing --output-format argument\n" ); + exit_val =1 ; + do_exit++; +break ; + }if (!strcmp (optarg,"minimal" ) || !strcmp (optarg,"terse" ) || !strcmp (optarg,"csv" ))
Signature · 1 line
1.8.5.3
Jens Axboe
AppliedQuoted 11 lines · Stefan Hajnoczi
Patch 1 changes --minimal from
optional_argumenttono_argument. There seems to be no reason whyoptional_argumentwas used (the option doesn't use optarg).Patch 2 fixes a segfault when --output-format is used without an argument.
Stefan Hajnoczi (2):
init: --minimal does not take an optional argument
init: log error on missing --output-format argumentinit.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Thanks, applied both!
Signature · 1 line
Jens Axboe