Commit e81f239b4db2ad6c4b029ed92f0222601ce42abe
Committed by
Linus Torvalds
1 parent
1813087dbc
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
checkpatch: fix false positive MISSING_BREAK warnings with --file
Using --file mode can give false positives with MISSING_BREAK fall-through warnings on simple but long multiple consecutive case statements. Look for all lines before a case statement for a switch or a statement when using --file mode. Fix a misspelling of preceded while there. Signed-off-by: Joe Perches <joe@perches.com> Reported-by: Lee Jones <lee.jones@linaro.org> Acked-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff
scripts/checkpatch.pl
... | ... | @@ -4811,13 +4811,13 @@ |
4811 | 4811 | } |
4812 | 4812 | } |
4813 | 4813 | |
4814 | -# check for case / default statements not preceeded by break/fallthrough/switch | |
4814 | +# check for case / default statements not preceded by break/fallthrough/switch | |
4815 | 4815 | if ($line =~ /^.\s*(?:case\s+(?:$Ident|$Constant)\s*|default):/) { |
4816 | 4816 | my $has_break = 0; |
4817 | 4817 | my $has_statement = 0; |
4818 | 4818 | my $count = 0; |
4819 | 4819 | my $prevline = $linenr; |
4820 | - while ($prevline > 1 && $count < 3 && !$has_break) { | |
4820 | + while ($prevline > 1 && ($file || $count < 3) && !$has_break) { | |
4821 | 4821 | $prevline--; |
4822 | 4822 | my $rline = $rawlines[$prevline - 1]; |
4823 | 4823 | my $fline = $lines[$prevline - 1]; |