Re: [PATCH] block: Use BIT macro from include/linux/bitops.h

From: Jens Axboe
Date: Wed May 20 2015 - 15:43:11 EST


On 05/20/2015 01:41 PM, Jagan Teki wrote:
On 21 May 2015 at 00:52, Jens Axboe <axboe@xxxxxxxxx> wrote:
On 05/18/2015 01:14 PM, Jagan Teki wrote:

Replace (1 << nr) to BIT(nr) where nr = 0, 1, 2 .... 31


I don't like it, I think it hurts readability.

What do you mean by don't like, using kernel defined macro instead of
numerical assignments huts readability?

In the context of the patch, BIT(0) == (1 << 0) is obvious. But if I just came across BIT(7) in the code, I'd have to check, whereas anyone would immediately know that (1 << 7) is the 7th bit set. Hence, readability is worse, and that's important.

--
Jens Axboe

--
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/