From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Date: Thu, 6 Oct 2022 04:48:02 +0000 (+0200)
Subject: cmd: simplify do_efi_boot_add()
X-Git-Tag: v2025.01-rc5-pxa1908~1259^2~16
X-Git-Url: http://git.dujemihanovic.xyz/img/html/%7B%7B%20%28.OutputFormats.Get?a=commitdiff_plain;h=80fadf4af6413f9668f6cfaea39f7a101103ce9e;p=u-boot.git

cmd: simplify do_efi_boot_add()

Use efi_convert_string() to convert a UTF-8 to a UTF-16 string.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---

diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index 84e6ff5565..25b5c47f3e 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -812,7 +812,6 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag,
 	char *endp;
 	u16 var_name16[9];
 	efi_guid_t guid;
-	size_t label_len, label_len16;
 	u16 *label;
 	struct efi_device_path *file_path = NULL;
 	struct efi_device_path *fp_free = NULL;
@@ -859,13 +858,10 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag,
 						"Boot", id);
 
 			/* label */
-			label_len = strlen(argv[2]);
-			label_len16 = utf8_utf16_strnlen(argv[2], label_len);
-			label = malloc((label_len16 + 1) * sizeof(u16));
+			label = efi_convert_string(argv[2]);
 			if (!label)
 				return CMD_RET_FAILURE;
 			lo.label = label; /* label will be changed below */
-			utf8_utf16_strncpy(&label, argv[2], label_len);
 
 			/* file path */
 			ret = efi_dp_from_name(argv[3], argv[4], argv[5],