Re: [PATCH] checkpatch: check for missing Fixes tags

From: Joe Perches
Date: Tue Jun 06 2023 - 11:11:16 EST


On Tue, 2023-06-06 at 11:30 +0300, Dan Carpenter wrote:
> This check looks for common words that probably indicate a patch
> is a fix. For now the regex is:
>
> (BUG: KASAN|Call Trace:|syzkaller|stable\@)

Seems sensible. Style notes:


> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -3186,6 +3192,12 @@ sub process {
> }
> }
>
> +# These indicate a bug fix
> + if (!$in_header_lines &&
> + $line =~ /(BUG: KASAN|Call Trace:|syzkaller|stable\@)/) {
> + $needs_fixes_tag++;

Align to open parenthesis please.
Maybe add "Closes:"
This should not check any actual patch lines.

So this should likely use

if (!$in_header_lines && !$is_patch &&
$line =~ /\b(?:BUG: KASAN|Call Trace:|Closes:|syzkaller|stable\@)/) {

There's no use of $needs_fixes_tag as something
other than a bool, so please just use

$needs_fixes_tag = 1;

> @@ -3198,6 +3210,7 @@ sub process {
> my $id_length = 1;
> my $id_case = 1;
> my $title_has_quotes = 0;
> + $fixes_tag++;

$fixes_tag = 1;

here too

> @@ -7636,6 +7649,12 @@ sub process {
> ERROR("NOT_UNIFIED_DIFF",
> "Does not appear to be a unified-diff format patch\n");
> }
> + if ($is_patch && $has_commit_log && $chk_fixes_tag) {
> + if ($needs_fixes_tag && $fixes_tag == 0) {

if ($needs_fixes_tag && !$fixes_tag) {

> + ERROR("MISSING_FIXES_TAG",
> + "This looks like a fix but there is no Fixes: tag\n");

Alignment to open parenthesis and likely WARN not ERROR