http://git.etherboot.org
/
people
/
sha0
/
gpxe.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
Don't get stuck in an infinite loop on negative integers!
[people/sha0/gpxe.git]
/
src
/
core
/
bitops.c
diff --git
a/src/core/bitops.c
b/src/core/bitops.c
index
75d57bf
..
53abaae
100644
(file)
--- a/
src/core/bitops.c
+++ b/
src/core/bitops.c
@@
-1,10
+1,11
@@
#include <strings.h>
int __flsl ( long x ) {
- int r = 0;
+ unsigned long value = x;
+ int ls = 0;
- for (
r = 0 ; x ; r
++ ) {
-
x
>>= 1;
+ for (
ls = 0 ; value ; ls
++ ) {
+
value
>>= 1;
}
- return
r
;
+ return
ls
;
}