summaryrefslogtreecommitdiff
path: root/examples/ip_fragmentation
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/ip_fragmentation
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/ip_fragmentation')
-rw-r--r--examples/ip_fragmentation/main.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/examples/ip_fragmentation/main.c b/examples/ip_fragmentation/main.c
index e1e32c6..9e9ecae 100644
--- a/examples/ip_fragmentation/main.c
+++ b/examples/ip_fragmentation/main.c
@@ -586,7 +586,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;
}