I considered the least code change approach without considering any optimization which also works as such.

However, yes, the duplicated /unnecessary subsequent checks can be removed.

On Tue, Nov 7, 2023 at 9:51 PM Laszlo Ersek <lersek@redhat.com> wrote:
On 11/7/23 07:19, Ranbir Singh wrote:
> From: Ranbir Singh <Ranbir.Singh3@Dell.com>
>
> The function PciHotPlugRequestNotify has two if blocks towards the end
> of function both containing return. Due to the parameter checks ensured
> at the beginning of the function, one of the two if blocks is bound to
> come in execution flow. Hence, the return EFI_SUCCESS; at line 2112 is
> redundant/deadcode.

Agree with the analysis.

>
> To fix it, either of line 2109 or 2112 can be deleted.
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4239
>
> Cc: Ray Ni <ray.ni@intel.com>
> Co-authored-by: Veeresh Sangolli <veeresh.sangolli@dellteam.com>
> Signed-off-by: Ranbir Singh <Ranbir.Singh3@Dell.com>
> Signed-off-by: Ranbir Singh <rsingh@ventanamicro.com>
> ---
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
> index 3f8c6e6da7dc..5b71e152f3ea 100644
> --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
> +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
> @@ -2106,7 +2106,6 @@ PciHotPlugRequestNotify (
>      //
>      // End for
>      //
> -    return EFI_SUCCESS;
>    }

>    return EFI_SUCCESS;

Disagree with the fix.

Given the checks on "Operation" at the top of the function, the
condition (near the end of the function)

  if (Operation == EfiPciHotplugRequestRemove) {

will always evaluate to TRUE. (Operation can be only Add or Remove, and
if it is Add, then we don't reach this location.)

Therefore, we should remove this condition, and *unnest* the dependent
logic.

As a result of *that*, you'll have

  return EFI_SUCCESS;
  return EFI_SUCCESS;

at the end of the function, and *then* you should remove either one of them.

Thanks
Laszlo

_._,_._,_

Groups.io Links:

You receive all messages sent to this group.

View/Reply Online (#111018) | | Mute This Topic | New Topic
Your Subscription | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_