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: <063D6719AE5E284EB5DD2968C1650D6DD009C922@AcuExch.aculab.com>
Date:   Thu, 19 Oct 2017 15:15:49 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Andrew Lunn' <andrew@...n.ch>,
        Vivien Didelot <vivien.didelot@...oirfairelinux.com>
CC:     Egil Hjelmeland <privat@...l-hjelmeland.no>,
        "f.fainelli@...il.com" <f.fainelli@...il.com>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v2 net-next 1/2] net: dsa: lan9303: Add port_fast_age
 and port_fdb_dump methods

From: Andrew Lunn
> Sent: 19 October 2017 15:15
> > > +/* Clear learned (non-static) entry on given port */
> > > +static void alr_loop_cb_del_port_learned(struct lan9303 *chip, u32 dat0,
> > > +					 u32 dat1, int portmap, void *ctx)
> > > +{
> > > +	int *port = ctx;
> >
> > You can get the value directly to make the line below more readable:
> >
> >     int port = *(int *)ctx;
> 
> You have to be a bit careful with this. You often see people
> submitting patches taking away casts for void * pointers.
> If they do that here, it should at least not compile...
> 
> So maybe do it in two steps?
> 
>    int * pport = ctx;
>    int port = *pport;

IMHO it is best to define a struct for the 'ctx and then do:
	..., void *v_ctx)
{
	foo_ctx *ctx = v_ctx;
	int port = ctx->port;

That stops anyone having to double-check that the *(int *)
is operating on a pointer to an integer of the correct size.

One of the syntax checkers probably ought to generate a warning
for *(integer_type *)foo since it is often a bug.

	David

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ