From: Lennart Poettering Date: Wed, 3 Sep 2025 09:48:39 +0000 (+0200) Subject: bootctl: normalize some enum definitions X-Git-Tag: v259-rc1~487^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83d0b6597c208818412b7c60a90f9229a4407a3b;p=thirdparty%2Fsystemd.git bootctl: normalize some enum definitions --- diff --git a/src/bootctl/bootctl-install.c b/src/bootctl/bootctl-install.c index 4eefc715d5e..3605b43ef03 100644 --- a/src/bootctl/bootctl-install.c +++ b/src/bootctl/bootctl-install.c @@ -381,7 +381,7 @@ static int update_efi_boot_binaries(const char *esp_path, const char *source_pat } static int copy_one_file(const char *esp_path, const char *name, bool force) { - char *root = IN_SET(arg_install_source, ARG_INSTALL_SOURCE_AUTO, ARG_INSTALL_SOURCE_IMAGE) ? arg_root : NULL; + char *root = IN_SET(arg_install_source, INSTALL_SOURCE_AUTO, INSTALL_SOURCE_IMAGE) ? arg_root : NULL; _cleanup_free_ char *source_path = NULL, *dest_path = NULL, *p = NULL, *q = NULL; const char *e; char *dest_name, *s; @@ -398,7 +398,7 @@ static int copy_one_file(const char *esp_path, const char *name, bool force) { r = chase(p, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS|CHASE_TRIGGER_AUTOFS, &source_path, NULL); /* If we had a root directory to try, we didn't find it and we are in auto mode, retry on the host */ - if (r == -ENOENT && root && arg_install_source == ARG_INSTALL_SOURCE_AUTO) + if (r == -ENOENT && root && arg_install_source == INSTALL_SOURCE_AUTO) r = chase(p, NULL, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS|CHASE_TRIGGER_AUTOFS, &source_path, NULL); if (r < 0) return log_error_errno(r, @@ -444,14 +444,14 @@ static int copy_one_file(const char *esp_path, const char *name, bool force) { } static int install_binaries(const char *esp_path, const char *arch, bool force) { - char *root = IN_SET(arg_install_source, ARG_INSTALL_SOURCE_AUTO, ARG_INSTALL_SOURCE_IMAGE) ? arg_root : NULL; + char *root = IN_SET(arg_install_source, INSTALL_SOURCE_AUTO, INSTALL_SOURCE_IMAGE) ? arg_root : NULL; _cleanup_closedir_ DIR *d = NULL; _cleanup_free_ char *path = NULL; int r; r = chase_and_opendir(BOOTLIBDIR, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS|CHASE_TRIGGER_AUTOFS, &path, &d); /* If we had a root directory to try, we didn't find it and we are in auto mode, retry on the host */ - if (r == -ENOENT && root && arg_install_source == ARG_INSTALL_SOURCE_AUTO) + if (r == -ENOENT && root && arg_install_source == INSTALL_SOURCE_AUTO) r = chase_and_opendir(BOOTLIBDIR, NULL, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS|CHASE_TRIGGER_AUTOFS, &path, &d); if (r == -ENOENT && arg_graceful() != ARG_GRACEFUL_NO) { log_debug("Source directory does not exist, ignoring."); diff --git a/src/bootctl/bootctl.c b/src/bootctl/bootctl.c index 0ef17ba5019..86a51f8f410 100644 --- a/src/bootctl/bootctl.c +++ b/src/bootctl/bootctl.c @@ -67,7 +67,7 @@ sd_json_format_flags_t arg_json_format_flags = SD_JSON_FORMAT_OFF; bool arg_arch_all = false; char *arg_root = NULL; char *arg_image = NULL; -InstallSource arg_install_source = ARG_INSTALL_SOURCE_AUTO; +InstallSource arg_install_source = INSTALL_SOURCE_AUTO; char *arg_efi_boot_option_description = NULL; bool arg_dry_run = false; ImagePolicy *arg_image_policy = NULL; @@ -483,11 +483,11 @@ static int parse_argv(int argc, char *argv[]) { case ARG_INSTALL_SOURCE: if (streq(optarg, "auto")) - arg_install_source = ARG_INSTALL_SOURCE_AUTO; + arg_install_source = INSTALL_SOURCE_AUTO; else if (streq(optarg, "image")) - arg_install_source = ARG_INSTALL_SOURCE_IMAGE; + arg_install_source = INSTALL_SOURCE_IMAGE; else if (streq(optarg, "host")) - arg_install_source = ARG_INSTALL_SOURCE_HOST; + arg_install_source = INSTALL_SOURCE_HOST; else return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unexpected parameter for --install-source=: %s", optarg); @@ -648,7 +648,7 @@ static int parse_argv(int argc, char *argv[]) { if (arg_root && arg_image) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Please specify either --root= or --image=, the combination of both is not supported."); - if (arg_install_source != ARG_INSTALL_SOURCE_AUTO && !arg_root && !arg_image) + if (arg_install_source != INSTALL_SOURCE_AUTO && !arg_root && !arg_image) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--install-from-host is only supported with --root= or --image=."); if (arg_dry_run && argv[optind] && !STR_IN_SET(argv[optind], "unlink", "cleanup")) diff --git a/src/bootctl/bootctl.h b/src/bootctl/bootctl.h index 7504d5715cf..4f052e67bc1 100644 --- a/src/bootctl/bootctl.h +++ b/src/bootctl/bootctl.h @@ -4,9 +4,11 @@ #include "forward.h" typedef enum InstallSource { - ARG_INSTALL_SOURCE_IMAGE, - ARG_INSTALL_SOURCE_HOST, - ARG_INSTALL_SOURCE_AUTO, + INSTALL_SOURCE_IMAGE, + INSTALL_SOURCE_HOST, + INSTALL_SOURCE_AUTO, + _INSTALL_SOURCE_MAX, + _INSTALL_SOURCE_INVALID = -EINVAL, } InstallSource; typedef enum GracefulMode { diff --git a/src/shared/boot-entry.h b/src/shared/boot-entry.h index 927802e5eee..71260d4ff7b 100644 --- a/src/shared/boot-entry.h +++ b/src/shared/boot-entry.h @@ -11,6 +11,8 @@ typedef enum BootEntryTokenType { BOOT_ENTRY_TOKEN_OS_ID, BOOT_ENTRY_TOKEN_LITERAL, BOOT_ENTRY_TOKEN_AUTO, + _BOOT_ENTRY_TOKEN_TYPE_MAX, + _BOOT_ENTRY_TOKEN_TYPE_INVALID = -EINVAL, } BootEntryTokenType; bool boot_entry_token_valid(const char *p);