Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e81f239b authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds
Browse files

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: default avatarJoe Perches <joe@perches.com>
Reported-by: default avatarLee Jones <lee.jones@linaro.org>
Acked-by: default avatarLee Jones <lee.jones@linaro.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 1813087d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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];