Re: [PATCH v2] checkpatch: check for #if 0/#if 1
From: Joe Perches
Date: Thu Jul 26 2018 - 17:31:16 EST
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@xxxxxxxxxxxxxx>
> Signed-off-by: Prakruthi Deepak Heragu <pheragu@xxxxxxxxxxxxxx>
Andrew, can you please move the misplaced periods below
to the appropriate positions?
Otherwise:
Acked-by: Joe Perches <joe@xxxxxxxxxxx>
> 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