All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scripts/checkpatch: warn on duplicate trailers and self-review
@ 2026-07-27 16:11 marcandre.lureau
  2026-08-20 12:42 ` Marc-André Lureau
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: marcandre.lureau @ 2026-07-27 16:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, chao.liu, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Detect two common trailer mistakes:

- Duplicate trailers: any trailer (Signed-off-by, Fixes, Resolves,
  Cc, etc.) appearing more than once with the same value in a commit
  message.

- Self-review: a Reviewed-by, Tested-by, or Acked-by tag from the
  same person as the patch author, which provides no independent
  review value.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 scripts/checkpatch.pl | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 03f35e75012c..a9326297d626 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1539,6 +1539,8 @@ sub process {
 
 	our $clean = 1;
 	my $signoff = 0;
+	my $author_email = '';
+	my %commit_trailers = ();
 	my $is_patch = 0;
 
 	my $in_header_lines = $file ? 0 : 1;
@@ -1795,6 +1797,14 @@ sub process {
 		    ERROR("Author email address is mangled by the mailing list\n" . $herecurr);
 		}
 
+# Extract author email for trailer checks
+		if ($in_header_lines && $line =~ /^(?:Author|From):\s*(.*)/) {
+			my $author_info = $1;
+			if ($author_info =~ /<([^>]+)>/) {
+				$author_email = $1;
+			}
+		}
+
 #check the patch for a signoff:
 		if ($line =~ /^\s*signed-off-by:/i) {
 			# This is a signoff, if ugly, so do not double report.
@@ -1811,6 +1821,28 @@ sub process {
 			}
 		}
 
+# Check for duplicate trailers and self-review
+		if (!$in_header_lines &&
+		    $line =~ /^\s*([A-Z][a-zA-Z]*(?:-[a-zA-Z]+)*):\s*(.+)/) {
+			my $trailer_type = $1;
+			my $trailer_value = $2;
+			$trailer_value =~ s/\s+$//;
+			my $trailer_key = lc("$trailer_type: $trailer_value");
+
+			if (exists $commit_trailers{$trailer_key}) {
+				WARN("Duplicate '$trailer_type' trailer\n" .
+					$herecurr);
+			}
+			$commit_trailers{$trailer_key} = 1;
+
+			if ($trailer_type =~ /^(?:Reviewed|Tested|Acked)-by$/ &&
+			    $author_email ne '' &&
+			    $trailer_value =~ /<\Q$author_email\E>/i) {
+				WARN("$trailer_type from the patch author\n" .
+					$herecurr);
+			}
+		}
+
 # Check SPDX-License-Identifier references a permitted license
 		if (($rawline =~ m,SPDX-License-Identifier: (.*?)(\*/)?\s*$,) &&
 			$rawline !~ /^-/) {
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-03 12:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-27 16:11 [PATCH] scripts/checkpatch: warn on duplicate trailers and self-review marcandre.lureau
2026-08-20 12:42 ` Marc-André Lureau
2026-09-03 12:01 ` Daniel P. Berrangé
2026-09-03 12:01 ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.