[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260112123224.GH830755@noisy.programming.kicks-ass.net>
Date: Mon, 12 Jan 2026 13:32:24 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Al Viro <viro@...iv.linux.org.uk>
Cc: kernel test robot <lkp@...el.com>, Eric Dumazet <edumazet@...gle.com>,
oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
Jakub Kicinski <kuba@...nel.org>,
Maciej Żenczykowski <maze@...gle.com>,
Will Deacon <will@...nel.org>,
"Paul E. McKenney" <paulmck@...nel.org>
Subject: Re: include/net/sock.h:2100:16: sparse: sparse: cast to non-scalar
On Sat, Jan 10, 2026 at 10:35:48PM +0000, Al Viro wrote:
> #define __READ_ONCE(x) \
> ({ \
> __unqual_scalar_typeof(x) __x = \
> (*(volatile typeof(__x) *)(&(x))); \
> mb(); \
> (typeof(x))__x; \
> })
> combined with
> typedef struct {
> uid_t val;
> } kuid_t;
>
> IOW, it complains about a cast from structure to itself, which is fair
> enough - C is pretty clear about not allowing any typecasts to or from
> non-scalar types, tautological or not.
>
> Why do we even need that cast? Seeing that generic __READ_ONCE() is
> #define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x))
> the cast added on alpha seems to be pointless.
The problem was things like test_bit() that take a volatile argument,
doing READ_ONCE() on them would instantiate a volatile temporary and GCC
would end up generating shit code.
The __unqual_scalar_typeof() was the result of trying to remove CV
qualifiers from a type.
Powered by blists - more mailing lists