]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootspec: add boot_config_selected_entry() helper
authorLennart Poettering <lennart@amutable.com>
Wed, 15 Apr 2026 14:19:55 +0000 (16:19 +0200)
committerLennart Poettering <lennart@amutable.com>
Fri, 1 May 2026 05:10:31 +0000 (07:10 +0200)
src/shared/bootspec.h

index 951a81f08c6c49ae932fb0da165c105bf7306277..afc5a576c9048d8eedb1991028203987158ed713 100644 (file)
@@ -116,6 +116,16 @@ static inline const BootEntry* boot_config_default_entry(const BootConfig *confi
         return config->entries + config->default_entry;
 }
 
+static inline const BootEntry* boot_config_selected_entry(const BootConfig *config) {
+        assert(config);
+
+        if (config->selected_entry < 0)
+                return NULL;
+
+        assert((size_t) config->selected_entry < config->n_entries);
+        return config->entries + config->selected_entry;
+}
+
 void boot_config_free(BootConfig *config);
 
 int boot_loader_read_conf(BootConfig *config, FILE *file, const char *path);