]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sysext: Move parsing mutable mode to a separate function
authorKrzesimir Nowak <knowak@microsoft.com>
Tue, 19 Mar 2024 12:20:46 +0000 (13:20 +0100)
committerKrzesimir Nowak <knowak@microsoft.com>
Mon, 25 Mar 2024 07:14:36 +0000 (08:14 +0100)
src/sysext/sysext.c

index 2329081992e7da23d7ee213075db9dd57ea5034e..496c5596a7f7e22b664c55a17b5b7dbd3aba2c1f 100644 (file)
@@ -119,6 +119,24 @@ static const struct {
         }
 };
 
+static int parse_mutable_mode(const char *p) {
+        int r;
+
+        assert(p);
+
+        if (streq(p, "auto"))
+                return MUTABLE_AUTO;
+
+        if (streq(p, "import"))
+                return MUTABLE_IMPORT;
+
+        r = parse_boolean(p);
+        if (r < 0)
+                return r;
+
+        return r ? MUTABLE_YES : MUTABLE_NO;
+}
+
 static int is_our_mount_point(
                 ImageClass image_class,
                 const char *p) {
@@ -2109,16 +2127,10 @@ static int parse_argv(int argc, char *argv[]) {
                         break;
 
                 case ARG_MUTABLE:
-                        if (streq(optarg, "auto"))
-                                arg_mutable = MUTABLE_AUTO;
-                        else if (streq(optarg, "import"))
-                                arg_mutable = MUTABLE_IMPORT;
-                        else {
-                                r = parse_boolean(optarg);
-                                if (r < 0)
-                                        return log_error_errno(r, "Failed to parse argument to --mutable=: %s", optarg);
-                                arg_mutable = r ? MUTABLE_YES : MUTABLE_NO;
-                        }
+                        r = parse_mutable_mode(optarg);
+                        if (r < 0)
+                                return log_error_errno(r, "Failed to parse argument to --mutable=: %s", optarg);
+                        arg_mutable = r;
                         break;
 
                 case '?':