summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAntony Pavlov <antonynpavlov@gmail.com>2018-12-05 16:21:58 +0300
committerSascha Hauer <s.hauer@pengutronix.de>2018-12-06 08:56:09 +0100
commit151ab20210367e7774f2caff705ad3aac85ade3e (patch)
tree7148f3f0fa6aa737d5541abfae8deaee64e9dfa9 /scripts
parent832750116b8c6ea220bf3c1ed682b81b6ec18216 (diff)
downloadbarebox-151ab20210367e7774f2caff705ad3aac85ade3e.tar.gz
barebox-151ab20210367e7774f2caff705ad3aac85ade3e.tar.xz
checkpatch.pl: check for #if 0/#if 1
The #if 0 or #if 1 is used to toggle features. Warn if #if 0 or #if 1 is present and suggest that they can be removed. Based on 60f890105547f7a4 ("checkpatch: check for #if 0/#if 1") Linux kernel commit. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl11
1 files changed, 8 insertions, 3 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d1fe6659ce..4e17347a84 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2863,9 +2863,14 @@ sub process {
# warn about #if 0
if ($line =~ /^.\s*\#\s*if\s+0\b/) {
- CHK("REDUNDANT_CODE",
- "if this code is redundant consider removing it\n" .
- $herecurr);
+ WARN("IF_0",
+ "Consider removing the code enclosed by this #if 0 and its #endif\n" . $herecurr);
+ }
+
+# warn about #if 1
+ if ($line =~ /^.\s*\#\s*if\s+1\b/) {
+ WARN("IF_1",
+ "Consider removing the #if 1 and its #endif\n" . $herecurr);
}
# check for needless kfree() checks