[U-Boot] [PATCH] cmd: env: print a message when setting UEFI variable failed

AKASHI Takahiro takahiro.akashi at linaro.org
Tue May 14 04:58:53 UTC 2019


Error message will alert a user that setting/deleting a variable failed.

Signed-off-by: AKASHI Takahiro <takahiro.akashi at linaro.org>
---
 cmd/nvedit_efi.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c
index 2805e8182b41..e0d8f578ac33 100644
--- a/cmd/nvedit_efi.c
+++ b/cmd/nvedit_efi.c
@@ -373,6 +373,7 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 		for ( ; argc > 0; argc--, argv++)
 			if (append_value(&value, &size, argv[0]) < 0) {
+				printf("## Failed to process arguments\n");
 				ret = CMD_RET_FAILURE;
 				goto out;
 			}
@@ -381,6 +382,7 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	len = utf8_utf16_strnlen(var_name, strlen(var_name));
 	var_name16 = malloc((len + 1) * 2);
 	if (!var_name16) {
+		printf("## Can't malloc %ld bytes\n", (len + 1) * 2);
 		ret = CMD_RET_FAILURE;
 		goto out;
 	}
@@ -392,7 +394,13 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 					EFI_VARIABLE_BOOTSERVICE_ACCESS |
 					EFI_VARIABLE_RUNTIME_ACCESS,
 					size, value));
-	ret = (ret == EFI_SUCCESS ? CMD_RET_SUCCESS : CMD_RET_FAILURE);
+	if (ret == EFI_SUCCESS) {
+		ret = CMD_RET_SUCCESS;
+	} else {
+		printf("## Failed to set EFI variable (%ld)\n",
+		       ret & ~EFI_ERROR_MASK);
+		ret = CMD_RET_FAILURE;
+	}
 out:
 	free(value);
 	free(var_name16);
-- 
2.21.0



More information about the U-Boot mailing list