]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
util: Use argconfig commandline options pointer directly
authorTokunori Ikegami <ikegami.t@gmail.com>
Wed, 22 Mar 2023 15:29:30 +0000 (00:29 +0900)
committerDaniel Wagner <wagi@monom.org>
Fri, 24 Mar 2023 14:31:36 +0000 (15:31 +0100)
Also change print help function options argument as not const variable.
Fix ";;" also incorrectly used to ";".

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
util/argconfig.c
util/argconfig.h

index 333704392b2803ec04e8d0daf64fbb212f673aac..f247fc54df5a1e5f8f1eb3eccb17b0e2d1333e40 100644 (file)
@@ -122,21 +122,19 @@ static void show_option(const struct argconfig_commandline_options *option)
 }
 
 void argconfig_print_help(const char *program_desc,
-                         const struct argconfig_commandline_options *options)
+                         struct argconfig_commandline_options *s)
 {
-       const struct argconfig_commandline_options *s;
-
        fprintf(stderr, "\033[1mUsage: %s\033[0m\n\n",
                append_usage_str);
 
        print_word_wrapped(program_desc, 0, 0, stderr);
        fprintf(stderr, "\n");
 
-       if (!options || !options->option)
+       if (!s || !s->option)
                return;
 
        fprintf(stderr, "\n\033[1mOptions:\033[0m\n");
-       for (s = options; (s != NULL) && (s->option != NULL); s++)
+       for (; s && s->option; s++)
                show_option(s);
 }
 
@@ -598,14 +596,12 @@ void argconfig_register_help_func(argconfig_help_func * f)
        }
 }
 
-bool argconfig_parse_seen(struct argconfig_commandline_options *options,
+bool argconfig_parse_seen(struct argconfig_commandline_options *s,
                          const char *option)
 {
-       struct argconfig_commandline_options *s;
-
-       for (s = options; s && s->option; s++) {
+       for (; s && s->option; s++) {
                if (!strcmp(s->option, option))
-                       return s->seen;;
+                       return s->seen;
        }
 
        return false;
index 8f7e7bbefa755d5915e529774fb17729833d969e..b691159f5143161f69196a045e6fe65ea0d60088 100644 (file)
@@ -119,7 +119,7 @@ struct argconfig_commandline_options {
 typedef void argconfig_help_func();
 void argconfig_append_usage(const char *str);
 void argconfig_print_help(const char *program_desc,
-                         const struct argconfig_commandline_options *options);
+                         struct argconfig_commandline_options *options);
 int argconfig_parse(int argc, char *argv[], const char *program_desc,
                    struct argconfig_commandline_options *options);
 int argconfig_parse_subopt_string(char *string, char **options,