diff mbox series

[1/1] efi_loader: simplify try_load_entry()

Message ID 20220425213704.51742-1-heinrich.schuchardt@canonical.com
State Accepted, archived
Delegated to: Heinrich Schuchardt
Headers show
Series [1/1] efi_loader: simplify try_load_entry() | expand

Commit Message

Heinrich Schuchardt April 25, 2022, 9:37 p.m. UTC
Use function efi_create_indexed_name() to create the BootXXXX variable
name.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
 lib/efi_loader/efi_bootmgr.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c
index 8c04ecbdc8..92fc2fcdf0 100644
--- a/lib/efi_loader/efi_bootmgr.c
+++ b/lib/efi_loader/efi_bootmgr.c
@@ -46,16 +46,12 @@  static efi_status_t try_load_entry(u16 n, efi_handle_t *handle,
 				   void **load_options)
 {
 	struct efi_load_option lo;
-	u16 varname[] = u"Boot0000";
-	u16 hexmap[] = u"0123456789ABCDEF";
+	u16 varname[9];
 	void *load_option;
 	efi_uintn_t size;
 	efi_status_t ret;
 
-	varname[4] = hexmap[(n & 0xf000) >> 12];
-	varname[5] = hexmap[(n & 0x0f00) >> 8];
-	varname[6] = hexmap[(n & 0x00f0) >> 4];
-	varname[7] = hexmap[(n & 0x000f) >> 0];
+	efi_create_indexed_name(varname, sizeof(varname), u"Boot", n);
 
 	load_option = efi_get_var(varname, &efi_global_variable_guid, &size);
 	if (!load_option)