]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
nvme-cli: have cfg var get set more than 1 execution
authorJay Freyensee <james_p_freyensee@linux.intel.com>
Fri, 7 Oct 2016 18:46:16 +0000 (11:46 -0700)
committerJay Freyensee <james_p_freyensee@linux.intel.com>
Fri, 7 Oct 2016 19:14:53 +0000 (12:14 -0700)
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 <james_p_freyensee@linux.intel.com>
Originally-by: Sagi Grimberg <sagi@lightbits.io>
Tested-by: Jay Freyensee <james_p_freyensee@linux.intel.com>
argconfig.c

index e2bb7ab264466871658dc78c2aa3f05210978abd..bda8b03c1cbd95d47cca32eb63cd011e03bfb70a 100644 (file)
@@ -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) {