On 05/12/16 19:23, Linus Torvalds wrote:
> On Mon, Dec 5, 2016 at 9:49 AM, Sebastian Frias <[email protected]> wrote:
>> Introduce GENVALUE(msb, lsb, value) macro to ease dealing with
>> continuous bitfields, just as BIT(x) does for single bits.
> 
> Oh, and looking at the implementation, this is wrong. You use "lsb"
> twice, so it mustn't have side effects.
> 
> That's fine for all expected users (since you'd expect that the only
> real use of this is with constant values for msb/lsb), 

Yes, that's what I thought.

>but please add
> actual checking.

Sure! Thanks for the advice.

> 
> You can use BUILD_BUG_ON_ZERO(!__builtin_constant_p(x)) or something.
> That returns zero, so it's easy to use in expressions.

Done. v3 of the patch is submitted.

> 
>              Linus
> 

Reply via email to