Skip to content

Commit ef3c005

Browse files
JoePerchestorvalds
authored andcommitted
checkpatch: remove missing switch/case break test
This test doesn't work well and newer compilers are much better at emitting this warning. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Cc: Cambda Zhu <cambda@linux.alibaba.com> Link: http://lkml.kernel.org/r/7e25090c79f6a69d502ab8219863300790192fe2.camel@perches.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 1a3dcf2 commit ef3c005

1 file changed

Lines changed: 0 additions & 25 deletions

File tree

‎scripts/checkpatch.pl‎

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6543,31 +6543,6 @@ sub process {
65436543
}
65446544
}
65456545

6546-
# check for case / default statements not preceded by break/fallthrough/switch
6547-
if ($line =~ /^.\s*(?:case\s+(?:$Ident|$Constant)\s*|default):/) {
6548-
my $has_break = 0;
6549-
my $has_statement = 0;
6550-
my $count = 0;
6551-
my $prevline = $linenr;
6552-
while ($prevline > 1 && ($file || $count < 3) && !$has_break) {
6553-
$prevline--;
6554-
my $rline = $rawlines[$prevline - 1];
6555-
my $fline = $lines[$prevline - 1];
6556-
last if ($fline =~ /^\@\@/);
6557-
next if ($fline =~ /^\-/);
6558-
next if ($fline =~ /^.(?:\s*(?:case\s+(?:$Ident|$Constant)[\s$;]*|default):[\s$;]*)*$/);
6559-
$has_break = 1 if ($rline =~ /fall[\s_-]*(through|thru)/i);
6560-
next if ($fline =~ /^.[\s$;]*$/);
6561-
$has_statement = 1;
6562-
$count++;
6563-
$has_break = 1 if ($fline =~ /\bswitch\b|\b(?:break\s*;[\s$;]*$|exit\s*\(\b|return\b|goto\b|continue\b)/);
6564-
}
6565-
if (!$has_break && $has_statement) {
6566-
WARN("MISSING_BREAK",
6567-
"Possible switch case/default not preceded by break or fallthrough comment\n" . $herecurr);
6568-
}
6569-
}
6570-
65716546
# check for /* fallthrough */ like comment, prefer fallthrough;
65726547
my @fallthroughs = (
65736548
'fallthrough',

0 commit comments

Comments
 (0)