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]
Date:   Tue, 21 Mar 2023 17:42:59 +0100
From:   Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To:     Menna Mahmoud <eng.mennamahmoud.mm@...il.com>
Cc:     gregkh@...uxfoundation.org, outreachy@...ts.linux.dev,
        johan@...nel.org, elder@...nel.org, vireshk@...nel.org,
        thierry.reding@...il.com, greybus-dev@...ts.linaro.org,
        linux-kernel@...r.kernel.org, linux-staging@...ts.linux.dev,
        linux-pwm@...r.kernel.org, Julia Lawall <julia.lawall@...ia.fr>
Subject: Re: [PATCH 2/3] staging: greybus: use inline function for macros

On Tue, Mar 21, 2023 at 06:25:29PM +0200, Menna Mahmoud wrote:
> 
> On ٢١‏/٣‏/٢٠٢٣ ١٧:٤٧, Uwe Kleine-König wrote:
> > Hello,
> > 
> > just some nitpicks:
> > 
> > On Tue, Mar 21, 2023 at 01:04:33AM +0200, Menna Mahmoud wrote:
> > > Convert `to_gbphy_dev` and `to_gbphy_driver` macros into a
> > > static inline function.
> > > 
> > > it is not great to have macro that use `container_of` macro,
> > s/it/It/; s/macro/macros/; s/use/use the/;
> Okay, I will fix it.
> > 
> > > because from looking at the definition one cannot tell what type
> > > it applies to.
> > > [...]
> > > -#define to_gbphy_dev(d) container_of(d, struct gbphy_device, dev)
> > > +static inline struct gbphy_device *to_gbphy_dev(const struct device *d)
> > drivers/staging/greybus/gbphy.c always passes a variable named
> > "dev" to this macro. So I'd call the parameter "dev", too, instead of
> > "d". This is also a more typical name for variables of that type.
> > 
> > > +{
> > > +	return container_of(d, struct gbphy_device, dev);
> > > +}
> > > [...]
> > >   };
> > > -#define to_gbphy_driver(d) container_of(d, struct gbphy_driver, driver)
> > > +static inline struct gbphy_driver *to_gbphy_driver(struct device_driver *d)
> > > +{
> > > +	return container_of(d, struct gbphy_driver, driver);
> > > +}
> > With a similar reasoning (and also to not have "d"s that are either
> > device or device_driver) I'd recommend "drv" here.
> 
> 
> please check this with Julia, because she said they should different.

At least use "_dev" instead of "d" which seems to be a common idiom,
too:

	$ git grep -P 'container_of\(_(?<ident>[A-Za-z_0-9-]*)\s*,[^,]*,\s*\g{ident}\s*\)' | wc -l
	570

("drv" should be fine, because the third argument is "driver" there.)

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ