Re: [PATCH] w1: Use container_of_const() when all types are const
From: Krzysztof Kozlowski
Date: Thu Nov 27 2025 - 01:58:40 EST
On 26/11/2025 20:27, david laight wrote:
> On Wed, 26 Nov 2025 18:18:42 +0100
> Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxxxxxxxx> wrote:
>
>> Use container_of_const(), which is preferred over container_of(), when
>> the argument 'ptr' and returned pointer are already const, for better
>> code safety and readability.
>
> I thought there was a plan to make container_of() return a const pointer
> when the input is const?
>
> Can't be done yet because a few things need some 'const' sprinkles
> to compile.
>
You mean to use _Generic for container_of, basically exactly how
container_of_const is created? Do you have any indications that this is
happening, because current code does not suggest that.
Best regards,
Krzysztof