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 13965D80D0C for ; Tue, 7 Nov 2023 06:20:20 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=1Stmc/P7pPXMKIrbDcTRiVLSzTChr2QmrMyqB/3Lbao=; 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=1699338019; v=1; b=Csjro91bKPtlyVl7CuC1lhzIWvnWV0TbJA5jqqjmoW6jrfQ7XPSKT20BLs/zDladztOEADKX kOlIU7JocrhHs1yg0uDkOfxaurQ8/Z7/XVHIZ8RIgncRhPuiZzapSxnx/TIo7M/riQTQPV/D3G+ BuW+LoDMzuWWdGFjsY97wr9M= X-Received: by 127.0.0.2 with SMTP id OOKmYY7687511xsLRa8cGQo1; Mon, 06 Nov 2023 22:20:19 -0800 X-Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) by mx.groups.io with SMTP id smtpd.web10.5039.1699338019153872234 for ; Mon, 06 Nov 2023 22:20:19 -0800 X-Received: by mail-io1-f47.google.com with SMTP id ca18e2360f4ac-7ad1236c419so164293039f.0 for ; Mon, 06 Nov 2023 22:20:19 -0800 (PST) X-Gm-Message-State: khJcIHvQ8Hnsdtwd5wfi2cw8x7686176AA= X-Google-Smtp-Source: AGHT+IFoqNOlM1NEuJyw0ERGUB55QTaUd6a0okbZ1GaJTZAZUHAtlWTVnWo5EXOf+xWIrxMeDTBT3g== X-Received: by 2002:a05:6602:2a44:b0:792:989b:c621 with SMTP id k4-20020a0566022a4400b00792989bc621mr40901804iov.1.1699338018160; Mon, 06 Nov 2023 22:20:18 -0800 (PST) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([2401:4900:1f24:775d:7335:84a5:7d11:9393]) by smtp.gmail.com with ESMTPSA id cb11-20020a0566381b0b00b00463ff175405sm1875508jab.80.2023.11.06.22.20.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 22:20:17 -0800 (PST) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Ray Ni Subject: [edk2-devel] [PATCH v2 5/5] MdeModulePkg/Bus/Pci/PciBusDxe: Fix UNUSED_VALUE Coverity issues Date: Tue, 7 Nov 2023 11:49:59 +0530 Message-Id: <20231107061959.113213-6-rsingh@ventanamicro.com> In-Reply-To: <20231107061959.113213-1-rsingh@ventanamicro.com> References: <20231107061959.113213-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=Csjro91b; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=none 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: 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 3de80d98370e..9b0587c94d05 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 (#110815): https://edk2.groups.io/g/devel/message/110815 Mute This Topic: https://groups.io/mt/102438321/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-