diff mbox series

[5/5] eficonfig: add error message of SetVariable

Message ID 20230202092447.28590-6-masahisa.kojima@linaro.org
State New
Headers show
Series improve eficonfig usability | expand

Commit Message

Masahisa Kojima Feb. 2, 2023, 9:24 a.m. UTC
This commits add the error message when EFI Runtime Service
SetVariable() failed.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
---
 cmd/eficonfig.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
index b0c8637676..c5cbf27631 100644
--- a/cmd/eficonfig.c
+++ b/cmd/eficonfig.c
@@ -30,6 +30,8 @@  static const char *eficonfig_change_boot_order_desc =
 	"  Press SPACE to activate or deactivate the entry\n"
 	"  CTRL+S to save, ESC to quit";
 
+static const char *set_variable_fail_str = "SetVariable failed!";
+
 static struct efi_simple_text_output_protocol *cout;
 static int avail_row;
 
@@ -1274,6 +1276,9 @@  static efi_status_t eficonfig_set_boot_option(u16 *varname, struct efi_device_pa
 				   EFI_VARIABLE_BOOTSERVICE_ACCESS |
 				   EFI_VARIABLE_RUNTIME_ACCESS,
 				   size, p, false);
+	if (ret != EFI_SUCCESS)
+		eficonfig_print_msg(set_variable_fail_str, ret);
+
 	free(p);
 
 	return ret;
@@ -1309,8 +1314,10 @@  efi_status_t eficonfig_append_bootorder(u16 index)
 				   EFI_VARIABLE_BOOTSERVICE_ACCESS |
 				   EFI_VARIABLE_RUNTIME_ACCESS,
 				   new_size, new_bootorder, false);
-	if (ret != EFI_SUCCESS)
+	if (ret != EFI_SUCCESS) {
+		eficonfig_print_msg(set_variable_fail_str, ret);
 		goto out;
+	}
 
 out:
 	free(bootorder);
@@ -2155,6 +2162,8 @@  static efi_status_t eficonfig_process_save_boot_order(void *data)
 				   EFI_VARIABLE_BOOTSERVICE_ACCESS |
 				   EFI_VARIABLE_RUNTIME_ACCESS,
 				   size, new_bootorder, false);
+	if (ret != EFI_SUCCESS)
+		eficonfig_print_msg(set_variable_fail_str, ret);
 
 	save_data->selected = true;
 out:
@@ -2394,7 +2403,7 @@  static efi_status_t delete_boot_option(u16 boot_index)
 	ret = efi_set_variable_int(varname, &efi_global_variable_guid,
 				   0, 0, NULL, false);
 	if (ret != EFI_SUCCESS) {
-		log_err("delete boot option(%ls) failed\n", varname);
+		eficonfig_print_msg("Delete boot option(%ls) failed!", ret);
 		return ret;
 	}
 
@@ -2415,6 +2424,8 @@  static efi_status_t delete_boot_option(u16 boot_index)
 				   EFI_VARIABLE_BOOTSERVICE_ACCESS |
 				   EFI_VARIABLE_RUNTIME_ACCESS,
 				   size, bootorder, false);
+	if (ret != EFI_SUCCESS)
+		eficonfig_print_msg(set_variable_fail_str, ret);
 
 	return ret;
 }
@@ -2672,13 +2683,18 @@  efi_status_t eficonfig_generate_media_device_boot_option(void)
 						   EFI_VARIABLE_BOOTSERVICE_ACCESS |
 						   EFI_VARIABLE_RUNTIME_ACCESS,
 						   opt[i].size, opt[i].lo, false);
-			if (ret != EFI_SUCCESS)
+			if (ret != EFI_SUCCESS) {
+				eficonfig_print_msg(set_variable_fail_str, ret);
 				goto out;
+			}
 
 			ret = eficonfig_append_bootorder(boot_index);
 			if (ret != EFI_SUCCESS) {
 				efi_set_variable_int(var_name, &efi_global_variable_guid,
 						     0, 0, NULL, false);
+				if (ret != EFI_SUCCESS)
+					eficonfig_print_msg(set_variable_fail_str, ret);
+
 				goto out;
 			}
 		}