]> err.no Git - linux-2.6/commitdiff
x86: fix new find_first_bit()
authorLinus Torvalds <torvalds@evo.osdl.org>
Fri, 29 Jul 2005 15:01:22 +0000 (11:01 -0400)
committerLinus Torvalds <torvalds@evo.osdl.org>
Fri, 29 Jul 2005 15:01:22 +0000 (11:01 -0400)
Some edge problems with the original C rewrite.

Thanks go to Cal Peake, who pinpointed the breakage to the rewrite, and
tested this fixed version.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
include/asm-i386/bitops.h

index 1caee1039363e7eb848ea9e2bb34ec4b7a985860..ddf1739dc7fd1968954ff0eed7d9053346f1360f 100644 (file)
@@ -335,14 +335,13 @@ static inline unsigned long __ffs(unsigned long word)
 static inline int find_first_bit(const unsigned long *addr, unsigned size)
 {
        int x = 0;
-       do {
-               if (*addr)
-                       return __ffs(*addr) + x;
-               addr++;
-               if (x >= size)
-                       break;
+
+       while (x < size) {
+               unsigned long val = *addr++;
+               if (val)
+                       return __ffs(val) + x;
                x += (sizeof(*addr)<<3);
-       } while (1);
+       }
        return x;
 }