Re: [PATCH] checkpatch: Add --strict preference for #defines using BIT(foo)

From: Andrew Morton
Date: Mon Nov 10 2014 - 18:36:52 EST


On Fri, 07 Nov 2014 13:15:39 -0800 Joe Perches <joe@xxxxxxxxxxx> wrote:

> Using BIT(foo) and BIT_ULL(bar) is more common now.
> Suggest using these macros over #defines with 1<<value.

urgh. I'm counting eightish implementations of BIT(), an unknown
number of which are actually being used. Many use 1<<n, some use
1UL<<N, another uses 1ULL<<n. I'm a bit reluctant to recommend that
anyone should use BIT() until it has has some vigorous scrubbing :(

Is it actually an improvement? If I see

#define X (1U << 7)

then I know exactly what it does. Whereas when I see

#define X BIT(7)

I know neither the size or the signedness of X so I have to go look it
up.


I have no strong feelings either way, but I'm wondering what might have
inspired this change?

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