lkml.org 
[lkml]   [2022]   [Dec]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
On Wed, Nov 23, 2022 at 06:00:23PM +0000, Matthew Wilcox wrote:
> On Wed, Nov 23, 2022 at 01:55:42PM -0400, Jason Gunthorpe wrote:
> > On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> > > On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > > > #define generic_container_of(in_type, in, out_type, out_member) \
> > > > _Generic(in, \
> > > > const in_type *: ((const out_type *)container_of(in, out_type, out_member)), \
> > > > in_type *: ((out_type *)container_of(in, out_type, out_member)) \
> > > > )
> > >
> > > There's a neat trick I found in seqlock.h:
> > >
> > > #define generic_container_of(in_t, in, out_t, m) \
> > > _Generic(*(in), \
> > > const in_t: ((const out_t *)container_of(in, out_t, m)), \
> > > in_t: ((out_t *)container_of(in, out_type, m)) \
> > > )
> > >
> > > and now it fits in 80 columns ;-)
> >
> > Aside from less letters, is their another benifit to using *(in) ?
>
> I don't think so. It just looks nicer to me than putting the star in
> each case. If I'd thought of it, I would have done it to page_folio(),
> but I won't change it now.

Ah, but your trick will not work, that blows up and will not build. The
original one from Jason here does work. _Generic is tricky...

thanks,

greg k-h

\
 
 \ /
  Last update: 2022-12-01 19:44    [W:0.091 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site