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]
Date:   Mon, 3 Jul 2023 22:46:01 +0200
From:   Michał Mirosław <mirq-linux@...e.qmqm.pl>
To:     Krzysztof Kozlowski <krzk@...nel.org>
Cc:     Andi Shyti <andi.shyti@...nel.org>,
        Codrin Ciubotariu <codrin.ciubotariu@...rochip.com>,
        linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] i2c: at91: constify at91_twi_pdata

On Mon, Jul 03, 2023 at 08:23:30PM +0200, Krzysztof Kozlowski wrote:
> On 30/06/2023 00:38, Andi Shyti wrote:
> > Hi Michal,
> >> -static struct at91_twi_pdata *at91_twi_get_driver_data(
> >> +static const struct at91_twi_pdata *at91_twi_get_driver_data(
> >>  					struct platform_device *pdev)
> >>  {
> >>  	if (pdev->dev.of_node) {
> >> @@ -189,9 +189,9 @@ static struct at91_twi_pdata *at91_twi_get_driver_data(
> >>  		match = of_match_node(atmel_twi_dt_ids, pdev->dev.of_node);
> >>  		if (!match)
> >>  			return NULL;
> >> -		return (struct at91_twi_pdata *)match->data;
> >> +		return match->data;
> >>  	}
> >> -	return (struct at91_twi_pdata *) platform_get_device_id(pdev)->driver_data;
> >> +	return (const void *) platform_get_device_id(pdev)->driver_data;
> > 
> > the const's always confuse me... do you get an error here? Is
> > this cast really needed?
> 
> I think this change is not necessary and actually should not matter. See
> for example drivers/tty/serial/samsung_tty.c after my refactorings in
> commit 3aec40096550 ("tty: serial: samsung: reduce number of casts").

I added this two fragments to avoid having suggesting that the pdata might
not be in a read-only segment.  For the compiler it doesn't matter -- the
pointer is cast to const on return.

Best Regards
Michał Mirosław

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ