diff options
author | Andy Whitcroft <apw@shadowen.org> | 2008-07-24 00:29:01 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-24 13:47:25 -0400 |
commit | 548596d523d83dff5a670beb84be0daf4c3bcd16 (patch) | |
tree | ad5e7bad318a2d986f7cd3d8e540e1c240610dfe /scripts/checkpatch.pl | |
parent | a3bb97a7aba36055d476896ed6393ab35a119d5b (diff) |
checkpatch: trailing statement indent: fix end of statement location
Fix end of statement location. Where the last line of the statement is
replaced we are miss reporting the newly added replacement an incorrectly
indented trailing statement for the negative context. We are also
incorrectly reporting negative statements generally.
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/checkpatch.pl')
-rwxr-xr-x | scripts/checkpatch.pl | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index add86862325b..89177c349f93 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -1249,17 +1249,22 @@ sub process { | |||
1249 | my $pre_ctx = "$1$2"; | 1249 | my $pre_ctx = "$1$2"; |
1250 | 1250 | ||
1251 | my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0); | 1251 | my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0); |
1252 | my $ctx_ln = $linenr + $#ctx + 1; | ||
1253 | my $ctx_cnt = $realcnt - $#ctx - 1; | 1252 | my $ctx_cnt = $realcnt - $#ctx - 1; |
1254 | my $ctx = join("\n", @ctx); | 1253 | my $ctx = join("\n", @ctx); |
1255 | 1254 | ||
1256 | ##warn "realcnt<$realcnt> ctx_cnt<$ctx_cnt>\n"; | 1255 | my $ctx_ln = $linenr; |
1256 | my $ctx_skip = $realcnt; | ||
1257 | 1257 | ||
1258 | # Skip over any removed lines in the context following statement. | 1258 | while ($ctx_skip > $ctx_cnt || ($ctx_skip == $ctx_cnt && |
1259 | while (defined($lines[$ctx_ln - 1]) && $lines[$ctx_ln - 1] =~ /^-/) { | 1259 | defined $lines[$ctx_ln - 1] && |
1260 | $lines[$ctx_ln - 1] =~ /^-/)) { | ||
1261 | ##print "SKIP<$ctx_skip> CNT<$ctx_cnt>\n"; | ||
1262 | $ctx_skip-- if (!defined $lines[$ctx_ln - 1] || $lines[$ctx_ln - 1] !~ /^-/); | ||
1260 | $ctx_ln++; | 1263 | $ctx_ln++; |
1261 | } | 1264 | } |
1262 | ##warn "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n"; | 1265 | |
1266 | ##print "realcnt<$realcnt> ctx_cnt<$ctx_cnt>\n"; | ||
1267 | ##print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n"; | ||
1263 | 1268 | ||
1264 | if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln -1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) { | 1269 | if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln -1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) { |
1265 | ERROR("that open brace { should be on the previous line\n" . | 1270 | ERROR("that open brace { should be on the previous line\n" . |