]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: get rid of redundant variable 'dry_run'
authorLennart Poettering <lennart@poettering.net>
Fri, 29 Sep 2023 14:16:03 +0000 (16:16 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 5 Oct 2023 17:05:33 +0000 (19:05 +0200)
There's only one case where we set 'dry_run', which is when
--empty=create is set. Hence simplify things and directly check for
that.

src/partition/repart.c

index 8ba6a9cb05bbabcf2ca2f314a0c0536b0b8ca02e..094851445531997e033d246571f2e41d04da57d7 100644 (file)
@@ -6455,7 +6455,7 @@ static int parse_argv(int argc, char *argv[]) {
                 {}
         };
 
-        int c, r, dry_run = -1;
+        int c, r;
 
         assert(argc >= 0);
         assert(argv);
@@ -6495,14 +6495,9 @@ static int parse_argv(int argc, char *argv[]) {
                                 arg_empty = EMPTY_REQUIRE;
                         else if (streq(optarg, "force"))
                                 arg_empty = EMPTY_FORCE;
-                        else if (streq(optarg, "create")) {
+                        else if (streq(optarg, "create"))
                                 arg_empty = EMPTY_CREATE;
-
-                                if (dry_run < 0)
-                                        dry_run = false; /* Imply --dry-run=no if we create the loopback file
-                                                          * anew. After all we cannot really break anyone's
-                                                          * partition tables that way. */
-                        } else
+                        else
                                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                                        "Failed to parse --empty= parameter: %s", optarg);
                         break;
@@ -6812,8 +6807,9 @@ static int parse_argv(int argc, char *argv[]) {
                 arg_dry_run = true; /* When --can-factory-reset is specified we don't make changes, hence
                                      * non-dry-run mode makes no sense. Thus, imply dry run mode so that we
                                      * open things strictly read-only. */
-        else if (dry_run >= 0)
-                arg_dry_run = dry_run;
+        else if (arg_empty == EMPTY_CREATE)
+                arg_dry_run = false; /* Imply --dry-run=no if we create the loopback file anew. After all we
+                                      * cannot really break anyone's partition tables that way. */
 
         /* Disable pager once we are not just reviewing, but doing things. */
         if (!arg_dry_run)