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 for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1530816922-27100-1-git-send-email-pheragu@codeaurora.org>
Date:   Thu,  5 Jul 2018 11:55:22 -0700
From:   Prakruthi Deepak Heragu <pheragu@...eaurora.org>
To:     apw@...onical.com, joe@...ches.com
Cc:     linux-kernel@...r.kernel.org, ckadabi@...eaurora.org,
        tsoni@...eaurora.org, bryanh@...eaurora.org,
        Prakruthi Deepak Heragu <pheragu@...eaurora.org>
Subject: [PATCH] checkpatch: check for #if 0/#if 1

The #if 0 and #if 1 are used to toggle features. Wharn if #if 1 or #if 0
is present. If #if 0 is present, warn about that part of code being
redundant and that it could be removed. Also, if #if 1 is present, suggest
that if the code is required then the #if 1 can be removed. In either
case, these preprocessor directives can be removed.

Signed-off-by: Prakruthi Deepak Heragu <pheragu@...eaurora.org>
---
 scripts/checkpatch.pl | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 978c752..fa3e695 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5378,11 +5378,19 @@ sub process {
                  "Use of dsb is discouranged: prefer mb.\n" .
                  $herecurr);
 		}
+
 # 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",
+			     "if this code is redundant consider removing it\n"
+				.  $herecurr);
+		}
+
+# warn about #if 1
+		if ($line =~ /^.\s*\#\s*if\s+1\b/) {
+			WARN("IF_1",
+			     "if this code is required consider removing"
+				. " #if 1\n" .  $herecurr);
 		}
 
 # check for needless "if (<foo>) fn(<foo>)" uses
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ