summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Whitcroft <apw@shadowen.org>2008-10-16 07:02:28 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-16 20:21:36 +0200
commit306708547b566ef6a0ccd470c84568807571885c (patch)
tree028c2ab4d3abefe272cf6ad02e11f10474d0b667
parentcheckpatch: suspect indent count condition lines correctly (diff)
downloadlinux-306708547b566ef6a0ccd470c84568807571885c.tar.xz
linux-306708547b566ef6a0ccd470c84568807571885c.zip
checkpatch: ensure we only apply checks to the lines within hunks
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> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rwxr-xr-xscripts/checkpatch.pl5
1 files changed, 3 insertions, 2 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2e513fdf3043..fe4553c070b1 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/) {