Skip to content

Commit

Permalink
x86: fix new find_first_bit()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Linus Torvalds committed Jul 29, 2005
1 parent 33ac02a commit d6d2a2a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions include/asm-i386/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit d6d2a2a

Please sign in to comment.