Skip to contentSkip to conversation

checkpatch: add new warnings to author signoff checks.

RFC PATCH In review Dwaipayan Ray 3 participants 6 messages Oct 5, 2020 2 messages not in the archive Checkpatch

lore
Share & tools
lore
#0 lore raw

RFC 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 | 57 ++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 53 insertions(+), 4 deletions(-)
scripts/checkpatch.pl +53 -4
index 31624bbb342e..80feb15f93cb 100755
@@ -2347,6 +2347,7 @@ sub process {
 	my $signoff = 0;
 	my $author = '';
 	my $authorsignoff = 0;
+	my $authorsignoff_ctx = '';
 	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) {
+						$authorsignoff_ctx = $ctx;
+						$authorsignoff = 2;
+					} elsif ($email_name eq $author_name) {
+						$authorsignoff_ctx = $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,32 @@ 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 present
+			# 2 -> address matches, name different
+			# 3 -> name matches, address different
+			# 4 -> name matches, address matches without extension
+
+			my $ctx_msg = "'Signed-off-by: $authorsignoff_ctx' should be:\n'Signed-off-by: $author'";
+
+			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",
+					"Author name mismatch:\n$ctx_msg\n");
+			}
+			elsif($authorsignoff == 3) {
+				WARN("NO_AUTHOR_SIGN_OFF",
+					"Author address mismatch:\n$ctx_msg\n");
+			}
+			elsif($authorsignoff == 4) {
+				CHK("NO_AUTHOR_SIGN_OFF",
+					"Author mail extension mismatch:\n$ctx_msg\n");
+			}
 		}
 	}
 
Signature · 6 lines
2.27.0

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

Quoted 8 lines

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.

I don't have any issue with the concept, but please be consistent with spacing after if tests.

Always use a single space after if

scripts/checkpatch.pl sub process { · line 2350

Quoted 7 lines
scripts/checkpatch.pl +1 -0
@@ -2347,6 +2347,7 @@ sub process {
 	my $signoff = 0;
 	my $author = '';
 	my $authorsignoff = 0;
+	my $authorsignoff_ctx = '';

ctx isn't a descriptive name.

Maybe $author_sob

scripts/checkpatch.pl sub process { · line 2678

Quoted 6 lines
scripts/checkpatch.pl +1 -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) {

Has space after if

scripts/checkpatch.pl sub process { · line 2686

Quoted 8 lines
scripts/checkpatch.pl +6 -0
 				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) {

No space after if, etc...

scripts/checkpatch.pl sub process { · line 6923

Quoted 11 lines
scripts/checkpatch.pl +4 -3
@@ -6891,9 +6917,32 @@ 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 present

sign off identical

scripts/checkpatch.pl sub process { · line 6926

Quoted 3 lines
scripts/checkpatch.pl +3 -0
+			# 2 -> address matches, name different
+			# 3 -> name matches, address different
+			# 4 -> name matches, address matches without extension

extension here isn't obvious

scripts/checkpatch.pl sub process { · line 6928

Quoted 2 lines
scripts/checkpatch.pl +2 -0
+
+			my $ctx_msg = "'Signed-off-by: $authorsignoff_ctx' should be:\n'Signed-off-by: $author'";

New line not necessary or useful really.

And for mismatches, it's really not known that
it should be one way or the or the other is it?

Quoted 20 lines
scripts/checkpatch.pl +17 -0
+
+			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",
+					"Author name mismatch:\n$ctx_msg\n");
+			}
+			elsif($authorsignoff == 3) {
+				WARN("NO_AUTHOR_SIGN_OFF",
+					"Author address mismatch:\n$ctx_msg\n");
+			}
+			elsif($authorsignoff == 4) {
+				CHK("NO_AUTHOR_SIGN_OFF",
+					"Author mail extension mismatch:\n$ctx_msg\n");
+			}
 		}
 	}
 
#2 lore raw
Quoted 30 lines · Joe Perches
Quoted 28 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]>"

Quoted 8 lines
Quoted 2 lines

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

I don't have any issue with the concept, but please be consistent with spacing after if tests.

Always use a single space after if

Okay sure I will take care of that.

Quoted 11 lines

scripts/checkpatch.pl sub process { · line 2350

Quoted 7 lines
scripts/checkpatch.pl +1 -0
@@ -2347,6 +2347,7 @@ sub process {
      my $signoff = 0;
      my $author = '';
      my $authorsignoff = 0;
+     my $authorsignoff_ctx = '';

ctx isn't a descriptive name.

Maybe $author_sob

Yes that's more illustrative. I will change that.

Quoted 35 lines

scripts/checkpatch.pl sub process { · line 2678

Quoted 7 lines
scripts/checkpatch.pl +1 -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) {

Has space after if

scripts/checkpatch.pl sub process { · line 2686

Quoted 8 lines
scripts/checkpatch.pl +6 -0
                              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) {

No space after if, etc...

scripts/checkpatch.pl sub process { · line 6923

Quoted 11 lines
scripts/checkpatch.pl +4 -3
@@ -6891,9 +6917,32 @@ 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 present

sign off identical

Quoted 5 lines

scripts/checkpatch.pl sub process { · line 6926

Quoted 3 lines
scripts/checkpatch.pl +3 -0
+                     # 2 -> address matches, name different
+                     # 3 -> name matches, address different
+                     # 4 -> name matches, address matches without extension

extension here isn't obvious

Yeah I was thinking of that. I was a bit confused about the message. Will it be better as "address excluding mail extensions matches"?

Quoted 9 lines

scripts/checkpatch.pl sub process { · line 6928

Quoted 3 lines
scripts/checkpatch.pl +2 -0
+
+                     my $ctx_msg = "'Signed-off-by: $authorsignoff_ctx' should be:\n'Signed-off-by: $author'";

New line not necessary or useful really.

And for mismatches, it's really not known that
it should be one way or the or the other is it?

I think that's true. But since the mail in the
From: part is the one which with others are being
compared, I think maybe it should have the higher
priority, and be treated as the expected one.

Otherwise I could change the message accordingly.

Quoted 12 lines
Quoted 12 lines
scripts/checkpatch.pl +12 -0
+
+                     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",
+                                     "Author name mismatch:\n$ctx_msg\n");
+                     }
+                     elsif($authorsignoff == 3) {
+                             WARN("NO_AUTHOR_SIGN_OFF",
+                                     "Author address mismatch:\n$ctx_msg\n");
Quoted 9 lines

scripts/checkpatch.pl sub process { · line 6948

Quoted 8 lines
scripts/checkpatch.pl +5 -0
+                     }
+                     elsif($authorsignoff == 4) {
+                             CHK("NO_AUTHOR_SIGN_OFF",
+                                     "Author mail extension mismatch:\n$ctx_msg\n");
+                     }
              }
      }
 

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

maintainer
#3 lore raw
Quoted 4 lines · Dwaipayan Ray
Quoted 3 lines · Joe Perches
Quoted 2 lines · Dwaipayan Ray

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

[]

Quoted 8 lines
Quoted 3 lines

And for mismatches, it's really not known that
it should be one way or the or the other is it?

I think that's true. But since the mail in the
From: part is the one which with others are being compared, I think maybe it should have the higher priority, and be treated as the expected one.

I rather expect it to be the other way around.

The Signed-off-by: line should be authoritative
as that is what is put in the commit log.

A message that is not in the archive (sent off-list or not yet received): CABJPP5CAY+qJU8wnGZ7JgugeN9CyFbdct6nAsxpY0NdyaNuWLQ@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 35 lines · Joe Perches
Quoted 22 lines · Dwaipayan Ray
Quoted 15 lines · Joe Perches
Quoted 4 lines · Dwaipayan Ray
Quoted 3 lines · Joe Perches
Quoted 2 lines · Dwaipayan Ray

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

[]

Quoted 8 lines
Quoted 3 lines

And for mismatches, it's really not known that
it should be one way or the or the other is it?

I think that's true. But since the mail in the
From: part is the one which with others are being compared, I think maybe it should have the higher priority, and be treated as the expected one.

Quoted 6 lines

I rather expect it to be the other way around.

The Signed-off-by: line should be authoritative
as that is what is put in the commit log.

Quoted 5 lines

Yes that makes sense. So is it just better to point at the difference?
Like:
Author email in From: (something) differs from
Signed-off-by: (something2).

I think so yes.

That's what I suggested when I replied to you
with your first attempt.

Quoted 7 lines

https://lore.kernel.org/lkml/[email protected]/

                        WARN("NO_AUTHOR_SIGN_OFF",
                             "From:/SoB: email address mismatch: 'From: $author' != 'Signed-off-by: $authorsignoff'\n");

And please keep replies on list.

Yes sure, I missed to cc the list.

I will fix the issues and get back to you with a new patch.

Thanks,
Dwaipayan.

#7 lore raw
In reply to Dwaipayan Ray
Quoted 22 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]>"

Quoted 9 lines

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.

I will start running an evaluation on checkpatch.pl before and after this patch to get some insight on this change.

Quoted 64 lines
---
 scripts/checkpatch.pl | 57 ++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 53 insertions(+), 4 deletions(-)
scripts/checkpatch.pl +31 -4
index 31624bbb342e..80feb15f93cb 100755
@@ -2347,6 +2347,7 @@ sub process {
 	my $signoff = 0;
 	my $author = '';
 	my $authorsignoff = 0;
+	my $authorsignoff_ctx = '';
 	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) {
+						$authorsignoff_ctx = $ctx;
+						$authorsignoff = 2;
+					} elsif ($email_name eq $author_name) {
+						$authorsignoff_ctx = $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,32 @@ 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 present

scripts/checkpatch.pl sub process { · line 6933

Quoted 10 lines
scripts/checkpatch.pl +10 -0
+			# 2 -> address matches, name different
+			# 3 -> name matches, address different
+			# 4 -> name matches, address matches without extension
+
+			my $ctx_msg = "'Signed-off-by: $authorsignoff_ctx' should be:\n'Signed-off-by: $author'";
+
+			if($authorsignoff == 0) {
+				WARN("NO_AUTHOR_SIGN_OFF",
+					"Missing Signed-off-by: line by nominal patch author '$author'\n");
+			}

I think in this case, we could actually turn this into an ERROR; now that we have the refined cases (2,3,4) on which we would just warn or 'note' with --strict checks.

Lukas

Quoted 19 lines
scripts/checkpatch.pl +12 -0
+			elsif($authorsignoff == 2) {
+				WARN("NO_AUTHOR_SIGN_OFF",
+					"Author name mismatch:\n$ctx_msg\n");
+			}
+			elsif($authorsignoff == 3) {
+				WARN("NO_AUTHOR_SIGN_OFF",
+					"Author address mismatch:\n$ctx_msg\n");
+			}
+			elsif($authorsignoff == 4) {
+				CHK("NO_AUTHOR_SIGN_OFF",
+					"Author mail extension mismatch:\n$ctx_msg\n");
+			}
 		}
 	}
 
Signature · 1 line
2.27.0