From d412691a91fc29e2a8204fe4b3494426fbb76cac Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 24 Mar 2022 17:06:16 +0100 Subject: bootctl: use boot_config_default_entry() where appropriate --- src/boot/bootctl.c | 2 +- src/shared/bootspec.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index 5c1d2533d7..2766c8452f 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -723,7 +723,7 @@ static int status_entries( printf("Default Boot Loader Entry:\n"); r = boot_entry_show( - config.entries + config.default_entry, + boot_config_default_entry(&config), /* show_as_default= */ false, /* show_as_selected= */ false, /* show_discovered= */ false); diff --git a/src/shared/bootspec.h b/src/shared/bootspec.h index 5c4b211ee4..0f199d5ee9 100644 --- a/src/shared/bootspec.h +++ b/src/shared/bootspec.h @@ -56,6 +56,7 @@ typedef struct BootConfig { BootEntry *entries; size_t n_entries; + ssize_t default_entry; ssize_t selected_entry; @@ -86,10 +87,12 @@ static inline BootEntry* boot_config_default_entry(BootConfig *config) { if (config->default_entry < 0) return NULL; + assert((size_t) config->default_entry < config->n_entries); return config->entries + config->default_entry; } void boot_config_free(BootConfig *config); + int boot_entries_load_config(const char *esp_path, const char *xbootldr_path, BootConfig *config); int boot_entries_load_config_auto(const char *override_esp_path, const char *override_xbootldr_path, BootConfig *config); int boot_entries_augment_from_loader(BootConfig *config, char **list, bool only_auto); -- cgit v1.2.3