From nobody Mon Feb 9 08:29:10 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+109062+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+109062+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1695710412; cv=none; d=zohomail.com; s=zohoarc; b=dks0Y9nbS1l8ydXSQM4gF0449sQqUi0WDL1mxt5iK0PnvJbTrW92OqVsu7uv3FkGevoVL+JLtxxzUXFFqL5BqGLwcUSU8MQo6br7qIaj9jKk//pz7BTqGEjh9eCCQKJqfQ7Om0C8n6mnBwn3m8LRwHI6JWuuXkvkXE3zHCE7iR4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695710412; 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=XtU9N/IhFM2R3pnred7pmApm87R7fwn2zsi3MVZWHn8=; b=du/Zc2bWgUA+itAxn3WwHtJSvhK8tRokA30SUkUpfCZWJdOQkJ9twcH9x5nBSuEKTbvLg73/KVEst8SGV/hj/sIxbS+REVCpRQgErdIN2LaAN2kPDs+eMz3KUru+LC/+Xj5nL3N8zEWYTRiFZ5ks4tXiNDSYqQ+z0t5/Xp+JgFE= 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+109062+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1695710412581666.19153122624; Mon, 25 Sep 2023 23:40:12 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=X2vHKh011PBMv8L2D+4shUUyabsam49oOLcr2VJCPnk=; 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=1695710412; v=1; b=YVK+SBcDFHYlHzo/W6qxYNzAyEabcXQNDT+vHaZcjYQooQgnndFieZef/KlLKviMglbYP++3 abEZUEfy4JBFKoTYEStapgjfDyU7TZWC0fTNdPQrMYuHx3NYrXl5tWAAVeYw6ce+B9bHIRKjr+S cpiYrwrTSNSWFgAFw3qG7daU= X-Received: by 127.0.0.2 with SMTP id KtteYY1788612xLGzGGRg9cA; Mon, 25 Sep 2023 23:40:12 -0700 X-Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) by mx.groups.io with SMTP id smtpd.web10.13233.1695710411740657607 for ; Mon, 25 Sep 2023 23:40:11 -0700 X-Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-6c4e7951dddso2008334a34.1 for ; Mon, 25 Sep 2023 23:40:11 -0700 (PDT) X-Gm-Message-State: eziy5tDKjEN76OoUJXIgRuFXx1787277AA= X-Google-Smtp-Source: AGHT+IEeGIwiy3LxEIrY+pIoP1YKYqkKWNzYQiTfj/8oXsLyuizqgC0l/baD23fvK+TkBSTZRcErYQ== X-Received: by 2002:a05:6358:e49c:b0:143:9b25:c029 with SMTP id by28-20020a056358e49c00b001439b25c029mr14102153rwb.2.1695710410720; Mon, 25 Sep 2023 23:40:10 -0700 (PDT) X-Received: from user-Latitude-5420.. ([2401:4900:1cbc:99f:aeba:67ec:3f47:cb02]) by smtp.gmail.com with ESMTPSA id q9-20020a639809000000b00573f82bb00esm8875606pgd.2.2023.09.25.23.40.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 23:40:10 -0700 (PDT) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Dandan Bi , Liming Gao , Veeresh Sangolli Subject: [edk2-devel] [PATCH v1 3/5] MdeModulePkg/Core/Dxe: Fix DEADCODE Coverity issue Date: Tue, 26 Sep 2023 12:09:56 +0530 Message-Id: <20230926063958.313858-4-rsingh@ventanamicro.com> In-Reply-To: <20230926063958.313858-1-rsingh@ventanamicro.com> References: <20230926063958.313858-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: 1695710413473100013 Content-Type: text/plain; charset="utf-8" From: Ranbir Singh In the function PromoteGuardedFreePages(), the value of AvailablePages cannot be ZERO at the condition check point if (AvailablePages !=3D 0) { as the code can come out of the while loop above only when AvailablePages is non-ZERO. Hence, remove the redundant condition check and the return FALSE; DEADCODE statement at the end of the function. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4219 Cc: Dandan Bi Cc: Liming Gao Co-authored-by: Veeresh Sangolli Signed-off-by: Ranbir Singh Signed-off-by: Ranbir Singh --- MdeModulePkg/Core/Dxe/Mem/HeapGuard.c | 35 +++++++++----------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c b/MdeModulePkg/Core/Dxe/= Mem/HeapGuard.c index 0c0ca61872b4..016791ee002b 100644 --- a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c +++ b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c @@ -1568,28 +1568,25 @@ PromoteGuardedFreePages ( } } =20 - if (AvailablePages !=3D 0) { - DEBUG ((DEBUG_INFO, "Promoted pages: %lX (%lx)\r\n", Start, (UINT64)Av= ailablePages)); - ClearGuardedMemoryBits (Start, AvailablePages); + DEBUG ((DEBUG_INFO, "Promoted pages: %lX (%lx)\r\n", Start, (UINT64)Avai= lablePages)); + ClearGuardedMemoryBits (Start, AvailablePages); =20 - if (gCpu !=3D NULL) { - // - // Set flag to make sure allocating memory without GUARD for page ta= ble - // operation; otherwise infinite loops could be caused. - // - mOnGuarding =3D TRUE; - Status =3D gCpu->SetMemoryAttributes (gCpu, Start, EFI_PAGES_TO= _SIZE (AvailablePages), 0); - ASSERT_EFI_ERROR (Status); - mOnGuarding =3D FALSE; - } - - mLastPromotedPage =3D Start; - *StartAddress =3D Start; - *EndAddress =3D Start + EFI_PAGES_TO_SIZE (AvailablePages) - 1; - return TRUE; + if (gCpu !=3D NULL) { + // + // Set flag to make sure allocating memory without GUARD for page table + // operation; otherwise infinite loops could be caused. + // + mOnGuarding =3D TRUE; + Status =3D gCpu->SetMemoryAttributes (gCpu, Start, EFI_PAGES_TO_S= IZE (AvailablePages), 0); + ASSERT_EFI_ERROR (Status); + mOnGuarding =3D FALSE; } =20 - return FALSE; + mLastPromotedPage =3D Start; + *StartAddress =3D Start; + *EndAddress =3D Start + EFI_PAGES_TO_SIZE (AvailablePages) - 1; + + return TRUE; } =20 /** --=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 (#109062): https://edk2.groups.io/g/devel/message/109062 Mute This Topic: https://groups.io/mt/101590756/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-