linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] checkpatch: check for #if 0/#if 1
@ 2018-07-26 17:13 Prakruthi Deepak Heragu
  2018-07-26 21:31 ` Joe Perches
  0 siblings, 1 reply; 2+ messages in thread
From: Prakruthi Deepak Heragu @ 2018-07-26 17:13 UTC (permalink / raw)
  To: apw, joe
  Cc: linux-kernel, ckadabi, tsoni, bryanh, Abhijeet Dharmapurikar,
	Prakruthi Deepak Heragu

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.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: Prakruthi Deepak Heragu <pheragu@codeaurora.org>
---
Changes in v2:
- Rephrase the warning for #if 0

Changes in v1:
- Rephrase the warning message to fit in a single line without
  80 column limit

 scripts/checkpatch.pl | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 3394ed8..1dfe83f 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5383,9 +5383,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 "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

* Re: [PATCH v2] checkpatch: check for #if 0/#if 1
  2018-07-26 17:13 [PATCH v2] checkpatch: check for #if 0/#if 1 Prakruthi Deepak Heragu
@ 2018-07-26 21:31 ` Joe Perches
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2018-07-26 21:31 UTC (permalink / raw)
  To: Prakruthi Deepak Heragu, apw, Andrew Morton
  Cc: linux-kernel, ckadabi, tsoni, bryanh, Abhijeet Dharmapurikar

On Thu, 2018-07-26 at 10:13 -0700, Prakruthi Deepak Heragu wrote:
> 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.
> 
> Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
> Signed-off-by: Prakruthi Deepak Heragu <pheragu@codeaurora.org>

Andrew, can you please move the misplaced periods below
to the appropriate positions?

Otherwise:

Acked-by: Joe Perches <joe@perches.com>

> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -5383,9 +5383,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);

This should have a space before the . and only one space after.

> +		}
> +
> +# 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);

here too

>  		}
>  
>  # check for needless "if (<foo>) fn(<foo>)" uses

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-26 21:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-26 17:13 [PATCH v2] checkpatch: check for #if 0/#if 1 Prakruthi Deepak Heragu
2018-07-26 21:31 ` Joe Perches

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).