From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Matthew Wilcox <willy@infradead.org>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>,
linux-kernel@vger.kernel.org,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Jason Gunthorpe <jgg@nvidia.com>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Hans Verkuil <hverkuil@xs4all.nl>
Subject: Re: [PATCH 1/1] container_of: Document container_of_const() is preferred
Date: Tue, 18 Jun 2024 16:02:46 +0200 [thread overview]
Message-ID: <2024061808-crane-palm-29ea@gregkh> (raw)
In-Reply-To: <ZnGSAfh70wdFQE3x@casper.infradead.org>
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
next prev parent reply other threads:[~2024-06-18 14:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-17 10:08 [PATCH 1/1] container_of: Document container_of_const() is preferred Sakari Ailus
2024-06-17 10:44 ` Greg Kroah-Hartman
2024-06-18 9:09 ` Sakari Ailus
2024-06-18 10:01 ` Greg Kroah-Hartman
2024-06-18 11:52 ` Sakari Ailus
2024-06-18 12:54 ` Greg Kroah-Hartman
2024-06-18 13:56 ` Matthew Wilcox
2024-06-18 14:02 ` Greg Kroah-Hartman [this message]
2024-08-09 12:59 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2024061808-crane-palm-29ea@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=hverkuil@xs4all.nl \
--cc=jgg@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox