]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootctl: use boot_config_default_entry() where appropriate
authorLennart Poettering <lennart@poettering.net>
Thu, 24 Mar 2022 16:06:16 +0000 (17:06 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 28 Mar 2022 14:01:54 +0000 (16:01 +0200)
src/boot/bootctl.c
src/shared/bootspec.h

index 5c1d2533d77d415ffba90622a0a6a8fa951b842e..2766c8452f4831d779a2f86b37a5cf3993758de5 100644 (file)
@@ -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);
index 5c4b211ee4c55e32e81201b49e290f7bbedcf6a2..0f199d5ee90c364803bb5bf2d42f05b149cb936b 100644 (file)
@@ -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);