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 6/7] checkpatch: ensure we only apply checks to the lines within hunks
Date: Tue, 2 Sep 2008 18:25:13 +0100 [thread overview]
Message-ID: <1220376314-15180-7-git-send-email-apw@shadowen.org> (raw)
In-Reply-To: <1220376314-15180-1-git-send-email-apw@shadowen.org>
We should only apply source checks to lines within hunks. Checks which are
anchored in the context may falsly trigger in the commentory. Ensure they
only match within valid hunk lines.
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
scripts/checkpatch.pl | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2e513fd..fe4553c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1128,6 +1128,7 @@ sub process {
$linenr++;
my $rawline = $rawlines[$linenr - 1];
+ my $hunk_line = ($realcnt != 0);
#extract the line range in the file after the patch is applied
if ($line=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
@@ -1238,8 +1239,8 @@ sub process {
ERROR("Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr);
}
-#ignore lines being removed
- if ($line=~/^-/) {next;}
+# ignore non-hunk lines and lines being removed
+ next if (!$hunk_line || $line =~ /^-/);
#trailing whitespace
if ($line =~ /^\+.*\015/) {
--
1.6.0.rc1.258.g80295
next prev parent reply other threads:[~2008-09-02 17:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-02 17:25 [PATCH 0/7] checkpatch: update to version 0.23 Andy Whitcroft
2008-09-02 17:25 ` [PATCH 1/7] checkpatch: case/default checks should only check changed lines Andy Whitcroft
2008-09-02 17:25 ` [PATCH 2/7] checkpatch: suppress errors triggered by short patch Andy Whitcroft
2008-09-02 17:25 ` [PATCH 3/7] checkpatch: handle comment/quote nesting correctly Andy Whitcroft
2008-09-11 18:46 ` Jaswinder Singh
2008-09-02 17:25 ` [PATCH 4/7] checkpatch: check line endings in text format files Andy Whitcroft
2008-09-02 17:25 ` [PATCH 5/7] checkpatch: suspect indent count condition lines correctly Andy Whitcroft
2008-09-02 17:25 ` Andy Whitcroft [this message]
2008-09-02 17:25 ` [PATCH 7/7] checkpatch: version: 0.23 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=1220376314-15180-7-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®