From 301a60f6edd7226307e1c6f5e650d781d053510b Mon Sep 17 00:00:00 2001 From: Nick Peng Date: Sun, 7 Jul 2019 20:12:06 +0800 Subject: [PATCH] Fix get opt issue --- src/lib/conf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/conf.c b/src/lib/conf.c index ed88e00..d527ed7 100644 --- a/src/lib/conf.c +++ b/src/lib/conf.c @@ -117,11 +117,13 @@ void conf_getopt_reset(void) int argc = 2; char *argv[3] = {"reset", "", 0}; - optind = 1; + optind = 0; opterr = 0; + optopt = 0; getopt_long(argc, argv, "", long_options, NULL); - optind = 1; + optind = 0; opterr = 0; + optopt = 0; } int conf_parse_args(char *key, char *value, int *argc, char **argv) @@ -181,7 +183,7 @@ int conf_parse_args(char *key, char *value, int *argc, char **argv) } *argc = count; - argv[count + 1] = 0; + argv[count] = 0; return 0; }