summaryrefslogtreecommitdiff
path: root/examples/l3fwd-vf
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/l3fwd-vf
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/l3fwd-vf')
-rw-r--r--examples/l3fwd-vf/main.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/examples/l3fwd-vf/main.c b/examples/l3fwd-vf/main.c
index f56e8db..dc3d547 100644
--- a/examples/l3fwd-vf/main.c
+++ b/examples/l3fwd-vf/main.c
@@ -816,7 +816,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;
}