summaryrefslogtreecommitdiffstats
path: root/ShellPkg
diff options
context:
space:
mode:
authorDaniel Nguyen <daniel.nguyen@arm.com>2023-11-30 02:28:40 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-12-18 06:11:49 +0000
commit74daeded0cabe87d26546f07f9a3911cb60ec0e1 (patch)
treeaca2c94a3781e384abfe13d3ac53b3400915466b /ShellPkg
parent3ce5f2d445e51efe2aebaa227a055e5c8522d00b (diff)
downloadedk2-74daeded0cabe87d26546f07f9a3911cb60ec0e1.tar.gz
edk2-74daeded0cabe87d26546f07f9a3911cb60ec0e1.tar.bz2
edk2-74daeded0cabe87d26546f07f9a3911cb60ec0e1.zip
ShellPkg: Tidy for code readability
Use error handling instead of success handling. Less indented logic is easier to read. Cc: Zhichao Gao <zhichao.gao@intel.com> Cc: Ray Ni <ray.ni@intel.com> Signed-off-by: Daniel Nguyen <daniel.nguyen@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c43
1 files changed, 24 insertions, 19 deletions
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)) {