From 163d1ea5dd69c75d889ba4c2d1b51432ed14127f Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Tue, 4 Jan 2022 13:12:21 +0100 Subject: [PATCH] boot: Do more config handling in config_load_all_entries --- src/boot/efi/boot.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index 608b3196c2..fac31abc44 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -1700,8 +1700,10 @@ static void config_default_entry_select(Config *config) { return; } - /* no entry found */ - config->idx_default = IDX_INVALID; + /* If no configured entry to select from was found, enable the menu. */ + config->idx_default = 0; + if (config->timeout_sec == 0) + config->timeout_sec = 10; } static BOOLEAN find_nonunique(ConfigEntry **entries, UINTN entry_count) { @@ -2358,6 +2360,16 @@ static void config_load_all_entries( L"auto-reboot-to-firmware-setup", L"Reboot Into Firmware Interface", reboot_into_firmware); + + if (config->entry_count == 0) + return + + config_write_entries_to_variable(config); + + config_title_generate(config); + + /* select entry by configured pattern or EFI LoaderDefaultEntry= variable */ + config_default_entry_select(config); } EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { @@ -2409,20 +2421,6 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { goto out; } - config_write_entries_to_variable(&config); - - config_title_generate(&config); - - /* select entry by configured pattern or EFI LoaderDefaultEntry= variable */ - config_default_entry_select(&config); - - /* if no configured entry to select from was found, enable the menu */ - if (config.idx_default == IDX_INVALID) { - config.idx_default = 0; - if (config.timeout_sec == 0) - config.timeout_sec = 10; - } - /* select entry or show menu when key is pressed or timeout is set */ if (config.force_menu || config.timeout_sec > 0) menu = TRUE;