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 8B83D7803CF for ; Tue, 26 Sep 2023 06:40:13 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=UbW0Sr3blbMFViQQKawSZtFJOTz6ssXKpZZrmssMgrc=; 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=B+WiTgxV14t4TRWfpKTXr607T6CdNRl8wbxQuYkvG5ceNOYz0euyv3rJUwfDz/7agDnO4S1w L8dvlL8MielIzhb7P9K4Z37Oe6jP5RvBGA7QKTkfb1fghjUj4+Xv+Rv66n27oHfn/b6MeKtnDZa YNwZ/Gx8V0C3oM1NlKEAuPi8= X-Received: by 127.0.0.2 with SMTP id B42SYY7687511xAIllwi8v1g; 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: rrpACyQ06N9IGNp01N0pUsJFx7686176AA= 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-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=B+WiTgxV; 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 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 ( }=0D }=0D =0D - if (AvailablePages !=3D 0) {=0D - DEBUG ((DEBUG_INFO, "Promoted pages: %lX (%lx)\r\n", Start, (UINT64)Av= ailablePages));=0D - ClearGuardedMemoryBits (Start, AvailablePages);=0D + DEBUG ((DEBUG_INFO, "Promoted pages: %lX (%lx)\r\n", Start, (UINT64)Avai= lablePages));=0D + ClearGuardedMemoryBits (Start, AvailablePages);=0D =0D - if (gCpu !=3D NULL) {=0D - //=0D - // Set flag to make sure allocating memory without GUARD for page ta= ble=0D - // operation; otherwise infinite loops could be caused.=0D - //=0D - mOnGuarding =3D TRUE;=0D - Status =3D gCpu->SetMemoryAttributes (gCpu, Start, EFI_PAGES_TO= _SIZE (AvailablePages), 0);=0D - ASSERT_EFI_ERROR (Status);=0D - mOnGuarding =3D FALSE;=0D - }=0D -=0D - mLastPromotedPage =3D Start;=0D - *StartAddress =3D Start;=0D - *EndAddress =3D Start + EFI_PAGES_TO_SIZE (AvailablePages) - 1;= =0D - return TRUE;=0D + if (gCpu !=3D NULL) {=0D + //=0D + // Set flag to make sure allocating memory without GUARD for page tabl= e=0D + // operation; otherwise infinite loops could be caused.=0D + //=0D + mOnGuarding =3D TRUE;=0D + Status =3D gCpu->SetMemoryAttributes (gCpu, Start, EFI_PAGES_TO_S= IZE (AvailablePages), 0);=0D + ASSERT_EFI_ERROR (Status);=0D + mOnGuarding =3D FALSE;=0D }=0D =0D - return FALSE;=0D + mLastPromotedPage =3D Start;=0D + *StartAddress =3D Start;=0D + *EndAddress =3D Start + EFI_PAGES_TO_SIZE (AvailablePages) - 1;=0D +=0D + return TRUE;=0D }=0D =0D /**=0D --=20 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- 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/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-