提交 e81f239b 编写于 作者: J Joe Perches 提交者: Linus Torvalds

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: NJoe Perches <joe@perches.com>
Reported-by: NLee Jones <lee.jones@linaro.org>
Acked-by: NLee Jones <lee.jones@linaro.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 1813087d
...@@ -4811,13 +4811,13 @@ sub process { ...@@ -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):/) { if ($line =~ /^.\s*(?:case\s+(?:$Ident|$Constant)\s*|default):/) {
my $has_break = 0; my $has_break = 0;
my $has_statement = 0; my $has_statement = 0;
my $count = 0; my $count = 0;
my $prevline = $linenr; my $prevline = $linenr;
while ($prevline > 1 && $count < 3 && !$has_break) { while ($prevline > 1 && ($file || $count < 3) && !$has_break) {
$prevline--; $prevline--;
my $rline = $rawlines[$prevline - 1]; my $rline = $rawlines[$prevline - 1];
my $fline = $lines[$prevline - 1]; my $fline = $lines[$prevline - 1];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册