diff options
author | Andy Whitcroft <apw@shadowen.org> | 2008-10-16 01:02:28 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-16 14:21:36 -0400 |
commit | 306708547b566ef6a0ccd470c84568807571885c (patch) | |
tree | 028c2ab4d3abefe272cf6ad02e11f10474d0b667 /scripts/checkpatch.pl | |
parent | 6f779c18ca74358b6ac8eb8f5d502843fa92be4e (diff) |
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>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-x | scripts/checkpatch.pl | 5 |
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 { | |||
1128 | $linenr++; | 1128 | $linenr++; |
1129 | 1129 | ||
1130 | my $rawline = $rawlines[$linenr - 1]; | 1130 | my $rawline = $rawlines[$linenr - 1]; |
1131 | my $hunk_line = ($realcnt != 0); | ||
1131 | 1132 | ||
1132 | #extract the line range in the file after the patch is applied | 1133 | #extract the line range in the file after the patch is applied |
1133 | if ($line=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) { | 1134 | if ($line=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) { |
@@ -1238,8 +1239,8 @@ sub process { | |||
1238 | ERROR("Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr); | 1239 | ERROR("Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr); |
1239 | } | 1240 | } |
1240 | 1241 | ||
1241 | #ignore lines being removed | 1242 | # ignore non-hunk lines and lines being removed |
1242 | if ($line=~/^-/) {next;} | 1243 | next if (!$hunk_line || $line =~ /^-/); |
1243 | 1244 | ||
1244 | #trailing whitespace | 1245 | #trailing whitespace |
1245 | if ($line =~ /^\+.*\015/) { | 1246 | if ($line =~ /^\+.*\015/) { |