lkml.org 
[lkml]   [2019]   [Oct]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v5 11/14] software node: move small properties inline when copying
On Wed, Oct 16, 2019 at 07:23:08PM +0300, Andy Shevchenko wrote:
> On Wed, Oct 16, 2019 at 07:18:45PM +0300, Andy Shevchenko wrote:
> > On Wed, Oct 16, 2019 at 09:01:26AM -0700, Dmitry Torokhov wrote:
> > > On Wed, Oct 16, 2019 at 10:48:57AM +0300, Andy Shevchenko wrote:
> > > > On Tue, Oct 15, 2019 at 11:25:53AM -0700, Dmitry Torokhov wrote:
> >
> > > > You store a value as union, but going to read as a member of union?
> > > > I'm pretty sure it breaks standard rules.
> > >
> > > No, I move the values _in place_ of the union, and the data is always
> > > fetched via void pointers. And copying data via char * or memcpy() is
> > > allowed even in C99 and C11.
> > >
> > > But I am wondering why are we actually worrying about all of this? The
> > > kernel is gnu89 and I think is going to stay this way because we use
> > > initializers with a cast in a lot of places:
> > >
> > > #define __RAW_SPIN_LOCK_UNLOCKED(lockname) \
> > > (raw_spinlock_t) __RAW_SPIN_LOCK_INITIALIZER(lockname)
> > >
> > > and C99 and gnu99 do not allow this. See
> > > https://lore.kernel.org/lkml/20141019231031.GB9319@node.dhcp.inet.fi/
> >
> > This is simple not a cast.
>
> 4.62 Compound literals in C99
> ISO C99 supports compound literals. A compound literal looks like a cast
> followed by an initializer. Its value is an object of the type specified in the
> cast, containing the elements specified in the initializer. It is an lvalue.

Yes, these are compound literals. And they can not be used as
initializers:

https://lore.kernel.org/lkml/CAHk-=wgXBV57mz46ZB5XivjiSBGkM0cjuvnU2OWyfRF=+41NPQ@mail.gmail.com/

Thanks.

--
Dmitry

\
 
 \ /
  Last update: 2019-10-16 18:45    [W:0.037 / U:0.492 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site