]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: Remove trivial config entry add helpers
authorJan Janssen <medhefgo@web.de>
Wed, 11 May 2022 10:52:24 +0000 (12:52 +0200)
committerJan Janssen <medhefgo@web.de>
Sun, 22 May 2022 10:48:06 +0000 (12:48 +0200)
These two functions have very limited use and are just fancy wrappers
around structured initializers.

src/boot/efi/boot.c

index bb8e8417e4e1a8d3c5669dcc1d26547954deb4a3..5a1192cc9fb4594cc8a304406bcdc7c030381d1a 100644 (file)
@@ -1846,71 +1846,6 @@ static void config_title_generate(Config *config) {
         }
 }
 
-static BOOLEAN config_entry_add_call(
-                Config *config,
-                const CHAR16 *id,
-                const CHAR16 *title,
-                EFI_STATUS (*call)(void)) {
-
-        ConfigEntry *entry;
-
-        assert(config);
-        assert(id);
-        assert(title);
-        assert(call);
-
-        entry = xnew(ConfigEntry, 1);
-        *entry = (ConfigEntry) {
-                .id = xstrdup(id),
-                .title = xstrdup(title),
-                .call = call,
-                .tries_done = UINTN_MAX,
-                .tries_left = UINTN_MAX,
-        };
-
-        config_add_entry(config, entry);
-        return TRUE;
-}
-
-static ConfigEntry *config_entry_add_loader(
-                Config *config,
-                EFI_HANDLE *device,
-                enum loader_type type,
-                const CHAR16 *id,
-                CHAR16 key,
-                const CHAR16 *title,
-                const CHAR16 *loader,
-                const CHAR16 *sort_key,
-                const CHAR16 *version) {
-
-        ConfigEntry *entry;
-
-        assert(config);
-        assert(device);
-        assert(id);
-        assert(title);
-        assert(loader);
-
-        entry = xnew(ConfigEntry, 1);
-        *entry = (ConfigEntry) {
-                .type = type,
-                .title = xstrdup(title),
-                .version = version ? xstrdup(version) : NULL,
-                .device = device,
-                .loader = xstrdup(loader),
-                .id = xstrdup(id),
-                .sort_key = sort_key ? xstrdup(sort_key) : NULL,
-                .key = key,
-                .tries_done = UINTN_MAX,
-                .tries_left = UINTN_MAX,
-        };
-
-        StrLwr(entry->id);
-
-        config_add_entry(config, entry);
-        return entry;
-}
-
 static BOOLEAN is_sd_boot(EFI_FILE *root_dir, const CHAR16 *loader_path) {
         EFI_STATUS err;
         const CHAR8 *sections[] = {
@@ -1974,7 +1909,20 @@ static ConfigEntry *config_entry_add_loader_auto(
         if (EFI_ERROR(err))
                 return NULL;
 
-        return config_entry_add_loader(config, device, LOADER_AUTO, id, key, title, loader, NULL, NULL);
+        ConfigEntry *entry = xnew(ConfigEntry, 1);
+        *entry = (ConfigEntry) {
+                .id = xstrdup(id),
+                .type = LOADER_AUTO,
+                .title = xstrdup(title),
+                .device = device,
+                .loader = xstrdup(loader),
+                .key = key,
+                .tries_done = UINTN_MAX,
+                .tries_left = UINTN_MAX,
+        };
+
+        config_add_entry(config, entry);
+        return entry;
 }
 
 static void config_entry_add_osx(Config *config) {
@@ -2124,7 +2072,6 @@ static void config_entry_add_linux(
 
         _cleanup_(file_closep) EFI_FILE *linux_dir = NULL;
         _cleanup_freepool_ EFI_FILE_INFO *f = NULL;
-        ConfigEntry *entry;
         UINTN f_size = 0;
         EFI_STATUS err;
 
@@ -2152,8 +2099,7 @@ static void config_entry_add_linux(
                 };
 
                 _cleanup_freepool_ CHAR16 *os_pretty_name = NULL, *os_image_id = NULL, *os_name = NULL, *os_id = NULL,
-                        *os_image_version = NULL, *os_version = NULL, *os_version_id = NULL, *os_build_id = NULL,
-                        *path = NULL;
+                        *os_image_version = NULL, *os_version = NULL, *os_version_id = NULL, *os_build_id = NULL;
                 const CHAR16 *good_name, *good_version, *good_sort_key;
                 _cleanup_freepool_ CHAR8 *content = NULL;
                 UINTN offs[_SECTION_MAX] = {};
@@ -2249,18 +2195,22 @@ static void config_entry_add_linux(
                                     &good_sort_key))
                         continue;
 
-                path = xpool_print(L"\\EFI\\Linux\\%s", f->FileName);
-                entry = config_entry_add_loader(
-                                config,
-                                device,
-                                LOADER_UNIFIED_LINUX,
-                                /* id= */ f->FileName,
-                                /* key= */ 'l',
-                                /* title= */ good_name,
-                                /* loader= */ path,
-                                /* sort_key= */ good_sort_key,
-                                good_version);
+                ConfigEntry *entry = xnew(ConfigEntry, 1);
+                *entry = (ConfigEntry) {
+                        .id = xstrdup(f->FileName),
+                        .type = LOADER_UNIFIED_LINUX,
+                        .title = xstrdup(good_name),
+                        .version = good_version ? xstrdup(good_version) : NULL,
+                        .device = device,
+                        .loader = xpool_print(L"\\EFI\\Linux\\%s", f->FileName),
+                        .sort_key = good_sort_key ? xstrdup(good_sort_key) : NULL,
+                        .key = 'l',
+                        .tries_done = UINTN_MAX,
+                        .tries_left = UINTN_MAX,
+                };
 
+                StrLwr(entry->id);
+                config_add_entry(config, entry);
                 config_entry_parse_tries(entry, L"\\EFI\\Linux", f->FileName, L".efi");
 
                 if (szs[SECTION_CMDLINE] == 0)
@@ -2592,11 +2542,17 @@ static void config_load_all_entries(
         config_entry_add_loader_auto(config, loaded_image->DeviceHandle, root_dir, loaded_image_path,
                                      L"auto-efi-default", '\0', L"EFI Default Loader", NULL);
 
-        if (config->auto_firmware && FLAGS_SET(get_os_indications_supported(), EFI_OS_INDICATIONS_BOOT_TO_FW_UI))
-                config_entry_add_call(config,
-                                      L"auto-reboot-to-firmware-setup",
-                                      L"Reboot Into Firmware Interface",
-                                      reboot_into_firmware);
+        if (config->auto_firmware && FLAGS_SET(get_os_indications_supported(), EFI_OS_INDICATIONS_BOOT_TO_FW_UI)) {
+                ConfigEntry *entry = xnew(ConfigEntry, 1);
+                *entry = (ConfigEntry) {
+                        .id = xstrdup(L"auto-reboot-to-firmware-setup"),
+                        .title = xstrdup(L"Reboot Into Firmware Interface"),
+                        .call = reboot_into_firmware,
+                        .tries_done = UINTN_MAX,
+                        .tries_left = UINTN_MAX,
+                };
+                config_add_entry(config, entry);
+        }
 
         if (config->entry_count == 0)
                 return;