Skip to content

Commit cd26149

Browse files
geertutorvalds
authored andcommitted
checkpatch: warn if missing author Signed-off-by
Print a warning if none of the Signed-off-by lines cover the patch author. Non-ASCII quoted printable encoding in From: headers and (lack of) double quotes are handled. Split From: headers are not fully handled: only the first part is compared. [[email protected]: only encode UTF-8 quoted printable mail headers] Link: http://lkml.kernel.org/r/[email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Geert Uytterhoeven <[email protected]> Acked-by: Joe Perches <[email protected]> Acked-by: Linus Walleij <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 33aa459 commit cd26149

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

scripts/checkpatch.pl

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use File::Basename;
1414
use Cwd 'abs_path';
1515
use Term::ANSIColor qw(:constants);
16+
use Encode qw(decode encode);
1617

1718
my $P = $0;
1819
my $D = dirname(abs_path($P));
@@ -2236,6 +2237,8 @@ sub process {
22362237

22372238
our $clean = 1;
22382239
my $signoff = 0;
2240+
my $author = '';
2241+
my $authorsignoff = 0;
22392242
my $is_patch = 0;
22402243
my $in_header_lines = $file ? 0 : 1;
22412244
my $in_commit_log = 0; #Scanning lines before patch
@@ -2518,10 +2521,24 @@ sub process {
25182521
}
25192522
}
25202523

2524+
# Check the patch for a From:
2525+
if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
2526+
$author = $1;
2527+
$author = encode("utf8", $author) if ($line =~ /=\?utf-8\?/i);
2528+
$author =~ s/"//g;
2529+
}
2530+
25212531
# Check the patch for a signoff:
25222532
if ($line =~ /^\s*signed-off-by:/i) {
25232533
$signoff++;
25242534
$in_commit_log = 0;
2535+
if ($author ne '') {
2536+
my $l = $line;
2537+
$l =~ s/"//g;
2538+
if ($l =~ /^\s*signed-off-by:\s*\Q$author\E/i) {
2539+
$authorsignoff = 1;
2540+
}
2541+
}
25252542
}
25262543

25272544
# Check if MAINTAINERS is being updated. If so, there's probably no need to
@@ -6507,9 +6524,14 @@ sub process {
65076524
ERROR("NOT_UNIFIED_DIFF",
65086525
"Does not appear to be a unified-diff format patch\n");
65096526
}
6510-
if ($is_patch && $has_commit_log && $chk_signoff && $signoff == 0) {
6511-
ERROR("MISSING_SIGN_OFF",
6512-
"Missing Signed-off-by: line(s)\n");
6527+
if ($is_patch && $has_commit_log && $chk_signoff) {
6528+
if ($signoff == 0) {
6529+
ERROR("MISSING_SIGN_OFF",
6530+
"Missing Signed-off-by: line(s)\n");
6531+
} elsif (!$authorsignoff) {
6532+
WARN("NO_AUTHOR_SIGN_OFF",
6533+
"Missing Signed-off-by: line by nominal patch author '$author'\n");
6534+
}
65136535
}
65146536

65156537
print report_dump();

0 commit comments

Comments
 (0)