Re: [PATCH] bitmap: Cleanup find_last_bit
From: Rusty Russell
Date: Mon Feb 16 2009 - 18:11:19 EST
On Monday 16 February 2009 23:28:40 Benny Halevy wrote:
> Fix cut & paste error in header comment.
> Simplify implementation a bit.
Hi Benny,
Nice catch! But I disagree with one change:
> /* Partial final word? */
> - if (size & (BITS_PER_LONG-1)) {
> - tmp = (addr[words] & (~0UL >> (BITS_PER_LONG
> - - (size & (BITS_PER_LONG-1)))));
> + tmp = size & (BITS_PER_LONG-1);
> + if (tmp) {
> + tmp = addr[words] & (~0UL >> (BITS_PER_LONG - tmp));
> if (tmp)
> goto found;
> }
The overloading of tmp to the remainder size here is not really a cleanup: it
makes it into a dual-use var. I know it's called tmp, but that's a sign of
poor code too :)
I'd prefer a new final_bits var: gcc will almost certainly just slap it in
a register anyway, but it's clearer.
tmp could then be called something like... word?
Thanks!
Rusty.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/