Re: [PATCH 1/1] checkpatch: Deprecate container_of() in favour of container_of_const()
From: Sakari Ailus
Date: Wed Nov 05 2025 - 11:25:20 EST
Hi Christoph,
On Wed, Nov 05, 2025 at 05:01:46AM -0800, Christoph Hellwig wrote:
> Well, if container_of_const is a drop-in replacement for all uses of
> container_of, just fix the implementation? If it is an almost but not
> complete replacement, find a different name for the few uses. And if
> it's not anywhere near drop in, just using container_of make a lot more
> sense.
>
> Just in case it wasn't clear: We really should keep the shorter nice
> name as the default if at all possible. Both because it reads better
> and because it avoids churn.
I'm in favour of the container_of() name instead of container_of_const(),
but there are a vast number of uses of container_of() in the kernel and
fixing these to respect const qualifier is going to take time. The intent
here is to prevent adding new uses of container_of() that do not respect
constness.
I tested this again on v6.18-rc2 and with my .config (far from
allyesconfig) there were 840 warnings from discarding const qualifier.
Presumably a lot of these are duplicates, but then again it'll be a
thankless (and possibly endless?) task to fix these if we don't make effort
to avoid new ones from being added at the same time.
--
Kind regards,
Sakari Ailus