* [edk2-devel] [PATCH v2 0/1] ShellPkg: Tidy for code readability @ 2023-11-29 18:28 Daniel Nguyen 2023-11-29 18:28 ` [edk2-devel] [PATCH v2 1/1] " Daniel Nguyen 0 siblings, 1 reply; 4+ messages in thread From: Daniel Nguyen @ 2023-11-29 18:28 UTC (permalink / raw) To: devel; +Cc: nd, Daniel Nguyen Use error handling instead of success handling. Less indented logic is easier to read. Daniel Nguyen (1): ShellPkg: Tidy for code readability ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c | 41 +++++++++++--------- 1 file changed, 23 insertions(+), 18 deletions(-) -- 2.25.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111855): https://edk2.groups.io/g/devel/message/111855 Mute This Topic: https://groups.io/mt/102877863/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=- ^ permalink raw reply [flat|nested] 4+ messages in thread
* [edk2-devel] [PATCH v2 1/1] ShellPkg: Tidy for code readability 2023-11-29 18:28 [edk2-devel] [PATCH v2 0/1] ShellPkg: Tidy for code readability Daniel Nguyen @ 2023-11-29 18:28 ` Daniel Nguyen 2023-12-13 11:45 ` Tom Pilar 0 siblings, 1 reply; 4+ messages in thread From: Daniel Nguyen @ 2023-11-29 18:28 UTC (permalink / raw) To: devel; +Cc: nd, Daniel Nguyen, Zhichao Gao, Ray Ni 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> --- ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c | 41 +++++++++++--------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c index 57ba3c90f373..361c47e43059 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)) { -- 2.25.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111856): https://edk2.groups.io/g/devel/message/111856 Mute This Topic: https://groups.io/mt/102877864/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=- ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [edk2-devel] [PATCH v2 1/1] ShellPkg: Tidy for code readability 2023-11-29 18:28 ` [edk2-devel] [PATCH v2 1/1] " Daniel Nguyen @ 2023-12-13 11:45 ` Tom Pilar 2023-12-14 2:51 ` Gao, Zhichao 0 siblings, 1 reply; 4+ messages in thread From: Tom Pilar @ 2023-12-13 11:45 UTC (permalink / raw) To: devel@edk2.groups.io, Daniel Nguyen; +Cc: nd, Zhichao Gao, Ray Ni Hi Zhichao & Ray, Can you have a quick review of this patch, no logic has changed, just a code tidy. Cheers, Tom > On 29 Nov 2023, at 18:28, Daniel Nguyen via groups.io <daniel.nguyen=arm.com@groups.io> wrote: > > Warning: EXTERNAL SENDER, use caution when opening links or attachments. > > > 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> > --- > ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c | 41 +++++++++++--------- > 1 file changed, 23 insertions(+), 18 deletions(-) > > diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c > index 57ba3c90f373..361c47e43059 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)) { > -- > 2.25.1 > > > > -=-=-=-=-=-= > Groups.io Links: You receive all messages sent to this group. > View/Reply Online (#111856): https://edk2.groups.io/g/devel/message/111856 > Mute This Topic: https://groups.io/mt/102877864/7994090 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [tom.pilar@arm.com] > -=-=-=-=-=-= > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112471): https://edk2.groups.io/g/devel/message/112471 Mute This Topic: https://groups.io/mt/102877864/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=- ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [edk2-devel] [PATCH v2 1/1] ShellPkg: Tidy for code readability 2023-12-13 11:45 ` Tom Pilar @ 2023-12-14 2:51 ` Gao, Zhichao 0 siblings, 0 replies; 4+ messages in thread From: Gao, Zhichao @ 2023-12-14 2:51 UTC (permalink / raw) To: Tom Pilar, devel@edk2.groups.io, Daniel Nguyen; +Cc: nd, Ni, Ray The patch looks good to me. Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Thanks, Zhichao > -----Original Message----- > From: Tom Pilar <Tom.Pilar@arm.com> > Sent: Wednesday, December 13, 2023 7:45 PM > To: devel@edk2.groups.io; Daniel Nguyen <Daniel.Nguyen@arm.com> > Cc: nd <nd@arm.com>; Gao, Zhichao <zhichao.gao@intel.com>; Ni, Ray > <ray.ni@intel.com> > Subject: Re: [edk2-devel] [PATCH v2 1/1] ShellPkg: Tidy for code readability > > Hi Zhichao & Ray, > > Can you have a quick review of this patch, no logic has changed, just a code > tidy. > > Cheers, > Tom > > > On 29 Nov 2023, at 18:28, Daniel Nguyen via groups.io > <daniel.nguyen=arm.com@groups.io> wrote: > > > > Warning: EXTERNAL SENDER, use caution when opening links or > attachments. > > > > > > 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> > > --- > > ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c | 41 > > +++++++++++--------- > > 1 file changed, 23 insertions(+), 18 deletions(-) > > > > diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c > > b/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c > > index 57ba3c90f373..361c47e43059 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)) { > > -- > > 2.25.1 > > > > > > > > -=-=-=-=-=-= > > Groups.io Links: You receive all messages sent to this group. > > View/Reply Online (#111856): > > https://edk2.groups.io/g/devel/message/111856 > > Mute This Topic: https://groups.io/mt/102877864/7994090 > > Group Owner: devel+owner@edk2.groups.io > > Unsubscribe: https://edk2.groups.io/g/devel/unsub [tom.pilar@arm.com] > > -=-=-=-=-=-= > > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112495): https://edk2.groups.io/g/devel/message/112495 Mute This Topic: https://groups.io/mt/102877864/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=- ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-12-14 2:51 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-11-29 18:28 [edk2-devel] [PATCH v2 0/1] ShellPkg: Tidy for code readability Daniel Nguyen 2023-11-29 18:28 ` [edk2-devel] [PATCH v2 1/1] " Daniel Nguyen 2023-12-13 11:45 ` Tom Pilar 2023-12-14 2:51 ` Gao, Zhichao
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox