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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230318175532.GA49651@sumitra.com>
Date:   Sat, 18 Mar 2023 10:55:32 -0700
From:   Sumitra Sharma <sumitraartsy@...il.com>
To:     Julia Lawall <julia.lawall@...ia.fr>
Cc:     Marc Dietrich <marvin24@....de>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        ac100@...ts.launchpad.net, linux-tegra@...r.kernel.org,
        linux-staging@...ts.linux.dev, linux-kernel@...r.kernel.org,
        outreachy@...ts.linux.dev
Subject: Re: [PATCH] Staging: nvec: Change container_of macro to an inline
 function.

On Sat, Mar 18, 2023 at 06:14:50PM +0100, Julia Lawall wrote:
> 
> 
> On Sat, 18 Mar 2023, Sumitra Sharma wrote:
> 
> > The macro has the drawback that one cannot determine
> > what type it applies to by looking at the definition.
> > Hence this macro definition is not type-safe.
> >
> > The inline function gives the same benefits as the
> > macro and only accepts the specific type of arguments.
> > Use static because the definition only requires it to be
> > visible in the current file.
> 
> Sumitra,
> 
> The subject line and log message could be a little less generic.  For the
> subject line, one has the impression that you are changing the definition
> of container_of itself.
> 
> The log message is also a bit wordy.  Something like the following would
> be more concise and still present the issue:
>

Okay. I will focus more on writing better patch subject and description.

Thanks.

Regards,

Sumitra

> Convert to_nvec_led from a macro to an inline function, to make the
> relevant types apparent in the definition and to benefit from the type
> checking performed by the compiler at call sites.
> 
> julia
> 
> 
> >
> > Signed-off-by: Sumitra Sharma <sumitraartsy@...il.com>
> > ---
> >  drivers/staging/nvec/nvec_paz00.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/staging/nvec/nvec_paz00.c b/drivers/staging/nvec/nvec_paz00.c
> > index 8b4da95081c8..9573ba762cdd 100644
> > --- a/drivers/staging/nvec/nvec_paz00.c
> > +++ b/drivers/staging/nvec/nvec_paz00.c
> > @@ -14,8 +14,10 @@
> >  #include <linux/platform_device.h>
> >  #include "nvec.h"
> >
> > -#define to_nvec_led(led_cdev) \
> > -	container_of(led_cdev, struct nvec_led, cdev)
> > +static inline struct nvec_led *to_nvec_led(struct led_classdev *led_cdev)
> > +{
> > +	return container_of(led_cdev, struct nvec_led, cdev);
> > +}
> >
> >  #define NVEC_LED_REQ {'\x0d', '\x10', '\x45', '\x10', '\x00'}
> >
> > --
> > 2.25.1
> >
> >
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ