summaryrefslogtreecommitdiff
path: root/MdePkg/Library/BaseLib/HighBitSet32.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdePkg/Library/BaseLib/HighBitSet32.c')
-rw-r--r--MdePkg/Library/BaseLib/HighBitSet32.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/MdePkg/Library/BaseLib/HighBitSet32.c b/MdePkg/Library/BaseLib/HighBitSet32.c
index 65f067ac1a..5ab4d7fe8d 100644
--- a/MdePkg/Library/BaseLib/HighBitSet32.c
+++ b/MdePkg/Library/BaseLib/HighBitSet32.c
@@ -36,6 +36,9 @@ HighBitSet32 (
{
INTN BitIndex;
- for (BitIndex = -1; Operand != 0; BitIndex++, Operand >>= 1);
+ if (Operand == 0) {
+ return - 1;
+ }
+ for (BitIndex = 31; (INT32)Operand > 0; BitIndex--, Operand <<= 1);
return BitIndex;
}