diff options
author | Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com> | 2010-03-05 16:43:50 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-06 14:26:44 -0500 |
commit | 42bdf74c95b6935f3c09a09ba4bead6cad11b540 (patch) | |
tree | ef37ea657ba74ea1cd4c8ebeb239bb65e3946b32 /scripts | |
parent | 8f53a9b80f011080555c498d2ca2dc6b1a77c42c (diff) |
checkpatch: trivial fix for trailing statements check
In case if the statement and the conditional are in one line, the line
appears in the report doubly.
And items of this check have no blank line before the next item.
This patch fixes these trivial problems, to improve readability of the
report.
[sample.c]
> if (cond1
> && cond2
> && cond3) func_foo();
>
> if (cond4) func_bar();
Before:
> ERROR: trailing statements should be on next line
> #1: FILE: sample.c:1:
> +if (cond1
> [...]
> + && cond3) func_foo();
> ERROR: trailing statements should be on next line
> #5: FILE: sample.c:5:
> +if (cond4) func_bar();
> +if (cond4) func_bar();
> total: 2 errors, 0 warnings, 5 lines checked
After:
> ERROR: trailing statements should be on next line
> #1: FILE: sample.c:1:
> +if (cond1
> [...]
> + && cond3) func_foo();
>
> ERROR: trailing statements should be on next line
> #5: FILE: sample.c:5:
> +if (cond4) func_bar();
>
> total: 2 errors, 0 warnings, 5 lines checked
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Cc: Andy Whitcroft <apw@canonical.com>
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 | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 309050f30874..3e4099a6df51 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -2182,8 +2182,10 @@ sub process { | |||
2182 | # Find out how long the conditional actually is. | 2182 | # Find out how long the conditional actually is. |
2183 | my @newlines = ($c =~ /\n/gs); | 2183 | my @newlines = ($c =~ /\n/gs); |
2184 | my $cond_lines = 1 + $#newlines; | 2184 | my $cond_lines = 1 + $#newlines; |
2185 | my $stat_real = ''; | ||
2185 | 2186 | ||
2186 | my $stat_real = raw_line($linenr, $cond_lines); | 2187 | $stat_real = raw_line($linenr, $cond_lines) |
2188 | . "\n" if ($cond_lines); | ||
2187 | if (defined($stat_real) && $cond_lines > 1) { | 2189 | if (defined($stat_real) && $cond_lines > 1) { |
2188 | $stat_real = "[...]\n$stat_real"; | 2190 | $stat_real = "[...]\n$stat_real"; |
2189 | } | 2191 | } |