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: <eba72e0dc08c5c80017000bf555d59f686423a36.1479998643.git.geliangtang@gmail.com>
Date:   Thu, 24 Nov 2016 22:45:52 +0800
From:   Geliang Tang <geliangtang@...il.com>
To:     Andy Whitcroft <apw@...onical.com>, Joe Perches <joe@...ches.com>
Cc:     Geliang Tang <geliangtang@...il.com>, linux-kernel@...r.kernel.org
Subject: [PATCH] checkpatch: warn if <foo.h> is already included

Some headers are included twice. Emit a warning when they occur.
For example:
$ ./scripts/checkpatch.pl -f drivers/of/overlay.c
WARNING: Do not use #include <linux/string.h>, this header is already included
+#include <linux/string.h>

WARNING: Do not use #include <linux/string.h>, this header is already included
+#include <linux/string.h>

total: 0 errors, 4 warnings, 589 lines checked

Signed-off-by: Geliang Tang <geliangtang@...il.com>
---
 scripts/checkpatch.pl | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 1579230..a0792d6 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4749,6 +4749,18 @@ sub process {
 			}
 		}
 
+# warn if <foo.h> is already #included
+		if ($tree && $rawline =~ m{^.\s*\#\s*include\s*\<(.*)\.h\>}) {
+			my $file = "$1.h";
+			if (-f "$root/$realfile") {
+				my $asminclude = `grep -Ec "#include\\s+<$file>" $root/$realfile`;
+				if ($asminclude > 1) {
+					WARN("INCLUDE_LINUX",
+					     "Do not use #include <$file>, this header is already included\n" . $herecurr);
+				}
+			}
+		}
+
 # multi-statement macros should be enclosed in a do while loop, grab the
 # first statement and ensure its the whole macro if its not enclosed
 # in a known good container
-- 
2.9.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ