Skip to content

Commit

Permalink
checkpatch: ensure we only apply checks to the lines within hunks
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
awhitcroft authored and torvalds committed Oct 16, 2008
1 parent 6f779c1 commit 3067085
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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+))? \@\@/) {
Expand Down Expand Up @@ -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/) {
Expand Down

0 comments on commit 3067085

Please sign in to comment.