Skip to content

Commit

Permalink
checkpatch: case/default checks should only check changed lines
Browse files Browse the repository at this point in the history
We should only be checking changes lines for the trailing statement check
on case/default statements.

Signed-off-by: Andy Whitcroft <apw@shadowen.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Andy Whitcroft authored and Linus Torvalds committed Oct 16, 2008
1 parent dea79cd commit a1080bf
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1363,14 +1363,6 @@ sub process {
ERROR("switch and case should be at the same indent\n$hereline$err");
}
}
if ($line =~ /^.\s*(?:case\s*.*|default\s*):/g &&
$line !~ /\G(?:
(?:\s*{)?(?:\s*$;*)(?:\s*\\)?\s*$|
\s*return\s+
)/xg)
{
ERROR("trailing statements should be on next line\n" . $herecurr);
}

# if/while/etc brace do not go on next line, unless defining a do while loop,
# or if that brace on the next line is for something else
Expand Down Expand Up @@ -1986,6 +1978,15 @@ sub process {
ERROR("trailing statements should be on next line\n" . $herecurr);
}
}
# case and default should not have general statements after them
if ($line =~ /^.\s*(?:case\s*.*|default\s*):/g &&
$line !~ /\G(?:
(?:\s*{)?(?:\s*$;*)(?:\s*\\)?\s*$|
\s*return\s+
)/xg)
{
ERROR("trailing statements should be on next line\n" . $herecurr);
}

# Check for }<nl>else {, these must be at the same
# indent level to be relevant to each other.
Expand Down

0 comments on commit a1080bf

Please sign in to comment.