From: Joe Perches Date: Wed, 6 Aug 2014 23:11:25 +0000 (-0700) Subject: checkpatch: fix false positive MISSING_BREAK warnings with --file X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e81f239b4db2ad6c4b029ed92f0222601ce42abe;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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 Reported-by: Lee Jones Acked-by: Lee Jones Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 10384cf40691..a0880ede3db9 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -4811,13 +4811,13 @@ sub process { } } -# check for case / default statements not preceeded by break/fallthrough/switch +# check for case / default statements not preceded by break/fallthrough/switch if ($line =~ /^.\s*(?:case\s+(?:$Ident|$Constant)\s*|default):/) { my $has_break = 0; my $has_statement = 0; my $count = 0; my $prevline = $linenr; - while ($prevline > 1 && $count < 3 && !$has_break) { + while ($prevline > 1 && ($file || $count < 3) && !$has_break) { $prevline--; my $rline = $rawlines[$prevline - 1]; my $fline = $lines[$prevline - 1];