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 9D00F94102E for ; Wed, 27 Sep 2023 06:17:21 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=ry2vmgTGNMPE80YZplZfUXz+vjF+kquWah6T8nOrweA=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1695795440; v=1; b=srUq4PKfLO83mIVHXOXU1V1znccRZu2anzRvn6IWZzCJMzZXntd8ed1In2qJWMg6q5RHOOX1 t+Sm/XxC3B3v6YJxRPNUwYfkaLbPYeWd/acMwQFiUoZiAktNXi1rEu2wIyn8akfSsgu5ccRO9Is n2e5pUmLcesF3+EGwuB8IP64= X-Received: by 127.0.0.2 with SMTP id 7zDGYY7687511xMeqvBqKGny; Tue, 26 Sep 2023 23:17:20 -0700 X-Received: from mail-io1-f49.google.com (mail-io1-f49.google.com [209.85.166.49]) by mx.groups.io with SMTP id smtpd.web10.11693.1695795439658881517 for ; Tue, 26 Sep 2023 23:17:19 -0700 X-Received: by mail-io1-f49.google.com with SMTP id ca18e2360f4ac-7a25040faffso6729139f.1 for ; Tue, 26 Sep 2023 23:17:19 -0700 (PDT) X-Gm-Message-State: KL1MSLZrnyXofL1nO4ezczoRx7686176AA= X-Google-Smtp-Source: AGHT+IGQIEUT7bEG2YXrqMj6ryinfWIQu06ZIMk/4lo5+0eI/QxCnmhhsyNLqjfqExWck34og9ZBrA== X-Received: by 2002:a6b:e510:0:b0:794:eaef:f43e with SMTP id y16-20020a6be510000000b00794eaeff43emr1318610ioc.1.1695795438786; Tue, 26 Sep 2023 23:17:18 -0700 (PDT) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([106.51.83.242]) by smtp.gmail.com with ESMTPSA id o23-20020a6b5a17000000b007836c7e8dccsm2571625iob.17.2023.09.26.23.17.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 23:17:18 -0700 (PDT) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Hao A Wu , Ray Ni Subject: [edk2-devel] [PATCH v1 5/5] MdeModulePkg/Bus/Pci/PciBusDxe: Fix UNUSED_VALUE Coverity issues Date: Wed, 27 Sep 2023 11:47:01 +0530 Message-Id: <20230927061701.451202-6-rsingh@ventanamicro.com> In-Reply-To: <20230927061701.451202-1-rsingh@ventanamicro.com> References: <20230927061701.451202-1-rsingh@ventanamicro.com> MIME-Version: 1.0 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,rsingh@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: 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=srUq4PKf; dmarc=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 The return value after calls to functions gBS->UninstallMultipleProtocolInterfaces, StartPciDevicesOnBridge, PciPciDeviceInfoCollector, BarExisted, PciRootBridgeIo->Pci.Write, gPciHotPlugInit->InitializeRootHpc and PciRootBridgeP2CProcess is stored in Status, but it is not made of any use and later Status gets overridden. Remove the return value storage in Status or add Status check as seems appropriate at a particular point. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4239 Cc: Hao A Wu Cc: Ray Ni Signed-off-by: Ranbir Singh --- MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c | 68 +++++++++++----= ----- MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c | 42 ++++++++---- MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c | 8 +++ 3 files changed, 72 insertions(+), 46 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c b/MdeModuleP= kg/Bus/Pci/PciBusDxe/PciDeviceSupport.c index f43f10325f16..ae770d766381 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c @@ -544,12 +544,12 @@ DeRegisterPciDevice ( EFI_OPEN_PROTOCOL_TEST_PROTOCOL=0D );=0D if (!EFI_ERROR (Status)) {=0D - Status =3D gBS->UninstallMultipleProtocolInterfaces (=0D - Handle,=0D - &gEfiLoadFile2ProtocolGuid,=0D - &PciIoDevice->LoadFile2,=0D - NULL=0D - );=0D + gBS->UninstallMultipleProtocolInterfaces (=0D + Handle,=0D + &gEfiLoadFile2ProtocolGuid,=0D + &PciIoDevice->LoadFile2,=0D + NULL=0D + );=0D }=0D =0D //=0D @@ -678,19 +678,21 @@ StartPciDevicesOnBridge ( ChildHandleBuffer=0D );=0D =0D - PciIoDevice->PciIo.Attributes (=0D - &(PciIoDevice->PciIo),=0D - EfiPciIoAttributeOperationSupported,=0D - 0,=0D - &Supports=0D - );=0D - Supports &=3D (UINT64)EFI_PCI_DEVICE_ENABLE;=0D - PciIoDevice->PciIo.Attributes (=0D - &(PciIoDevice->PciIo),=0D - EfiPciIoAttributeOperationEnable,=0D - Supports,=0D - NULL=0D - );=0D + if (!EFI_ERROR (Status)) {=0D + PciIoDevice->PciIo.Attributes (=0D + &(PciIoDevice->PciIo),=0D + EfiPciIoAttributeOperationSupported,=0D + 0,=0D + &Supports=0D + );=0D + Supports &=3D (UINT64)EFI_PCI_DEVICE_ENABLE;=0D + PciIoDevice->PciIo.Attributes (=0D + &(PciIoDevice->PciIo),=0D + EfiPciIoAttributeOperationEnable,=0D + Supports,=0D + NULL=0D + );=0D + }=0D =0D return Status;=0D } else {=0D @@ -726,19 +728,21 @@ StartPciDevicesOnBridge ( ChildHandleBuffer=0D );=0D =0D - PciIoDevice->PciIo.Attributes (=0D - &(PciIoDevice->PciIo),=0D - EfiPciIoAttributeOperationSupported,=0D - 0,=0D - &Supports=0D - );=0D - Supports &=3D (UINT64)EFI_PCI_DEVICE_ENABLE;=0D - PciIoDevice->PciIo.Attributes (=0D - &(PciIoDevice->PciIo),=0D - EfiPciIoAttributeOperationEnable,=0D - Supports,=0D - NULL=0D - );=0D + if (!EFI_ERROR (Status)) {=0D + PciIoDevice->PciIo.Attributes (=0D + &(PciIoDevice->PciIo),=0D + EfiPciIoAttributeOperationSupported,=0D + 0,=0D + &Supports=0D + );=0D + Supports &=3D (UINT64)EFI_PCI_DEVICE_ENABLE;=0D + PciIoDevice->PciIo.Attributes (=0D + &(PciIoDevice->PciIo),=0D + EfiPciIoAttributeOperationEnable,=0D + Supports,=0D + NULL=0D + );=0D + }=0D }=0D =0D CurrentLink =3D CurrentLink->ForwardLink;=0D diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c b/MdeMod= ulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c index eda97285ee18..636885dd189d 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c @@ -2796,6 +2796,20 @@ IsPciDeviceRejected ( // Test its high 32-Bit BAR=0D //=0D Status =3D BarExisted (PciIoDevice, BarOffset, &TestValue, &OldV= alue);=0D + if (EFI_ERROR (Status)) {=0D + //=0D + // Not sure if it is correct to skip the below if (TestValue = =3D=3D OldValue) check in this special scenario.=0D + // If correct, then remove these 11 comment lines eventually.= =0D + // If not correct, then replace "continue;" with blank "; // N= othing to do" and also remove these 11 comment lines eventually=0D + // OR=0D + // Remove the newly added if (EFI_ERROR (Status)) { ... } bl= ock completely and change=0D + // Status =3D BarExisted (PciIoDevice, BarOffset, &TestValue= , &OldValue);=0D + // =3D>=0D + // BarExisted (PciIoDevice, BarOffset, &TestValue, &OldValue= );=0D + // i.e., no return value storage in Status=0D + //=0D + continue;=0D + }=0D if (TestValue =3D=3D OldValue) {=0D return TRUE;=0D }=0D @@ -2861,13 +2875,13 @@ ResetAllPpbBusNumber ( if (!EFI_ERROR (Status) && (IS_PCI_BRIDGE (&Pci))) {=0D Register =3D 0;=0D Address =3D EFI_PCI_ADDRESS (StartBusNumber, Device, Func, 0x18);= =0D - Status =3D PciRootBridgeIo->Pci.Read (=0D - PciRootBridgeIo,=0D - EfiPciWidthUint32,=0D - Address,=0D - 1,=0D - &Register=0D - );=0D + PciRootBridgeIo->Pci.Read (=0D + PciRootBridgeIo,=0D + EfiPciWidthUint32,=0D + Address,=0D + 1,=0D + &Register=0D + );=0D SecondaryBus =3D (UINT8)(Register >> 8);=0D =0D if (SecondaryBus !=3D 0) {=0D @@ -2878,13 +2892,13 @@ ResetAllPpbBusNumber ( // Reset register 18h, 19h, 1Ah on PCI Bridge=0D //=0D Register &=3D 0xFF000000;=0D - Status =3D PciRootBridgeIo->Pci.Write (=0D - PciRootBridgeIo,=0D - EfiPciWidthUint32,=0D - Address,=0D - 1,=0D - &Register=0D - );=0D + PciRootBridgeIo->Pci.Write (=0D + PciRootBridgeIo,=0D + EfiPciWidthUint32,=0D + Address,=0D + 1,=0D + &Register=0D + );=0D }=0D =0D if ((Func =3D=3D 0) && !IS_PCI_MULTI_FUNC (&Pci)) {=0D diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c b/MdeModulePkg/Bus/Pci= /PciBusDxe/PciLib.c index 71767d3793d4..087fe563c0bc 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c @@ -1250,6 +1250,10 @@ PciScanBus ( &State=0D );=0D =0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_WARN, "Failed to initialize Hotplug PCI Cont= roller, Status %r\n", Status));=0D + }=0D +=0D PreprocessController (=0D PciDevice,=0D PciDevice->BusNumber,=0D @@ -1501,6 +1505,10 @@ PciRootBridgeP2CProcess ( =0D if (!IsListEmpty (&Temp->ChildList)) {=0D Status =3D PciRootBridgeP2CProcess (Temp);=0D +=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_WARN, "Failed to process Option Rom on PCI root brid= ge %p, Status %r\n", Temp, Status));=0D + }=0D }=0D =0D CurrentLink =3D CurrentLink->ForwardLink;=0D --=20 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109112): https://edk2.groups.io/g/devel/message/109112 Mute This Topic: https://groups.io/mt/101612811/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-