From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web11.36765.1679468582485583700 for ; Wed, 22 Mar 2023 00:03:02 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cvW2eYDy; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679468581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vodCwO9ThNjMB2+gQ9mQVTQ0ziXZ1uFHiFJaipUGr48=; b=cvW2eYDyuNoIzayZ8wFVnU5SMa1lNFmQm4uwhqS40DawJL7IrfgYOznh3urbrGhgaIkIgt sxP5PVQV0w+a+bQszsQADU7vYh2Nx7KIquLy7lOXw/UT5pp5/+lbtlrGzeVnA+Cn25Lrh/ QHjIBHUX8+k1Sp0sqmWwwpnN7pdF5jc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-228-1P-kopCLOsiLPLMK2I383A-1; Wed, 22 Mar 2023 03:03:00 -0400 X-MC-Unique: 1P-kopCLOsiLPLMK2I383A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6A54C185A78F; Wed, 22 Mar 2023 07:02:59 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.53]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 33B3C40C6E67; Wed, 22 Mar 2023 07:02:59 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D4D8318003B8; Wed, 22 Mar 2023 08:02:43 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Michael D Kinney , Erdem Aktas , James Bottomley , Liming Gao , =?UTF-8?q?Marvin=20H=C3=A4user?= , Pawel Polawski , Michael Roth , Tom Lendacky , Gerd Hoffmann , Jiewen Yao , Jian J Wang , Ard Biesheuvel , Jordan Justen , Hao A Wu , Zhiguang Liu , Ray Ni , Min Xu , Oliver Steffen Subject: [PATCH v2 6/6] UefiCpuPkg/MtrrLib: use new IS_POW2() macro. Date: Wed, 22 Mar 2023 08:02:43 +0100 Message-Id: <20230322070243.410903-7-kraxel@redhat.com> In-Reply-To: <20230322070243.410903-1-kraxel@redhat.com> References: <20230322070243.410903-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Drop MtrrLibIsPowerOfTwo function, use the new IS_POW2() macro instead. The ASSERT() removed (inside MtrrLibIsPowerOfTwo) is superfluous, another ASSERT() a few lines up in MtrrLibCalculateMtrrs() already guarantees that Length can not be zero at this point. Signed-off-by: Gerd Hoffmann --- UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c index e5c862c83d61..dd0b668d7782 100644 --- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c +++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c @@ -1253,21 +1253,6 @@ MtrrLibLowestType ( return (MTRR_MEMORY_CACHE_TYPE)Type; } -/** - Return TRUE when the Operand is exactly power of 2. - - @retval TRUE Operand is exactly power of 2. - @retval FALSE Operand is not power of 2. -**/ -BOOLEAN -MtrrLibIsPowerOfTwo ( - IN UINT64 Operand - ) -{ - ASSERT (Operand != 0); - return (BOOLEAN)((Operand & (Operand - 1)) == 0); -} - /** Calculate the subtractive path from vertex Start to Stop. @@ -1638,7 +1623,7 @@ MtrrLibCalculateMtrrs ( break; } - if ((Weight[M (Start, Stop)] == MAX_WEIGHT) && MtrrLibIsPowerOfTwo (Length)) { + if ((Weight[M (Start, Stop)] == MAX_WEIGHT) && IS_POW2 (Length)) { if (MtrrLibGetNumberOfTypes ( Ranges, RangeCount, -- 2.39.2