diff options
author | Andy Whitcroft <apw@shadowen.org> | 2008-10-16 01:02:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-16 14:21:36 -0400 |
commit | a1080bf80862c571b5f0a20cb601e24dd90e2026 (patch) | |
tree | 0aae05e30c0107a6286bce04692c7d17b4f1f632 /scripts | |
parent | dea79cd3dfb4a50e4c3d0dcb7294f6d633b455d1 (diff) |
checkpatch: case/default checks should only check changed lines
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>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/checkpatch.pl | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 66bcedc0c8b3..457f87460d6e 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -1363,14 +1363,6 @@ sub process { | |||
1363 | ERROR("switch and case should be at the same indent\n$hereline$err"); | 1363 | ERROR("switch and case should be at the same indent\n$hereline$err"); |
1364 | } | 1364 | } |
1365 | } | 1365 | } |
1366 | if ($line =~ /^.\s*(?:case\s*.*|default\s*):/g && | ||
1367 | $line !~ /\G(?: | ||
1368 | (?:\s*{)?(?:\s*$;*)(?:\s*\\)?\s*$| | ||
1369 | \s*return\s+ | ||
1370 | )/xg) | ||
1371 | { | ||
1372 | ERROR("trailing statements should be on next line\n" . $herecurr); | ||
1373 | } | ||
1374 | 1366 | ||
1375 | # if/while/etc brace do not go on next line, unless defining a do while loop, | 1367 | # if/while/etc brace do not go on next line, unless defining a do while loop, |
1376 | # or if that brace on the next line is for something else | 1368 | # or if that brace on the next line is for something else |
@@ -1986,6 +1978,15 @@ sub process { | |||
1986 | ERROR("trailing statements should be on next line\n" . $herecurr); | 1978 | ERROR("trailing statements should be on next line\n" . $herecurr); |
1987 | } | 1979 | } |
1988 | } | 1980 | } |
1981 | # case and default should not have general statements after them | ||
1982 | if ($line =~ /^.\s*(?:case\s*.*|default\s*):/g && | ||
1983 | $line !~ /\G(?: | ||
1984 | (?:\s*{)?(?:\s*$;*)(?:\s*\\)?\s*$| | ||
1985 | \s*return\s+ | ||
1986 | )/xg) | ||
1987 | { | ||
1988 | ERROR("trailing statements should be on next line\n" . $herecurr); | ||
1989 | } | ||
1989 | 1990 | ||
1990 | # Check for }<nl>else {, these must be at the same | 1991 | # Check for }<nl>else {, these must be at the same |
1991 | # indent level to be relevant to each other. | 1992 | # indent level to be relevant to each other. |