From: Jay Freyensee Date: Fri, 7 Oct 2016 18:46:16 +0000 (-0700) Subject: nvme-cli: have cfg var get set more than 1 execution X-Git-Tag: v1.0~25^2~1 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2da2440f1e5e98df61b192446be7c68a170dcda6;p=users%2Fhch%2Fnvme-cli.git nvme-cli: have cfg var get set more than 1 execution Without this fix, the struct config cfg variable only gets set one time when argconfig_parse() is called. Any other time it is attempted to be set, it acts as a read-only value and continues to use the initial value it was set with. This poses a problem for the discovery feature, discovery.conf file as it is desired to make the file multiple line instead of a single line, such as: -t rdma -a 192.168.69.33 -s 4420 -q host2-proper-nqn -t rdma -a 192.168.1.4 -s 4420 -q host2-proper-nqn -t rdma -a 192.168.69.33 -s 99 -q host2-proper-nqn I've tried the fix with a few existing commands and nothing appears to be broken, but I haven't done an exhaustive test. Reported-by: Jay Freyensee Originally-by: Sagi Grimberg Tested-by: Jay Freyensee --- diff --git a/argconfig.c b/argconfig.c index e2bb7ab..bda8b03 100644 --- a/argconfig.c +++ b/argconfig.c @@ -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) {