lint/checkpatch: Update 'Check patch "separator" and "signoff"'

This reduce the difference with linux v5.19-rc7.

Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Change-Id: Id3d7375216af5bf75ed7ce61fa8ea2dfebe8ac77
Reviewed-on: https://review.coreboot.org/c/coreboot/+/65834
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin L Roth <gaumless@tutanota.com>
This commit is contained in:
Elyes Haouas 2022-07-13 17:35:43 +02:00 committed by Martin L Roth
parent cb346842ad
commit 6e84c2ca70
1 changed files with 69 additions and 4 deletions

View File

@ -2446,6 +2446,9 @@ sub process {
our $clean = 1; our $clean = 1;
my $signoff = 0; my $signoff = 0;
my $author = '';
my $authorsignoff = 0;
my $author_sob = '';
my $is_patch = 0; my $is_patch = 0;
my $in_header_lines = $file ? 0 : 1; my $in_header_lines = $file ? 0 : 1;
my $in_commit_log = 0; #Scanning lines before patch my $in_commit_log = 0; #Scanning lines before patch
@ -2742,9 +2745,42 @@ sub process {
} }
# Check the patch for a signoff: # Check the patch for a signoff:
if ($line =~ /^\s*signed-off-by:/i) { if ($line =~ /^\s*signed-off-by:\s*(.*)/i) {
$signoff++; $signoff++;
$in_commit_log = 0; $in_commit_log = 0;
if ($author ne '' && $authorsignoff != 1) {
if (same_email_addresses($1, $author)) {
$authorsignoff = 1;
} else {
my $ctx = $1;
my ($email_name, $email_comment, $email_address, $comment1) = parse_email($ctx);
my ($author_name, $author_comment, $author_address, $comment2) = parse_email($author);
if (lc $email_address eq lc $author_address && $email_name eq $author_name) {
$author_sob = $ctx;
$authorsignoff = 2;
} elsif (lc $email_address eq lc $author_address) {
$author_sob = $ctx;
$authorsignoff = 3;
} elsif ($email_name eq $author_name) {
$author_sob = $ctx;
$authorsignoff = 4;
my $address1 = $email_address;
my $address2 = $author_address;
if ($address1 =~ /(\S+)\+\S+(\@.*)/) {
$address1 = "$1$2";
}
if ($address2 =~ /(\S+)\+\S+(\@.*)/) {
$address2 = "$1$2";
}
if ($address1 eq $address2) {
$authorsignoff = 5;
}
}
}
}
} }
# Check for patch separator # Check for patch separator
@ -6934,9 +6970,38 @@ sub process {
ERROR("NOT_UNIFIED_DIFF", ERROR("NOT_UNIFIED_DIFF",
"Does not appear to be a unified-diff format patch\n"); "Does not appear to be a unified-diff format patch\n");
} }
if ($is_patch && $has_commit_log && $chk_signoff && $signoff == 0) { if ($is_patch && $has_commit_log && $chk_signoff) {
if ($signoff == 0) {
ERROR("MISSING_SIGN_OFF", ERROR("MISSING_SIGN_OFF",
"Missing Signed-off-by: line(s)\n"); "Missing Signed-off-by: line(s)\n");
} elsif ($authorsignoff != 1) {
# authorsignoff values:
# 0 -> missing sign off
# 1 -> sign off identical
# 2 -> names and addresses match, comments mismatch
# 3 -> addresses match, names different
# 4 -> names match, addresses different
# 5 -> names match, addresses excluding subaddress details (refer RFC 5233) match
my $sob_msg = "'From: $author' != 'Signed-off-by: $author_sob'";
if ($authorsignoff == 0) {
ERROR("NO_AUTHOR_SIGN_OFF",
"Missing Signed-off-by: line by nominal patch author '$author'\n");
} elsif ($authorsignoff == 2) {
CHK("FROM_SIGN_OFF_MISMATCH",
"From:/Signed-off-by: email comments mismatch: $sob_msg\n");
} elsif ($authorsignoff == 3) {
WARN("FROM_SIGN_OFF_MISMATCH",
"From:/Signed-off-by: email name mismatch: $sob_msg\n");
} elsif ($authorsignoff == 4) {
WARN("FROM_SIGN_OFF_MISMATCH",
"From:/Signed-off-by: email address mismatch: $sob_msg\n");
} elsif ($authorsignoff == 5) {
WARN("FROM_SIGN_OFF_MISMATCH",
"From:/Signed-off-by: email subaddress mismatch: $sob_msg\n");
}
}
} }
print report_dump(); print report_dump();