From: Krzesimir Nowak Date: Tue, 19 Mar 2024 12:20:46 +0000 (+0100) Subject: sysext: Move parsing mutable mode to a separate function X-Git-Tag: v256-rc1~405^2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=738eaf969744503b83fddb340905c1871da1196c;p=thirdparty%2Fsystemd.git sysext: Move parsing mutable mode to a separate function --- diff --git a/src/sysext/sysext.c b/src/sysext/sysext.c index 2329081992e..496c5596a7f 100644 --- a/src/sysext/sysext.c +++ b/src/sysext/sysext.c @@ -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 '?':