Skip to contentSkip to conversation

checkpatch: add new warnings to author signoff checks.

PATCH Superseded Dwaipayan Ray 2 participants 5 messages Oct 6, 2020 Checkpatch

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 checkpatch: add new warnings to author signoff checks.

The author signed-off-by checks are currently very vague. Cases like same name or same address are not handled separately.

For example, running checkpatch on commit be6577af0cef ("parisc: Add atomic64_set_release() define to avoid CPU soft lockups"), gives:

WARNING: Missing Signed-off-by: line by nominal patch author 'John David Anglin <[email protected]>'

The signoff line was:
"Signed-off-by: Dave Anglin <[email protected]>"

Clearly the author has signed off but with a slightly different version of his name. A more appropriate warning would have been to point out at the name mismatch instead.

Previously, the values assumed by $authorsignoff were either 0 or 1 to indicate whether a proper sign off by author is present. Extended the checks to handle three new cases.

$authorsignoff values now denote the following:

0: Missing sign off by patch author.

1: Sign off present and identical.

2: Addresses match, but names are different.
"James Watson <[email protected]>", "James <[email protected]>"

3: Names match, but addresses are different.
"James Watson <[email protected]>", "James Watson <[email protected]>"

4: Names match, addresses excluding subaddress details (RFC 5233) match.
"James Watson <[email protected]>", "James Watson <[email protected]>"

For case 0, an error is generated and for the
other cases 2, 3 and 4, warnings are generated.

---
 scripts/checkpatch.pl | 54 +++++++++++++++++++++++++++++++++++++++----
 1 file changed, 50 insertions(+), 4 deletions(-)
scripts/checkpatch.pl +50 -4
index 31624bbb342e..e81f0bebbeb9 100755
@@ -2347,6 +2347,7 @@ sub process {
 	my $signoff = 0;
 	my $author = '';
 	my $authorsignoff = 0;
+	my $author_sob = '';
 	my $is_patch = 0;
 	my $is_binding_patch = -1;
 	my $in_header_lines = $file ? 0 : 1;
@@ -2674,9 +2675,34 @@ sub process {
 		if ($line =~ /^\s*signed-off-by:\s*(.*)/i) {
 			$signoff++;
 			$in_commit_log = 0;
-			if ($author ne '') {
+			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 ($email_address eq $author_address) {
+						$author_sob = $ctx;
+						$authorsignoff = 2;
+					} elsif ($email_name eq $author_name) {
+						$author_sob = $ctx;
+						$authorsignoff = 3;
+
+						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 = 4;
+						}
+					}
 				}
 			}
 		}
@@ -6891,9 +6917,29 @@ sub process {
 		if ($signoff == 0) {
 			ERROR("MISSING_SIGN_OFF",
 			      "Missing Signed-off-by: line(s)\n");
-		} elsif (!$authorsignoff) {
-			WARN("NO_AUTHOR_SIGN_OFF",
-			     "Missing Signed-off-by: line by nominal patch author '$author'\n");
+		} elsif ($authorsignoff != 1) {
+			# authorsignoff values:
+			# 0 -> missing sign off
+			# 1 -> sign off identical
+			# 2 -> addresses match, names different
+			# 3 -> names match, addresses different
+			# 4 -> 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) {
+				WARN("NO_AUTHOR_SIGN_OFF",
+				     "From:/Signed-off-by: email name mismatch: $sob_msg\n");
+			} elsif ($authorsignoff == 3) {
+				WARN("NO_AUTHOR_SIGN_OFF",
+				     "From:/Signed-off-by: email address mismatch: $sob_msg\n");
+			} elsif ($authorsignoff == 4) {
+				WARN("NO_AUTHOR_SIGN_OFF",
+				     "From:/Signed-off-by: email extension mismatch: $sob_msg\n");
+			}
 		}
 	}
 
Signature · 1 line
2.27.0
maintainer
#1 lore raw
Quoted 6 lines · Dwaipayan Ray

The author signed-off-by checks are currently very vague. Cases like same name or same address are not handled separately.

For example, running checkpatch on commit be6577af0cef ("parisc: Add atomic64_set_release() define to avoid CPU soft lockups"), gives:

Aren't you still missing emitting an message for cases like

From: "J. Random Developer" <[email protected]>

Where a comment does not match?

#2 lore raw
Quoted 9 lines · Joe Perches
Quoted 6 lines · Dwaipayan Ray

The author signed-off-by checks are currently very vague. Cases like same name or same address are not handled separately.

For example, running checkpatch on commit be6577af0cef ("parisc: Add atomic64_set_release() define to avoid CPU soft lockups"), gives:

Quoted 9 lines

Aren't you still missing emitting an message for cases like

From: "J. Random Developer" <[email protected]>

Where a comment does not match?

Yes, messages for comments were not emitted previously too cause the same_email_address() function just matches name and email (discarding name comments and email comments).

So should I add it to this patch, or should I work on it in a different patch perhaps because it involves change on another subroutine?

Thanks,
Dwaipayan.

maintainer
#3 lore raw
Quoted 19 lines · Dwaipayan Ray
Quoted 8 lines · Joe Perches
Quoted 6 lines · Dwaipayan Ray

The author signed-off-by checks are currently very vague. Cases like same name or same address are not handled separately.

For example, running checkpatch on commit be6577af0cef ("parisc: Add atomic64_set_release() define to avoid CPU soft lockups"), gives:

Quoted 9 lines

Aren't you still missing emitting an message for cases like

From: "J. Random Developer" <[email protected]>

Where a comment does not match?

Quoted 6 lines

Yes, messages for comments were not emitted previously too cause the same_email_address() function just matches name and email (discarding name comments and email comments).

So should I add it to this patch, or should I work on it in a different patch perhaps because it involves change on another subroutine?

I suggest adding it to this patch.

maintainer
#4 lore raw
Quoted 1 line · Joe Perches

I suggest adding it to this patch.

as a --strict CHK as it's not an actual defect in addressing just a trivial difference in formatting.