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:35:54 +0100 (CET)
From:   Julia Lawall <julia.lawall@...ia.fr>
To:     Uwe Kleine-König 
        <u.kleine-koenig@...gutronix.de>
cc:     Menna Mahmoud <eng.mennamahmoud.mm@...il.com>,
        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
Subject: Re: [PATCH 2/3] staging: greybus: use inline function for macros



On Tue, 21 Mar 2023, Uwe Kleine-König wrote:

> On Tue, Mar 21, 2023 at 04:59:49PM +0100, Julia Lawall wrote:
> >
> >
> > On Tue, 21 Mar 2023, 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/;
> > >
> > > > 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.
> >
> > I argued against that.  Because then there are two uses of dev
> > in the argument of container_of, and they refer to completely different
> > things.  It's true that by the way container_of works, it's fine, but it
> > may be misleading.
>
> Hmm, that seems to be subjective, but I have less problems with that
> than with using "d" for a struct device (or a struct device_driver).
> I'd even go so far as to consider it nice if they are identical.
>
> Maybe that's because having the first and third argument identical is
> quite common:
>
> 	$ git grep -P 'container_of\((?<ident>[A-Za-z_0-9-]*)\s*,[^,]*,\s*\g{ident}\s*\)' | wc -l
> 	5940
>
> which is >44% of all the usages
>
> 	$ git grep -P 'container_of\((?<ident>[A-Za-z_0-9-]*)\s*,[^,]*,\s*(?&ident)\s*\)' | wc -l
> 	13362

OK, if people like that, then why not.  But it's dangerous if the call to
container_of is in a macro, rather than in a function.

julia

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ