Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 30670854 authored by Andy Whitcroft's avatar Andy Whitcroft Committed by Linus Torvalds
Browse files

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: default avatarAndy Whitcroft <apw@shadowen.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 6f779c18
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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/) {