On Mon, Jul 9, 2012 at 7:43 AM, Markus Armbruster <arm...@redhat.com> wrote: > blauwir...@gmail.com writes: > >> From: Blue Swirl <blauwir...@gmail.com> >> >> Use 'bool' type for return value of bit test functions. > > Matter of taste. 'bool' makes sense if you think of these functions as > predicates (ugly ones, with side effects). 'int' makes sense if you > think of them as returning the bit value (a bit is not a truth value in > my book).
The documentation actually talks about returning the old value. But I think the kernel version (with the same documentation) however returns a truth value: static inline int test_and_clear_bit(int nr, volatile unsigned long *addr) { int oldbit; asm volatile(LOCK_PREFIX "btr %2,%1\n\t" "sbb %0,%0" : "=r" (oldbit), ADDR : "Ir" (nr) : "memory"); return oldbit; } SBB oldbit, oldbit with oldbit = 0 initially and carry set will produce -1, no? > > In my opinion, this is just unnecessary churn, and unnecessary deviation > from established kernel practice. We use for example NetBSD queue macros with heavy modification. If we have a need to modify code derived from Linux kernel, we should do it as well. In this case the kernel practice seems to be inconsistent and worth fixing.