lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZnGSAfh70wdFQE3x@casper.infradead.org>
Date: Tue, 18 Jun 2024 14:56:17 +0100
From: Matthew Wilcox <willy@...radead.org>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.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: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?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ