From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 57786AC1054 for ; Tue, 7 Nov 2023 16:21:20 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=TTiYtNhhc89Z/ESp4UHx6/2HswssawJIssGoep2J8UU=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1699374079; v=1; b=j7Pd6LQJOAxUfgAdsJlBoZzCdxd78iADuNRafT5j7Dwf44oobn40wt6PrDr6MZYnkMJKxsUJ CCn/pnjQHTxNxqol7kz+23c/7HMcUKT6ZqFF06N52g7f+SVuHYR3nycBn/hlnyoHNuv7dJo/M7h CG3urGFqL1S8re/PItpFVjh8= X-Received: by 127.0.0.2 with SMTP id LAlhYY7687511xN1fzxJOUAh; Tue, 07 Nov 2023 08:21:19 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.15271.1699374078402132202 for ; Tue, 07 Nov 2023 08:21:18 -0800 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-611-qXG6aY2pMSSuS2YoD7Dv4g-1; Tue, 07 Nov 2023 11:21:13 -0500 X-MC-Unique: qXG6aY2pMSSuS2YoD7Dv4g-1 X-Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8B2433C1477B; Tue, 7 Nov 2023 16:21:13 +0000 (UTC) X-Received: from [10.39.193.64] (unknown [10.39.193.64]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D3B14502A; Tue, 7 Nov 2023 16:21:12 +0000 (UTC) Message-ID: <0c88e9d0-ad1d-9b9d-7bbc-90cee40752e3@redhat.com> Date: Tue, 7 Nov 2023 17:21:11 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH v2 1/5] MdeModulePkg/Bus/Pci/PciBusDxe: Fix DEADCODE Coverity issue To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Ray Ni , Veeresh Sangolli References: <20231107061959.113213-1-rsingh@ventanamicro.com> <20231107061959.113213-2-rsingh@ventanamicro.com> From: "Laszlo Ersek" In-Reply-To: <20231107061959.113213-2-rsingh@ventanamicro.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 9FmegNUsm6cxaQzOvXsHOjuJx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=j7Pd6LQJ; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On 11/7/23 07:19, Ranbir Singh wrote: > From: Ranbir Singh >=20 > 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. >=20 > To fix it, either of line 2109 or 2112 can be deleted. >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4239 >=20 > Cc: Ray Ni > Co-authored-by: Veeresh Sangolli > Signed-off-by: Ranbir Singh > Signed-off-by: Ranbir Singh > --- > MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c | 1 - > 1 file changed, 1 deletion(-) >=20 > diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c b/MdeModulePk= g/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; > } > =20 > 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 =3D=3D 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 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110862): https://edk2.groups.io/g/devel/message/110862 Mute This Topic: https://groups.io/mt/102438298/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-