diff --git a/MdePkg/Library/BaseLib/GetPowerOfTwo32.c b/MdePkg/Library/BaseLib/GetPowerOfTwo32.c index 6dfe8056b4..dbf4ca6513 100644 --- a/MdePkg/Library/BaseLib/GetPowerOfTwo32.c +++ b/MdePkg/Library/BaseLib/GetPowerOfTwo32.c @@ -34,6 +34,7 @@ GetPowerOfTwo32 ( ) { INTN BitPos; - - return (BitPos = HighBitSet32 (Operand)) > 0 ? 1ul << BitPos : 0; + + BitPos = HighBitSet32 (Operand); + return BitPos >= 0 ? 1ul << BitPos : 0; } diff --git a/MdePkg/Library/BaseLib/GetPowerOfTwo64.c b/MdePkg/Library/BaseLib/GetPowerOfTwo64.c index 9994fb8f12..8372a7f136 100644 --- a/MdePkg/Library/BaseLib/GetPowerOfTwo64.c +++ b/MdePkg/Library/BaseLib/GetPowerOfTwo64.c @@ -35,5 +35,6 @@ GetPowerOfTwo64 ( { INTN BitPos; - return (BitPos = HighBitSet64 (Operand)) > 0 ? LShiftU64 (1, BitPos) : 0; + BitPos = HighBitSet64 (Operand); + return BitPos >= 0 ? LShiftU64 (1, BitPos) : 0; }