]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
machinectl: simplify option string assignment
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 24 Apr 2016 15:31:19 +0000 (11:31 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 27 Apr 2016 13:05:42 +0000 (09:05 -0400)
It's better to avoid having the option string duplicated, lest we forget
to modify them in sync in the future.

src/machine/machinectl.c

index b03198bbf1ea4d1dea27878d04eadccbb4215ae4..5a68c4ceb279c51deefda6e264bd142da315ea56 100644 (file)
@@ -2516,14 +2516,9 @@ static int parse_argv(int argc, char *argv[]) {
         assert(argv);
 
         for (;;) {
-                const char *option_string;
+                const char * const option_string = "+hp:als:H:M:qn:o:";
 
-                if (reorder)
-                        option_string = "hp:als:H:M:qn:o:";
-                else
-                        option_string = "+hp:als:H:M:qn:o:";
-
-                c = getopt_long(argc, argv, option_string, options, NULL);
+                c = getopt_long(argc, argv, option_string + reorder, options, NULL);
                 if (c < 0) {
                         /* We generally are fine with the fact that getopt_long() reorders the command line, and looks
                          * for switches after the main verb. However, for "shell" we really don't want that, since we