History

checkpatch: remove missing switch/case break test

This test doesn't work well and newer compilers are much better at emitting this warning.

Joe Perches committed 6 years ago

Commit ef3c0051 parent 1a3dcf21 file · +0 −25Browse files

Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all

Unified · Split

scripts/checkpatch.pl+0−25
@@ -6543,31 +6543,6 @@ sub process { · 6542 unmodified lines
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',