Skip to content

Commit

Permalink
UefiCpuPkg/MtrrLib: use new IS_POW2() macro.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Ray Ni <[email protected]>
  • Loading branch information
kraxel authored and mdkinney committed Nov 7, 2023
1 parent 031af64 commit 789da72
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions UefiCpuPkg/Library/MtrrLib/MtrrLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1273,21 +1273,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.
Expand Down Expand Up @@ -1658,7 +1643,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,
Expand Down

0 comments on commit 789da72

Please sign in to comment.