Re: [PATCH] scripts/checkpatch.pl: Add WARN on sizeof(&

From: Andy Whitcroft
Date: Mon Oct 26 2009 - 07:17:28 EST


On Sat, Oct 03, 2009 at 06:12:49PM -0700, Joe Perches wrote:
> On Sat, 2009-10-03 at 17:38 +0200, Jan Ceuleers wrote:
> > David Miller wrote:
> > > Any time you see "&" in a sizeof() expression, it's almost
> > > certainly a bug. Something for the folks with automated
> > > tools to look for if they haven't already :-)
> >
> > Your remark prompted me to find four more instances of such bugs
> > (none of which in the networking bits). I have submitted patches.
>
> Perhaps a checkpatch test.
>
> ---
>
> sizeof(&foo) is frequently an error. Warn on its use.
>
> Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>

Seems reasonable. A slightly modified version of this is now in my
tree. Thanks!

http://www.kernel.org/pub/linux/kernel/people/apw/checkpatch/checkpatch.pl-testing

-apw
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/