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 0730D7803D9 for ; Wed, 27 Sep 2023 06:06:16 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=QEfrvld2HvTGU+o4j1mPwlp1blTNODPMmOomvGIjeFs=; 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=1695794775; v=1; b=osZcg9+duVLJIAah7E3Xk0glylMjQF836wB+UYOHexQbgN1Ax8FoUMIhoyx8nggFuLHQR9sT 2LulfGVJDb6N+SCo903ZKaTEEYzg+OItTFRF/keaW0Zc0Oki1m3zl/YBFDBImlEo72rJkUuqWEo 2hsorhhiibwIF7i3bsf9DmQg= X-Received: by 127.0.0.2 with SMTP id Wl6aYY7687511xp3qR6544a7; Tue, 26 Sep 2023 23:06:15 -0700 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.web11.11802.1695794774952190888 for ; Tue, 26 Sep 2023 23:06:15 -0700 X-Received: by mail-io1-f47.google.com with SMTP id ca18e2360f4ac-79faf4210b2so260241939f.2 for ; Tue, 26 Sep 2023 23:06:14 -0700 (PDT) X-Gm-Message-State: EF32N1OqX4px2fxrSmTHHr8Jx7686176AA= X-Google-Smtp-Source: AGHT+IEJlGPl7j1VNoGhI1HSPR0OE99SnuJFya0R53u5LNqGWFD37soMRH534dG0xh12OMqb/9GLQQ== X-Received: by 2002:a92:c5cd:0:b0:349:77c7:2ab6 with SMTP id s13-20020a92c5cd000000b0034977c72ab6mr1148907ilt.2.1695794774121; Tue, 26 Sep 2023 23:06:14 -0700 (PDT) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([106.51.83.242]) by smtp.gmail.com with ESMTPSA id gj8-20020a0566386a0800b0042b39b2289asm3856707jab.102.2023.09.26.23.06.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 23:06:13 -0700 (PDT) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Dandan Bi , Liming Gao , Veeresh Sangolli Subject: [edk2-devel] [PATCH v2 3/5] MdeModulePkg/Core/Dxe: Fix DEADCODE Coverity issue Date: Wed, 27 Sep 2023 11:35:59 +0530 Message-Id: <20230927060601.443693-4-rsingh@ventanamicro.com> In-Reply-To: <20230927060601.443693-1-rsingh@ventanamicro.com> References: <20230927060601.443693-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=osZcg9+d; 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 (#109104): https://edk2.groups.io/g/devel/message/109104 Mute This Topic: https://groups.io/mt/101612679/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-