diff --git a/contrib/scripts/checkpatch.pl b/contrib/scripts/checkpatch.pl index f32fe2793..b78e3b8f1 100755 --- a/contrib/scripts/checkpatch.pl +++ b/contrib/scripts/checkpatch.pl @@ -57,6 +57,7 @@ our $check_line; # Complain if errors are found on this line our @functions_seen; our $type; our $filename; +our $line_no; sub new_hunk { @@ -74,22 +75,28 @@ sub complain my $message = shift; return unless $check_line; - warn "$ARGV:$.: $message:\n"; + warn "$filename:$line_no: $message:\n"; warn "> $line\n\n"; $seen_error = 1; } if ($is_patch) { # This is a line of an unified diff - /^@@/ and new_hunk; - if (/^\+\+\+ (.*)/) { - new_file ($1); + if (/^@@.*\+(\d+)/) { + $line_no = $1 - 1; + new_hunk; + next; + } + if (/^\+\+\+ (b\/)?(.*)/) { + new_file ($2); next; } /^([ \+])(.*)/ or next; + $line_no++; $check_line = $1 eq '+'; $line = $2; } elsif ($is_file) { + $line_no = $.; # This is a line from full C file $check_line = 1; $line = $_; @@ -129,11 +136,10 @@ if (/^typedef*/) { } elsif (/^[A-Za-z_][A-Za-z0-9_ ]*\*?$/ and /[a-z]/) { # A function type $type = $_; - #print "TYPE: >>> $line <<<\n"; next; } elsif ($type and /^([A-Za-z_][A-Za-z0-9_]*)(\s*)\(/) { - my @order = qw/^get_property$ ^set_property$ (? +=item B A F<.git/hooks/post-commit> oneliner that, wisely, tolerates failures while -still providing advice. +still providing advice. The large line context allows helps checkpatch.pl +get a better idea about the changes in context of code that does not change. =back