]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] Fix cpumask iterator over empty cpu set
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 27 Apr 2004 11:30:50 +0000 (04:30 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Tue, 27 Apr 2004 11:30:50 +0000 (04:30 -0700)
Can't use _ffs() without first checking for zero, and if bits beyond
NR_CPUS set it'll give bogus results.  Use find_first_bit

include/asm-generic/cpumask_arith.h

index 7325284843dd5a8e806dd55142b80aac2bf656b6..b4d25ac46a9fa9567062b25a59a02315a7f6b82a 100644 (file)
@@ -43,7 +43,7 @@
 #define cpus_promote(map)              ({ map; })
 #define cpumask_of_cpu(cpu)            ({ ((cpumask_t)1) << (cpu); })
 
-#define first_cpu(map)                 __ffs(map)
+#define first_cpu(map)                 find_first_bit(&(map), NR_CPUS)
 #define next_cpu(cpu, map)             find_next_bit(&(map), NR_CPUS, cpu + 1)
 
 #endif /* __ASM_GENERIC_CPUMASK_ARITH_H */