From 74daeded0cabe87d26546f07f9a3911cb60ec0e1 Mon Sep 17 00:00:00 2001 From: Daniel Nguyen Date: Thu, 30 Nov 2023 02:28:40 +0800 Subject: ShellPkg: Tidy for code readability Use error handling instead of success handling. Less indented logic is easier to read. Cc: Zhichao Gao Cc: Ray Ni Signed-off-by: Daniel Nguyen Reviewed-by: Zhichao Gao --- .../Library/UefiShellLevel2CommandsLib/Reset.c | 43 ++++++++++++---------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'ShellPkg') diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c index 57ba3c90f3..361c47e430 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c @@ -79,30 +79,35 @@ ShellCommandRunReset ( &DataSize, &OsIndications ); - if (!EFI_ERROR (Status)) { - if ((OsIndications & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) != 0) { - DataSize = sizeof (OsIndications); - Status = gRT->GetVariable ( - EFI_OS_INDICATIONS_VARIABLE_NAME, - &gEfiGlobalVariableGuid, - &Attr, - &DataSize, - &OsIndications - ); - if (!EFI_ERROR (Status)) { - OsIndications |= EFI_OS_INDICATIONS_BOOT_TO_FW_UI; - } else { - OsIndications = EFI_OS_INDICATIONS_BOOT_TO_FW_UI; - } - - Status = gRT->SetVariable ( + + if (EFI_ERROR (Status)) { + ShellStatus = SHELL_UNSUPPORTED; + goto Error; + } + + if ((OsIndications & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) != 0) { + DataSize = sizeof (OsIndications); + Status = gRT->GetVariable ( EFI_OS_INDICATIONS_VARIABLE_NAME, &gEfiGlobalVariableGuid, - EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, - sizeof (OsIndications), + &Attr, + &DataSize, &OsIndications ); + + if (EFI_ERROR (Status)) { + OsIndications = EFI_OS_INDICATIONS_BOOT_TO_FW_UI; + } else { + OsIndications |= EFI_OS_INDICATIONS_BOOT_TO_FW_UI; } + + Status = gRT->SetVariable ( + EFI_OS_INDICATIONS_VARIABLE_NAME, + &gEfiGlobalVariableGuid, + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, + sizeof (OsIndications), + &OsIndications + ); } if (EFI_ERROR (Status)) { -- cgit v1.2.3