Skip to contentSkip to conversation

checkpatch: add new warnings to author signoff checks.

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

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

Introduced three new types of warnings:

1) Address matches, but names are different.
"James Watson <[email protected]>", "James <[email protected]>"

2) Name matches, but addresses are different.
"James Watson <[email protected]>", "James Watson <[email protected]>"

3) Name matches, but addresses without mail extensions are same. "James Watson <[email protected]>", "James Watson <[email protected]>"

For the 3rd class, a --strict check message is generated, and for the other two, warnings are generated.

---
 scripts/checkpatch.pl | 54 +++++++++++++++++++++++++++++++++++++++----
 1 file changed, 50 insertions(+), 4 deletions(-)
scripts/checkpatch.pl +50 -4
index 31624bbb342e..1380212f1a9d 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 excuding mail extensions (subaddresses) match
+
+			my $sob_msg = "'From: $author' != 'Signed-off-by: $author_sob'";
+
+			if ($authorsignoff == 0) {
+				WARN("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:\n$sob_msg\n");
+			} elsif ($authorsignoff == 3) {
+				WARN("NO_AUTHOR_SIGN_OFF",
+					 "From:/Signed-off-by: email address mismatch:\n$sob_msg\n");
+			} elsif ($authorsignoff == 4) {
+				CHK("NO_AUTHOR_SIGN_OFF",
+					"From:/Signed-off-by: email extension mismatch:\n$sob_msg\n");
+			}
 		}
 	}
 
Signature · 6 lines
2.27.0

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
#1 lore raw
Quoted 120 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:

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.

Introduced three new types of warnings:

1) Address matches, but names are different.
"James Watson <[email protected]>", "James <[email protected]>"

2) Name matches, but addresses are different.
"James Watson <[email protected]>", "James Watson <[email protected]>"

3) Name matches, but addresses without mail extensions are same. "James Watson <[email protected]>", "James Watson <[email protected]>"

For the 3rd class, a --strict check message is generated, and for the other two, warnings are generated.

---
 scripts/checkpatch.pl | 54 +++++++++++++++++++++++++++++++++++++++----
 1 file changed, 50 insertions(+), 4 deletions(-)
scripts/checkpatch.pl +50 -5
index 31624bbb342e..1380212f1a9d 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 excuding mail extensions (subaddresses) match
+
+                       my $sob_msg = "'From: $author' != 'Signed-off-by: $author_sob'";
+
+                       if ($authorsignoff == 0) {
+                               WARN("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:\n$sob_msg\n");
+                       } elsif ($authorsignoff == 3) {
+                               WARN("NO_AUTHOR_SIGN_OFF",
+                                        "From:/Signed-off-by: email address mismatch:\n$sob_msg\n");
+                       } elsif ($authorsignoff == 4) {
+                               CHK("NO_AUTHOR_SIGN_OFF",
+                                       "From:/Signed-off-by: email extension mismatch:\n$sob_msg\n");
+                       }
                }
        }
 
--
Quoted 2 lines

2.27.0

Hi Lukas,
This is the updated patch with some style changes, and Joe's suggestions.

Please let me know if I am missing something or if it is ready to be sent back again to Joe and LKML.

Thanks,
Dwaipayan.
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

#2 lore raw
In reply to Dwaipayan Ray
Quoted 19 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:

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.

Introduced three new types of warnings:

Quoted 9 lines

1) Address matches, but names are different.
"James Watson <[email protected]>", "James <[email protected]>"

2) Name matches, but addresses are different.
"James Watson <[email protected]>", "James Watson <[email protected]>"

3) Name matches, but addresses without mail extensions are same. "James Watson <[email protected]>", "James Watson <[email protected]>"

Make the numbers and cases match the return value and just add which were existent before this patch.

Looks good to me. Send it out to lkml for discussion.

I did not check the whitespace and tab issues, but I hope you got it now right.

Lukas

Quoted 94 lines

For the 3rd class, a --strict check message is generated, and for the other two, warnings are generated.

---
 scripts/checkpatch.pl | 54 +++++++++++++++++++++++++++++++++++++++----
 1 file changed, 50 insertions(+), 4 deletions(-)
scripts/checkpatch.pl +50 -4
index 31624bbb342e..1380212f1a9d 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 excuding mail extensions (subaddresses) match
+
+			my $sob_msg = "'From: $author' != 'Signed-off-by: $author_sob'";
+
+			if ($authorsignoff == 0) {
+				WARN("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:\n$sob_msg\n");
+			} elsif ($authorsignoff == 3) {
+				WARN("NO_AUTHOR_SIGN_OFF",
+					 "From:/Signed-off-by: email address mismatch:\n$sob_msg\n");
+			} elsif ($authorsignoff == 4) {
+				CHK("NO_AUTHOR_SIGN_OFF",
+					"From:/Signed-off-by: email extension mismatch:\n$sob_msg\n");
+			}
 		}
 	}
 
Signature · 1 line
2.27.0

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

#3 lore raw
Quoted 33 lines · Lukas Bulwahn
Quoted 19 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:

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.

Introduced three new types of warnings:

Quoted 9 lines

1) Address matches, but names are different.
"James Watson <[email protected]>", "James <[email protected]>"

2) Name matches, but addresses are different.
"James Watson <[email protected]>", "James Watson <[email protected]>"

3) Name matches, but addresses without mail extensions are same. "James Watson <[email protected]>", "James Watson <[email protected]>"

Quoted 8 lines

Make the numbers and cases match the return value and just add which were existent before this patch.

Looks good to me. Send it out to lkml for discussion.

I did not check the whitespace and tab issues, but I hope you got it now right.

Also, remember to change the subject line of the patch to PATCH v2.

Lukas
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees