Skip to contentSkip to conversation

argconfig: Rewind optind before looping on getopt_long

PATCH New Sagi Grimberg 3 participants 4 messages Oct 13, 2016 NVMe

lore
Share & tools
lore

Sagi Grimberg

author maintainer
#0 lore raw

PATCH 1/1 argconfig: Rewind optind before looping on getopt_long

In conf file based discovery we can call argconfig_parse multiple times.

Reported-by Jay Freyensee <james_p_freyensee at linux.intel.com>
Signed-off-by Sagi Grimberg <sagi at grimberg.me>
---
 argconfig.c | 1 +
 1 file changed, 1 insertion(+)
argconfig.c +1 -0
index e2bb7ab26446..bda8b03c1cbd 100644
@@ -193,6 +193,7 @@ int argconfig_parse(int argc, char *argv[], const char *program_desc,
 	short_opts[short_index++] = 'h';
 	short_opts[short_index] = 0;
 
+	optind = 0;
 	while ((c = getopt_long_only(argc, argv, short_opts, long_opts,
 				&option_index)) != -1) {
 		if (c != 0) {
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 argconfig: Rewind optind before looping on getopt_long

Quoted 2 lines · Sagi Grimberg

In conf file based discovery we can call argconfig_parse multiple times.

Jay beat you to it. :)

https://github.com/linux-nvme/nvme-cli/commit/2da2440f1e5e98df61b192446be7c68a170dcda6

Quoted 18 lines
Reported-by Jay Freyensee <james_p_freyensee at linux.intel.com>
Signed-off-by Sagi Grimberg <sagi at grimberg.me>
---
 argconfig.c | 1 +
 1 file changed, 1 insertion(+)
argconfig.c +1 -0
index e2bb7ab26446..bda8b03c1cbd 100644
@@ -193,6 +193,7 @@ int argconfig_parse(int argc, char *argv[], const char *program_desc,
 	short_opts[short_index++] = 'h';
 	short_opts[short_index] = 0;
 
+	optind = 0;
 	while ((c = getopt_long_only(argc, argv, short_opts, long_opts,
 				&option_index)) != -1) {
 		if (c != 0) {
author maintainer
#2 lore raw

PATCH 1/1 argconfig: Rewind optind before looping on getopt_long

Quoted 5 lines
Quoted 3 lines

In conf file based discovery we can call argconfig_parse multiple times.

Jay beat you to it. :)

Heh :)

October is a multi-holiday sparse month...

Thanks Jay!

#3 lore raw

PATCH 1/1 argconfig: Rewind optind before looping on getopt_long

Quoted 5 lines · Sagi Grimberg
Quoted 5 lines
Quoted 4 lines

In conf file based discovery we can call argconfig_parse multiple times.

Quoted 7 lines
Quoted 1 line

Jay beat you to it. :)

Heh :)

October is a multi-holiday sparse month...

Thanks Jay!

No thank you :-)

Quoted 5 lines

_______________________________________________
Linux-nvme mailing list
Linux-nvme at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme