From nobody Sun Feb 8 11:17:07 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+109112+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+109112+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1695795440; cv=none; d=zohomail.com; s=zohoarc; b=SyGJHjXAndmMWsqlp9shQoAo6EmCygk4p4Hxxoa6xMlJyXrrixBbgvkwSv/T1vFN8ph17p3Pg44HIQJfJ2s7fAEAojH7TGag5Tw7Iu/TwgpGmJi0ApNgiGKKwpMRzDAsQFrNOYHHcoOpqdP0MwkJNkDIsE6ttwzEDze1aS6SJNc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695795440; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=ssAYmwDcahyll1OB33NpmJ7UoYLGXHvHZtyc2UFY0do=; b=X8gh361uqJNL1cZVS+AwsCzP9Bf0tx+fGAak0/w/JiOolTOcgn5xitA9J9a1+9TPxJq4DDTjcljcxlpxhYo3ajiH6UGW+lr1yqRm2rw1K7kigY64tYCkE+5aICN0vGfrdFeiu/lJ8n3KKOllxHWW/YxGYtMCN1zmgkx60kV3/yQ= 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+109112+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1695795440699482.99781048432305; Tue, 26 Sep 2023 23:17:20 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=+O/CjwrFWPpIH3/G1dzWIgpQ9XzT1PBu4uf0UkVt5rg=; 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=b8GKmtmSBlycTyw4thSGkkvJ/ZgMGbkRNHnfxlr0LHUaT4748jtGj3n1hUYN3ysQBRmbXHOy m+7sdhg82HoUQ03sP72lPOxcrpnL/hUzwEA5fDLaxbOdWOXVPX/fdDJxhRm61vfxa7bB9BeBqU3 JRvaJWUadu1BmOvJxWM8sqEI= X-Received: by 127.0.0.2 with SMTP id F32SYY1788612x6PuANjYe6H; 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: MSpJofD8c5h9v7Rm46OXRspMx1787277AA= 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-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1695795441020100010 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: 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 ); 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 (#109112): https://edk2.groups.io/g/devel/message/109112 Mute This Topic: https://groups.io/mt/101612811/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-