examples: fix optind reset
authorKeith Wiles <keith.wiles@intel.com>
Tue, 14 Feb 2017 22:09:41 +0000 (16:09 -0600)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Fri, 10 Mar 2017 14:38:47 +0000 (15:38 +0100)
commit9d5ca5323910591f2cafbac5070fcb5b6d02d022
treef6bc89813b796a03e8ffa75cb5f0b55927c32240
parent2deb6b5246d7706448d070335b329d1acb754cee
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>
25 files changed:
examples/distributor/main.c
examples/dpdk_qat/main.c
examples/ip_fragmentation/main.c
examples/ip_pipeline/config_parse.c
examples/ip_reassembly/main.c
examples/ipsec-secgw/ipsec-secgw.c
examples/ipv4_multicast/main.c
examples/l2fwd-cat/cat.c
examples/l2fwd-crypto/main.c
examples/l2fwd-jobstats/main.c
examples/l2fwd-keepalive/main.c
examples/l2fwd/main.c
examples/l3fwd-acl/main.c
examples/l3fwd-power/main.c
examples/l3fwd-vf/main.c
examples/l3fwd/main.c
examples/link_status_interrupt/main.c
examples/load_balancer/config.c
examples/multi_process/l2fwd_fork/main.c
examples/multi_process/symmetric_mp/main.c
examples/packet_ordering/main.c
examples/performance-thread/l3fwd-thread/main.c
examples/ptpclient/ptpclient.c
examples/qos_meter/main.c
test/test-pipeline/config.c