[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aUNGcDLfe2AhWgkh@yury>
Date: Wed, 17 Dec 2025 19:10:24 -0500
From: Yury Norov <yury.norov@...il.com>
To: David Laight <david.laight.linux@...il.com>
Cc: Jonathan Cameron <jonathan.cameron@...wei.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
linux-kernel@...r.kernel.org, linux-usb@...r.kernel.org,
Geert Uytterhoeven <geert+renesas@...der.be>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Crt Mori <cmo@...exis.com>,
Richard Genoud <richard.genoud@...tlin.com>,
Andy Shevchenko <andriy.shevchenko@...el.com>,
Luo Jie <quic_luoj@...cinc.com>,
Peter Zijlstra <peterz@...radead.org>,
Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org,
"David S . Miller" <davem@...emloft.net>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
Andreas Noever <andreas.noever@...il.com>,
Yehezkel Bernat <YehezkelShB@...il.com>,
Nicolas Frattaroli <nicolas.frattaroli@...labora.com>
Subject: Re: [PATCH v2 08/16] bitfield: Simplify __BF_FIELD_CHECK_REG()
On Wed, Dec 17, 2025 at 10:31:55PM +0000, David Laight wrote:
> On Wed, 17 Dec 2025 10:26:18 +0000
> Jonathan Cameron <jonathan.cameron@...wei.com> wrote:
>
> > On Fri, 12 Dec 2025 19:37:13 +0000
> > david.laight.linux@...il.com wrote:
> >
> > > From: David Laight <david.laight.linux@...il.com>
...
> > > ---
> > > @@ -75,8 +59,8 @@
> > > })
> > >
> > > #define __BF_FIELD_CHECK_REG(mask, reg, pfx) \
> > > - BUILD_BUG_ON_MSG(__bf_cast_unsigned(mask, mask) > \
> > > - __bf_cast_unsigned(reg, ~0ull), \
> > > + BUILD_BUG_ON_MSG((mask) + 0U + 0UL + 0ULL > \
> > > + ~0ULL >> (64 - 8 * sizeof (reg)), \
> >
> > Trivial. sizeof(reg) is much more comment syntax in kernel code.
> (common)
>
> Hmm. sizeof is an operator not a function.
> Its argument is either a variable/expression or a bracketed type
> (I don't usually put variables in brackets).
> So 'sizeof(reg)' is nearly as bad as 'return(reg)'.
Please re-read Documentation/process/coding-style.rst:
3.1) Spaces
***********
Linux kernel style for use of spaces depends (mostly) on
function-versus-keyword usage. Use a space after (most) keywords. The
notable exceptions are sizeof, typeof, alignof, and __attribute__, which look
somewhat like functions (and are usually used with parentheses in Linux,
although they are not required in the language, as in: ``sizeof info`` after
``struct fileinfo info;`` is declared).
So use a space after these keywords::
if, switch, case, for, do, while
but not with sizeof, typeof, alignof, or __attribute__. E.g.,
.. code-block:: c
s = sizeof(struct file);
Do not add spaces around (inside) parenthesized expressions. This example is
**bad**:
.. code-block:: c
s = sizeof( struct file );
Powered by blists - more mailing lists