Skip to content

Commit

Permalink
checkpatch: check for #if 0/#if 1
Browse files Browse the repository at this point in the history
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.

[[email protected]: fix spacing around periods, per Joe\
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Abhijeet Dharmapurikar <[email protected]>
Signed-off-by: Prakruthi Deepak Heragu <[email protected]>
Acked-by: Joe Perches <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Prakruthi Deepak Heragu authored and torvalds committed Aug 22, 2018
1 parent 4cab63c commit 60f8901
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -5422,9 +5422,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
Expand Down

0 comments on commit 60f8901

Please sign in to comment.