Re: [PATCH] checkpatch: Warn when a patch doesn't have a description

From: Andrew Morton
Date: Thu Jul 26 2018 - 18:09:01 EST


On Wed, 25 Jul 2018 19:22:47 -0700 Joe Perches <joe@xxxxxxxxxxx> wrote:

> Potential patches should have a commit description.
> Emit a warning when there isn't one.
>
> ...
>
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2240,6 +2240,7 @@ sub process {
> my $in_header_lines = $file ? 0 : 1;
> my $in_commit_log = 0; #Scanning lines before patch
> my $has_commit_log = 0; #Encountered lines before patch
> + my $commit_log_lines = 0; #Number of commit log lines
> my $commit_log_possible_stack_dump = 0;
> my $commit_log_long_line = 0;
> my $commit_log_has_diff = 0;
> @@ -2497,6 +2498,18 @@ sub process {
>
> $cnt_lines++ if ($realcnt != 0);
>
> +# Verify the existence of a commit log if appropriate
> +# 2 is used because a $signature is counted in $commit_log_lines
> + if ($in_commit_log) {
> + if ($line !~ /^\s*$/) {
> + $commit_log_lines++; #could be a $signature
> + }
> + } else if ($has_commit_log && $commit_log_lines < 2) {
> + WARN("COMMIT_MESSAGE",
> + "Missing commit description - Add an appropriate one\n");
> + $commit_log_lines = 2; #warn only once
> + }
> +
> # Check if the commit log has what seems like a diff which can confuse patch
> if ($in_commit_log && !$commit_log_has_diff &&
> (($line =~ m@^\s+diff\b.*a/[\w/]+@ &&

This explodes all over the place.

Variable "$clean" is not imported at scripts/checkpatch.pl line 6565.
Variable "$clean" is not imported at scripts/checkpatch.pl line 6590.
Variable "$cnt_error" is not imported at scripts/checkpatch.pl line 6592.
Variable "$cnt_warn" is not imported at scripts/checkpatch.pl line 6592.
Variable "$cnt_chk" is not imported at scripts/checkpatch.pl line 6593.
Variable "$cnt_lines" is not imported at scripts/checkpatch.pl line 6594.
Variable "$clean" is not imported at scripts/checkpatch.pl line 6599.
Variable "$clean" is not imported at scripts/checkpatch.pl line 6618.
Variable "$clean" is not imported at scripts/checkpatch.pl line 6659.
Variable "$clean" is not imported at scripts/checkpatch.pl line 6665.
syntax error at scripts/checkpatch.pl line 2520, near "else if"
Global symbol "$herecurr" requires explicit package name (did you forget to declare "my $herecurr"?) at scripts/checkpatch.pl line 2533.
Global symbol "$herecurr" requires explicit package name (did you forget to declare "my $herecurr"?) at scripts/checkpatch.pl line 2584.
Global symbol "$herecurr" requires explicit package name (did you forget to declare "my $herecurr"?) at scripts/checkpatch.pl line 2588.
etc

I did this:

--- a/scripts/checkpatch.pl~checkpatch-warn-when-a-patch-doesnt-have-a-description-fix
+++ a/scripts/checkpatch.pl
@@ -2517,7 +2517,7 @@ sub process {
if ($line !~ /^\s*$/) {
$commit_log_lines++; #could be a $signature
}
- } else if ($has_commit_log && $commit_log_lines < 2) {
+ } elsif ($has_commit_log && $commit_log_lines < 2) {
WARN("COMMIT_MESSAGE",
"Missing commit description - Add an appropriate one\n");
$commit_log_lines = 2; #warn only once

But I worry that you didn't send out the version which you tested, so
please check.