From: Andy Whitcroft <apw@shadowen.org>
To: Andrew Morton <akpm@osdl.org>
Cc: Randy Dunlap <rdunlap@xenotime.net>,
Joel Schopp <jschopp@austin.ibm.com>, Ingo Molnar <mingo@elte.hu>,
linux-kernel@vger.kernel.org, Andy Whitcroft <apw@shadowen.org>
Subject: [PATCH 09/23] checkpatch: trailing statement indent: fix end of statement location
Date: Thu, 12 Jun 2008 13:05:48 +0100 [thread overview]
Message-ID: <1213272362-19457-10-git-send-email-apw@shadowen.org> (raw)
In-Reply-To: <1213272362-19457-1-git-send-email-apw@shadowen.org>
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>
---
scripts/checkpatch.pl | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index add8686..89177c3 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1249,17 +1249,22 @@ sub process {
my $pre_ctx = "$1$2";
my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0);
- my $ctx_ln = $linenr + $#ctx + 1;
my $ctx_cnt = $realcnt - $#ctx - 1;
my $ctx = join("\n", @ctx);
- ##warn "realcnt<$realcnt> ctx_cnt<$ctx_cnt>\n";
+ my $ctx_ln = $linenr;
+ my $ctx_skip = $realcnt;
- # Skip over any removed lines in the context following statement.
- while (defined($lines[$ctx_ln - 1]) && $lines[$ctx_ln - 1] =~ /^-/) {
+ while ($ctx_skip > $ctx_cnt || ($ctx_skip == $ctx_cnt &&
+ defined $lines[$ctx_ln - 1] &&
+ $lines[$ctx_ln - 1] =~ /^-/)) {
+ ##print "SKIP<$ctx_skip> CNT<$ctx_cnt>\n";
+ $ctx_skip-- if (!defined $lines[$ctx_ln - 1] || $lines[$ctx_ln - 1] !~ /^-/);
$ctx_ln++;
}
- ##warn "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n";
+
+ ##print "realcnt<$realcnt> ctx_cnt<$ctx_cnt>\n";
+ ##print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n";
if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln -1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) {
ERROR("that open brace { should be on the previous line\n" .
--
1.5.6.rc0.140.ga9675
next prev parent reply other threads:[~2008-06-12 12:07 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-12 12:05 update checkpatch to version 0.20 Andy Whitcroft
2008-06-12 12:05 ` [PATCH 01/23] checkpatch: Version: 0.20 Andy Whitcroft
2008-06-12 12:05 ` [PATCH 02/23] checkpatch: return is not a function -- parentheses for casts are ok too Andy Whitcroft
2008-06-12 12:05 ` [PATCH 03/23] checkpatch: types: some types may also be identifiers Andy Whitcroft
2008-06-12 12:05 ` [PATCH 04/23] checkpatch: add a checkpatch warning for new uses of __initcall() Andy Whitcroft
2008-06-12 12:05 ` [PATCH 05/23] checkpatch: possible types: __asm__ is never a type Andy Whitcroft
2008-06-12 12:05 ` [PATCH 06/23] checkpatch: comment detection: ignore macro continuation when detecting associated comments Andy Whitcroft
2008-06-12 12:05 ` [PATCH 07/23] checkpatch: types: unary -- goto introduces unary context Andy Whitcroft
2008-06-12 12:05 ` [PATCH 08/23] checkpatch: macros: fix statement counting block end detection Andy Whitcroft
2008-06-12 12:05 ` Andy Whitcroft [this message]
2008-06-12 12:05 ` [PATCH 10/23] checkpatch: allow printk strings to exceed 80 characters to maintain their searchability Andy Whitcroft
2008-06-12 12:05 ` [PATCH 11/23] checkpatch: switch -- report trailing statements on case and default Andy Whitcroft
2008-06-12 12:05 ` [PATCH 12/23] checkpatch: check spacing for square brackets Andy Whitcroft
2008-06-12 12:05 ` [PATCH 13/23] checkpatch: toughen trailing if statement checks and extend them to while and for Andy Whitcroft
2008-06-12 12:05 ` [PATCH 14/23] checkpatch: condition/loop indent checks Andy Whitcroft
2008-06-12 12:05 ` [PATCH 15/23] checkpatch: usb_free_urb() can take NULL Andy Whitcroft
2008-06-12 12:05 ` [PATCH 16/23] checkpatch: correct spelling in kfree checks Andy Whitcroft
2008-06-12 12:05 ` [PATCH 17/23] checkpatch: allow for type modifiers on multiple declarations Andy Whitcroft
2008-06-12 12:05 ` [PATCH 18/23] checkpatch: improve type matcher debug Andy Whitcroft
2008-06-12 12:05 ` [PATCH 19/23] checkpatch: possible modifiers are not being correctly matched Andy Whitcroft
2008-06-12 12:05 ` [PATCH 20/23] checkpatch: macro complexity checks are meaningless in linker scripts Andy Whitcroft
2008-06-12 12:06 ` [PATCH 21/23] checkpatch: handle return types of pointers to functions Andy Whitcroft
2008-06-12 12:06 ` [PATCH 22/23] checkpatch: possible types -- known modifiers cannot be types Andy Whitcroft
2008-06-12 12:06 ` [PATCH 23/23] checkpatch: possible modifiers -- handle multiple modifiers and trailing Andy Whitcroft
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1213272362-19457-10-git-send-email-apw@shadowen.org \
--to=apw@shadowen.org \
--cc=akpm@osdl.org \
--cc=jschopp@austin.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rdunlap@xenotime.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®