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] [day] [month] [year] [list]
Message-ID: <20251126192705.36321d87@pumpkin>
Date: Wed, 26 Nov 2025 19:27:05 +0000
From: david laight <david.laight@...box.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@....qualcomm.com>
Cc: Krzysztof Kozlowski <krzk@...nel.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] w1: Use container_of_const() when all types are const

On Wed, 26 Nov 2025 18:18:42 +0100
Krzysztof Kozlowski <krzysztof.kozlowski@....qualcomm.com> 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.

	David

> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@....qualcomm.com>
> ---
>  drivers/w1/w1.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
> index 002d2639aa12..3b48d15390be 100644
> --- a/drivers/w1/w1.c
> +++ b/drivers/w1/w1.c
> @@ -575,11 +575,11 @@ static int w1_uevent(const struct device *dev, struct kobj_uevent_env *env)
>  	int err = 0;
>  
>  	if (dev->driver == &w1_master_driver) {
> -		md = container_of(dev, struct w1_master, dev);
> +		md = container_of_const(dev, struct w1_master, dev);
>  		event_owner = "master";
>  		name = md->name;
>  	} else if (dev->driver == &w1_slave_driver) {
> -		sl = container_of(dev, struct w1_slave, dev);
> +		sl = container_of_const(dev, struct w1_slave, dev);
>  		event_owner = "slave";
>  		name = sl->name;
>  	} else {


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ