All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] init: option parsing fixes
@ 2014-02-04 13:27 Stefan Hajnoczi
  2014-02-04 13:27 ` [PATCH 1/2] init: --minimal does not take an optional argument Stefan Hajnoczi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2014-02-04 13:27 UTC (permalink / raw)
  To: fio; +Cc: Jens Axboe

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(-)

-- 
1.8.5.3



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] init: --minimal does not take an optional argument
  2014-02-04 13:27 [PATCH 0/2] init: option parsing fixes Stefan Hajnoczi
@ 2014-02-04 13:27 ` Stefan Hajnoczi
  2014-02-04 13:27 ` [PATCH 2/2] init: log error on missing --output-format argument Stefan Hajnoczi
  2014-02-05 17:11 ` [PATCH 0/2] init: option parsing fixes Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2014-02-04 13:27 UTC (permalink / raw)
  To: fio; +Cc: Jens Axboe

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/init.c b/init.c
index cc35e2b..05c73ef 100644
--- a/init.c
+++ b/init.c
@@ -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,
 	},
 	{
-- 
1.8.5.3



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] init: log error on missing --output-format argument
  2014-02-04 13:27 [PATCH 0/2] init: option parsing fixes Stefan Hajnoczi
  2014-02-04 13:27 ` [PATCH 1/2] init: --minimal does not take an optional argument Stefan Hajnoczi
@ 2014-02-04 13:27 ` Stefan Hajnoczi
  2014-02-05 17:11 ` [PATCH 0/2] init: option parsing fixes Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2014-02-04 13:27 UTC (permalink / raw)
  To: fio; +Cc: Jens Axboe

strcmp(optarg, "foo") will crash if --output-format was given without an
argument.  Log an error and exit properly instead of crashing.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 init.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/init.c b/init.c
index 05c73ef..6c48d3a 100644
--- a/init.c
+++ b/init.c
@@ -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"))
-- 
1.8.5.3



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] init: option parsing fixes
  2014-02-04 13:27 [PATCH 0/2] init: option parsing fixes Stefan Hajnoczi
  2014-02-04 13:27 ` [PATCH 1/2] init: --minimal does not take an optional argument Stefan Hajnoczi
  2014-02-04 13:27 ` [PATCH 2/2] init: log error on missing --output-format argument Stefan Hajnoczi
@ 2014-02-05 17:11 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2014-02-05 17:11 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: fio

On Tue, Feb 04 2014, Stefan Hajnoczi wrote:
> 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(-)

Thanks, applied both!

-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-02-05 17:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-04 13:27 [PATCH 0/2] init: option parsing fixes Stefan Hajnoczi
2014-02-04 13:27 ` [PATCH 1/2] init: --minimal does not take an optional argument Stefan Hajnoczi
2014-02-04 13:27 ` [PATCH 2/2] init: log error on missing --output-format argument Stefan Hajnoczi
2014-02-05 17:11 ` [PATCH 0/2] init: option parsing fixes Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.