* [PATCH] checkpatch: check for #if 0/#if 1
@ 2018-07-03 16:56 Prakruthi Deepak Heragu
0 siblings, 0 replies; 2+ messages in thread
From: Prakruthi Deepak Heragu @ 2018-07-03 16:56 UTC (permalink / raw)
To: apw, joe
Cc: linux-kernel, ckadabi, bryanh, tsoni, Abhijeet Dharmapurikar,
Stepan Moskovchenko, Murali Nalajala
From: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
The #if 0 and #if 1 are used to toggle features. Warn 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, the preprocessor directives can be removed.
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
---
scripts/checkpatch.pl | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a9c0550..a3dc0c8 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5374,9 +5374,16 @@ 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",
+ "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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] checkpatch: check for #if 0/#if 1
@ 2018-07-05 18:55 Prakruthi Deepak Heragu
0 siblings, 0 replies; 2+ messages in thread
From: Prakruthi Deepak Heragu @ 2018-07-05 18:55 UTC (permalink / raw)
To: apw, joe; +Cc: linux-kernel, ckadabi, tsoni, bryanh, Prakruthi Deepak Heragu
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-05 18:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-03 16:56 [PATCH] checkpatch: check for #if 0/#if 1 Prakruthi Deepak Heragu
2018-07-05 18:55 Prakruthi Deepak Heragu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).