On Wed, Jul 31, 2019 at 12:27:38PM -0700, Joe Perches wrote:
> On Wed, 2019-07-31 at 21:03 +0200, Rikard Falkeborn wrote:
> > GENMASK() and GENMASK_ULL() are supposed to be called with the high bit
> > as the first argument and the low bit as the second argument. Mixing
> > them will return a mask with zero bits set.
> 
> A few things:
> 
> o Reading the final code is a bit confusing.
>   Perhaps add a comment description saying it's not checked
>   in asm .h uses.

Comment added.
 
> o Maybe use:
>   #define GENMASK_INPUT_CHECK(h, l) UL(0)

Sure.
 
> o The compiler error message when the arguments are in the
>   wrong order isn't obvious.  Is there some way to improve
>   the compiler error output, maybe by using BUILD_BUG_ON_MSG
>   or some other mechanism?

Not that I could find. BUILD_BUG_ON_MSG can not be used if the macros
should be usable in e.g. a structure initializer (this seems to be the
whole reason BUILD_BUG_ON_ZERO exists).

Reply via email to