From nobody Mon Feb 9 02:28:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+110815+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+110815+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1699338020; cv=none; d=zohomail.com; s=zohoarc; b=JnjEj4xSKfquCD1LHwYK/HcwJDkdKYooHeBA6f+61gu/m5keQhFYUB1AioZ4pArLtX9mB2gbGjpwDuwHLp7ydf1bFh7VqO3iv55u4FiE/234LMO0D2mYH5gxU556RmHVuHOgi9toSI6BI9QdD7x82rqmsuNKGoRtVm9rBQ44x4c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699338020; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=/e1xIKF4M0vJtvSiQ4E7LvUWLgUQxYM/RYaKz1OuHtM=; b=RMIAdEOQIowQ/BQJuAu6BiNjWfB8W64toKT0Pt1uipeCUDRxgAhrCqXc/g6QfoRle5s0N4mx408H/f3MQEECEBebihk/HjS9BvFWiVBWKWNMEXl32eg5aaFz6cNaKgA37/QewDqjrqair4w9FRb8zenb8nKsgiFsq4lHjsVhuyY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+110815+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1699338020112206.78180422100195; Mon, 6 Nov 2023 22:20:20 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=Xed270C8F0XO0Xq4N6XYJPo3ivaNv56/0tgrPIXdkKc=; 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=CQ/KNhICe2Lsim7dFE9ugff+tyh+C8edb3latvunV+na+fEO/NGC3jT2GnIFevn5588mXkld Dl/gKjuDV3fwaPRc1qej+GCs90WC4c8gYhyE5EjmWa5M0S+LAjQEj4V8L0UkYYbrQavhRFnsyqv m9mxHiRBB7m5Ux3P4ZTtJ4Jc= X-Received: by 127.0.0.2 with SMTP id vG7FYY1788612xus8FzbgcFK; 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: 5mVQiFnLXJr2th8xviIB2RbRx1787277AA= 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-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1699338025811100001 Content-Type: text/plain; charset="utf-8" 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 ); if (!EFI_ERROR (Status)) { - Status =3D gBS->UninstallMultipleProtocolInterfaces ( - Handle, - &gEfiLoadFile2ProtocolGuid, - &PciIoDevice->LoadFile2, - NULL - ); + gBS->UninstallMultipleProtocolInterfaces ( + Handle, + &gEfiLoadFile2ProtocolGuid, + &PciIoDevice->LoadFile2, + NULL + ); } =20 // @@ -678,19 +678,21 @@ StartPciDevicesOnBridge ( ChildHandleBuffer ); =20 - PciIoDevice->PciIo.Attributes ( - &(PciIoDevice->PciIo), - EfiPciIoAttributeOperationSupported, - 0, - &Supports - ); - Supports &=3D (UINT64)EFI_PCI_DEVICE_ENABLE; - PciIoDevice->PciIo.Attributes ( - &(PciIoDevice->PciIo), - EfiPciIoAttributeOperationEnable, - Supports, - NULL - ); + if (!EFI_ERROR (Status)) { + PciIoDevice->PciIo.Attributes ( + &(PciIoDevice->PciIo), + EfiPciIoAttributeOperationSupported, + 0, + &Supports + ); + Supports &=3D (UINT64)EFI_PCI_DEVICE_ENABLE; + PciIoDevice->PciIo.Attributes ( + &(PciIoDevice->PciIo), + EfiPciIoAttributeOperationEnable, + Supports, + NULL + ); + } =20 return Status; } else { @@ -726,19 +728,21 @@ StartPciDevicesOnBridge ( ChildHandleBuffer ); =20 - PciIoDevice->PciIo.Attributes ( - &(PciIoDevice->PciIo), - EfiPciIoAttributeOperationSupported, - 0, - &Supports - ); - Supports &=3D (UINT64)EFI_PCI_DEVICE_ENABLE; - PciIoDevice->PciIo.Attributes ( - &(PciIoDevice->PciIo), - EfiPciIoAttributeOperationEnable, - Supports, - NULL - ); + if (!EFI_ERROR (Status)) { + PciIoDevice->PciIo.Attributes ( + &(PciIoDevice->PciIo), + EfiPciIoAttributeOperationSupported, + 0, + &Supports + ); + Supports &=3D (UINT64)EFI_PCI_DEVICE_ENABLE; + PciIoDevice->PciIo.Attributes ( + &(PciIoDevice->PciIo), + EfiPciIoAttributeOperationEnable, + Supports, + NULL + ); + } } =20 CurrentLink =3D CurrentLink->ForwardLink; 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 // Status =3D BarExisted (PciIoDevice, BarOffset, &TestValue, &OldV= alue); + if (EFI_ERROR (Status)) { + // + // Not sure if it is correct to skip the below if (TestValue = =3D=3D OldValue) check in this special scenario. + // If correct, then remove these 11 comment lines eventually. + // If not correct, then replace "continue;" with blank "; // N= othing to do" and also remove these 11 comment lines eventually + // OR + // Remove the newly added if (EFI_ERROR (Status)) { ... } bl= ock completely and change + // Status =3D BarExisted (PciIoDevice, BarOffset, &TestValue= , &OldValue); + // =3D> + // BarExisted (PciIoDevice, BarOffset, &TestValue, &OldValue= ); + // i.e., no return value storage in Status + // + continue; + } if (TestValue =3D=3D OldValue) { return TRUE; } @@ -2861,13 +2875,13 @@ ResetAllPpbBusNumber ( if (!EFI_ERROR (Status) && (IS_PCI_BRIDGE (&Pci))) { Register =3D 0; Address =3D EFI_PCI_ADDRESS (StartBusNumber, Device, Func, 0x18); - Status =3D PciRootBridgeIo->Pci.Read ( - PciRootBridgeIo, - EfiPciWidthUint32, - Address, - 1, - &Register - ); + PciRootBridgeIo->Pci.Read ( + PciRootBridgeIo, + EfiPciWidthUint32, + Address, + 1, + &Register + ); SecondaryBus =3D (UINT8)(Register >> 8); =20 if (SecondaryBus !=3D 0) { @@ -2878,13 +2892,13 @@ ResetAllPpbBusNumber ( // Reset register 18h, 19h, 1Ah on PCI Bridge // Register &=3D 0xFF000000; - Status =3D PciRootBridgeIo->Pci.Write ( - PciRootBridgeIo, - EfiPciWidthUint32, - Address, - 1, - &Register - ); + PciRootBridgeIo->Pci.Write ( + PciRootBridgeIo, + EfiPciWidthUint32, + Address, + 1, + &Register + ); } =20 if ((Func =3D=3D 0) && !IS_PCI_MULTI_FUNC (&Pci)) { 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 ); =20 + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "Failed to initialize Hotplug PCI Cont= roller, Status %r\n", Status)); + } + PreprocessController ( PciDevice, PciDevice->BusNumber, @@ -1501,6 +1505,10 @@ PciRootBridgeP2CProcess ( =20 if (!IsListEmpty (&Temp->ChildList)) { Status =3D PciRootBridgeP2CProcess (Temp); + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "Failed to process Option Rom on PCI root brid= ge %p, Status %r\n", Temp, Status)); + } } =20 CurrentLink =3D CurrentLink->ForwardLink; --=20 2.34.1 -=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 (#110815): https://edk2.groups.io/g/devel/message/110815 Mute This Topic: https://groups.io/mt/102438321/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-