[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2024061808-crane-palm-29ea@gregkh>
Date: Tue, 18 Jun 2024 16:02:46 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Matthew Wilcox <willy@...radead.org>
Cc: Sakari Ailus <sakari.ailus@...ux.intel.com>,
linux-kernel@...r.kernel.org,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Jason Gunthorpe <jgg@...dia.com>,
"Rafael J . Wysocki" <rafael@...nel.org>,
Hans Verkuil <hverkuil@...all.nl>
Subject: Re: [PATCH 1/1] container_of: Document container_of_const() is
preferred
On Tue, Jun 18, 2024 at 02:56:17PM +0100, Matthew Wilcox wrote:
> On Tue, Jun 18, 2024 at 02:54:53PM +0200, Greg Kroah-Hartman wrote:
> > > I didn't have any issues (apart from me misspelling function names ;)) with
> > > GCC 12, neither in using container_of_const() in a static inline function
> > > nor in using a static inline function as a _Generic() expression.
> >
> > Really? And how do you handle the pointer being either const or not,
> > and propagating that back out as the return type? I'd like to see your
> > inline function please.
>
> Here's how I did it for page_folio():
>
> #define page_folio(p) (_Generic((p), \
> const struct page *: (const struct folio *)_compound_head(p), \
> struct page *: (struct folio *)_compound_head(p)))
>
> Is there something differently magic about container_of() that prevents
> this trick from working?
That's a #define, not an inline function, which is what I thought we
were talking about.
thanks,
greg k-h
Powered by blists - more mailing lists