This test doesn't work well and newer compilers are much better at emitting this warning.
Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all
Unified · Split
| @@ -6543,31 +6543,6 @@ sub process { · 6542 unmodified lines | ||
| 6543 | 6543 | } |
| 6544 | 6544 | } |
| 6545 | 6545 | |
| 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 | − | |
| 6571 | 6546 | # check for /* fallthrough */ like comment, prefer fallthrough; |
| 6572 | 6547 | my @fallthroughs = ( |
| 6573 | 6548 | 'fallthrough', |