public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Prakruthi Deepak Heragu <pheragu@codeaurora.org>
To: apw@canonical.com, joe@perches.com
Cc: linux-kernel@vger.kernel.org, ckadabi@codeaurora.org,
	tsoni@codeaurora.org, bryanh@codeaurora.org,
	Prakruthi Deepak Heragu <pheragu@codeaurora.org>
Subject: [PATCH] checkpatch: check for #if 0/#if 1
Date: Thu,  5 Jul 2018 11:55:22 -0700	[thread overview]
Message-ID: <1530816922-27100-1-git-send-email-pheragu@codeaurora.org> (raw)

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


             reply	other threads:[~2018-07-05 18:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-05 18:55 Prakruthi Deepak Heragu [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-07-03 16:56 [PATCH] checkpatch: check for #if 0/#if 1 Prakruthi Deepak Heragu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1530816922-27100-1-git-send-email-pheragu@codeaurora.org \
    --to=pheragu@codeaurora.org \
    --cc=apw@canonical.com \
    --cc=bryanh@codeaurora.org \
    --cc=ckadabi@codeaurora.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tsoni@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox