* [PATCH] checkpatch: trivial fix for trailing statements check
@ 2009-10-26 5:26 Hidetoshi Seto
0 siblings, 0 replies; only message in thread
From: Hidetoshi Seto @ 2009-10-26 5:26 UTC (permalink / raw)
To: linux-kernel; +Cc: Andy Whitcroft, Andrew Morton
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>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
scripts/checkpatch.pl | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 87bbb8b..60a8f99 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2144,8 +2144,10 @@ sub process {
# Find out how long the conditional actually is.
my @newlines = ($c =~ /\n/gs);
my $cond_lines = 1 + $#newlines;
+ my $stat_real = '';
- my $stat_real = raw_line($linenr, $cond_lines);
+ $stat_real = raw_line($linenr, $cond_lines)
+ . "\n" if ($cond_lines);
if (defined($stat_real) && $cond_lines > 1) {
$stat_real = "[...]\n$stat_real";
}
--
1.6.4.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2009-10-26 5:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-26 5:26 [PATCH] checkpatch: trivial fix for trailing statements check Hidetoshi Seto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox