[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <9d74aaf8-a328-a3a6-dcaa-9ade95538241@laposte.net>
Date: Tue, 6 Dec 2016 11:10:02 +0100
From: Sebastian Frias <sf84@...oste.net>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: zijun_hu <zijun_hu@....com>,
Andrew Morton <akpm@...ux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Mason <slash.tmp@...e.fr>,
Harvey Harrison <harvey.harrison@...il.com>,
Borislav Petkov <bp@...en8.de>
Subject: Re: [PATCH v2] add equivalent of BIT(x) for bitfields
On 05/12/16 19:23, Linus Torvalds wrote:
> On Mon, Dec 5, 2016 at 9:49 AM, Sebastian Frias <sf84@...oste.net> 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
>
Powered by blists - more mailing lists