diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-04-12 15:38:01 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-04-13 11:17:28 +0200 |
commit | 06e78680e3c36589b785f90ecda64d124905a3f7 (patch) | |
tree | 4e30e25ea6b5d15e3156ec783cfef15744df9b27 /src/machine-id-setup | |
parent | repart: Discard from/to first/last usable lba (diff) | |
download | systemd-06e78680e3c36589b785f90ecda64d124905a3f7.tar.xz systemd-06e78680e3c36589b785f90ecda64d124905a3f7.zip |
image-policy: introduce parse_image_policy_argument() helper
Addresses
https://github.com/systemd/systemd/pull/25608/commits/84be0c710d9d562f6d2cf986cc2a8ff4c98a138b#r1060130312,
https://github.com/systemd/systemd/pull/25608/commits/84be0c710d9d562f6d2cf986cc2a8ff4c98a138b#r1067927293, and
https://github.com/systemd/systemd/pull/25608/commits/84be0c710d9d562f6d2cf986cc2a8ff4c98a138b#r1067926416.
Follow-up for 84be0c710d9d562f6d2cf986cc2a8ff4c98a138b.
Diffstat (limited to 'src/machine-id-setup')
-rw-r--r-- | src/machine-id-setup/machine-id-setup-main.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/machine-id-setup/machine-id-setup-main.c b/src/machine-id-setup/machine-id-setup-main.c index c5b22d5d76..17012e20ac 100644 --- a/src/machine-id-setup/machine-id-setup-main.c +++ b/src/machine-id-setup/machine-id-setup-main.c @@ -60,9 +60,9 @@ static int parse_argv(int argc, char *argv[]) { ARG_VERSION = 0x100, ARG_ROOT, ARG_IMAGE, + ARG_IMAGE_POLICY, ARG_COMMIT, ARG_PRINT, - ARG_IMAGE_POLICY, }; static const struct option options[] = { @@ -70,9 +70,9 @@ static int parse_argv(int argc, char *argv[]) { { "version", no_argument, NULL, ARG_VERSION }, { "root", required_argument, NULL, ARG_ROOT }, { "image", required_argument, NULL, ARG_IMAGE }, + { "image-policy", required_argument, NULL, ARG_IMAGE_POLICY }, { "commit", no_argument, NULL, ARG_COMMIT }, { "print", no_argument, NULL, ARG_PRINT }, - { "image-policy", required_argument, NULL, ARG_IMAGE_POLICY }, {} }; @@ -103,6 +103,12 @@ static int parse_argv(int argc, char *argv[]) { return r; break; + case ARG_IMAGE_POLICY: + r = parse_image_policy_argument(optarg, &arg_image_policy); + if (r < 0) + return r; + break; + case ARG_COMMIT: arg_commit = true; break; @@ -111,17 +117,6 @@ static int parse_argv(int argc, char *argv[]) { arg_print = true; break; - case ARG_IMAGE_POLICY: { - _cleanup_(image_policy_freep) ImagePolicy *p = NULL; - - r = image_policy_from_string(optarg, &p); - if (r < 0) - return log_error_errno(r, "Failed to parse image policy: %s", optarg); - - image_policy_free(arg_image_policy); - arg_image_policy = TAKE_PTR(p); - break; - } case '?': return -EINVAL; |