Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Joe Perches and committed by
Linus Torvalds
ef3c005c 1a3dcf2e

-25
-25
scripts/checkpatch.pl
··· 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',