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-next>] [day] [month] [year] [list]
Message-Id: <1254618769.1799.280.camel@Joe-Laptop.home>
Date:	Sat, 03 Oct 2009 18:12:49 -0700
From:	Joe Perches <joe@...ches.com>
To:	Andy Whitcroft <apw@...onical.com>
Cc:	Jan Ceuleers <jan.ceuleers@...puter.org>,
	David Miller <davem@...emloft.net>,
	LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH] scripts/checkpatch.pl: Add WARN on sizeof(&

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@...ches.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