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]
Message-ID: <2375c9f90910050059n636ab68dw651225f14b86ee15@mail.gmail.com>
Date:	Mon, 5 Oct 2009 15:59:49 +0800
From:	Américo Wang <xiyou.wangcong@...il.com>
To:	Joe Perches <joe@...ches.com>
Cc:	Andy Whitcroft <apw@...onical.com>,
	Jan Ceuleers <jan.ceuleers@...puter.org>,
	David Miller <davem@...emloft.net>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] scripts/checkpatch.pl: Add WARN on sizeof(&

On Sun, Oct 4, 2009 at 9:12 AM, Joe Perches <joe@...ches.com> 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.

A quick grep shows we have more:

grep -e '\bsizeof[:space:]*([:space:]*\&.*)' -nr ./
./drivers/media/video/em28xx/em28xx-cards.c:2237:
memset(&dev->info, 0, sizeof(&dev->info));
./drivers/media/video/saa7164/saa7164-cmd.c:350:
memset(&response_t, 0, sizeof(&response_t));
./drivers/media/dvb/dvb-usb/ce6230.c:108:       memset(&req, 0, sizeof(&req));
./drivers/video/backlight/lcd.c:59:     memset(&ld->fb_notif, 0,
sizeof(&ld->fb_notif));

>
> ---
>
> sizeof(&foo) is frequently an error.  Warn on its use.
>
> Signed-off-by: Joe Perches <joe@...ches.com>


This patch looks fine for me,

Acked-by: WANG Cong <xiyou.wangcong@...il.com>


>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 87bbb8b..596dd72 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2534,6 +2534,11 @@ sub process {
>                        WARN("plain inline is preferred over $1\n" . $herecurr);
>                }
>
> +# check for sizeof(&)
> +               if ($line =~ /\bsizeof\s*\(\s*\&/) {
> +                       WARN("sizeof(& should be avoided\n" . $herecurr);
> +               }
> +
>  # check for new externs in .c files.
>                if ($realfile =~ /\.c$/ && defined $stat &&
>                    $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s)
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ