summaryrefslogtreecommitdiff
path: root/MdePkg/Library/BaseLib/GetPowerOfTwo64.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdePkg/Library/BaseLib/GetPowerOfTwo64.c')
-rw-r--r--MdePkg/Library/BaseLib/GetPowerOfTwo64.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/MdePkg/Library/BaseLib/GetPowerOfTwo64.c b/MdePkg/Library/BaseLib/GetPowerOfTwo64.c
index 8372a7f136..52d148c924 100644
--- a/MdePkg/Library/BaseLib/GetPowerOfTwo64.c
+++ b/MdePkg/Library/BaseLib/GetPowerOfTwo64.c
@@ -33,8 +33,9 @@ GetPowerOfTwo64 (
IN UINT64 Operand
)
{
- INTN BitPos;
+ if (Operand == 0) {
+ return 0;
+ }
- BitPos = HighBitSet64 (Operand);
- return BitPos >= 0 ? LShiftU64 (1, BitPos) : 0;
+ return LShiftU64 (1, HighBitSet64 (Operand));
}