summaryrefslogtreecommitdiff
path: root/examples/ipv4_multicast
diff options
context:
space:
mode:
authorKeith Wiles <keith.wiles@intel.com>2017-02-14 16:09:41 -0600
committerThomas Monjalon <thomas.monjalon@6wind.com>2017-03-10 15:38:47 +0100
commit9d5ca5323910591f2cafbac5070fcb5b6d02d022 (patch)
treef6bc89813b796a03e8ffa75cb5f0b55927c32240 /examples/ipv4_multicast
parent2deb6b5246d7706448d070335b329d1acb754cee (diff)
downloaddpdk-9d5ca5323910591f2cafbac5070fcb5b6d02d022.zip
dpdk-9d5ca5323910591f2cafbac5070fcb5b6d02d022.tar.gz
dpdk-9d5ca5323910591f2cafbac5070fcb5b6d02d022.tar.xz
examples: fix optind reset
The variable optind should be reset to one not zero. From the man page: "The variable optind is the index of the next element to be processed in argv. The system initializes this value to 1. The caller can reset it to 1 to restart scanning of the same argv, or when scanning a new argument vector.” The problem I saw with my application was trying to parse the wrong option, which can happen as DPDK parses the first part of the command line and the application parses the second part. If you call getopt() multiple times in the same execution, the behavior is not maintained when using zero for optind. Signed-off-by: Keith Wiles <keith.wiles@intel.com>
Diffstat (limited to 'examples/ipv4_multicast')
-rw-r--r--examples/ipv4_multicast/main.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/examples/ipv4_multicast/main.c b/examples/ipv4_multicast/main.c
index 708d76e..b681f8e 100644
--- a/examples/ipv4_multicast/main.c
+++ b/examples/ipv4_multicast/main.c
@@ -575,7 +575,7 @@ parse_args(int argc, char **argv)
argv[optind-1] = prgname;
ret = optind-1;
- optind = 0; /* reset getopt lib */
+ optind = 1; /* reset getopt lib */
return ret;
}