From: Dwaipayan Ray <dwaipayanray1@gmail.com>
To: joe@perches.com
Cc: dwaipayanray1@gmail.com,
linux-kernel-mentees@lists.linuxfoundation.org,
linux-kernel@vger.kernel.org
Subject: [Linux-kernel-mentees] [PATCH v2] checkpatch: add new warnings to author signoff checks.
Date: Mon, 5 Oct 2020 23:09:33 +0530 [thread overview]
Message-ID: <20201005173933.171074-1-dwaipayanray1@gmail.com> (raw)
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 <dave.anglin@bell.net>'
The signoff line was:
"Signed-off-by: Dave Anglin <dave.anglin@bell.net>"
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 <james@gmail.com>", "James <james@gmail.com>"
3: Names match, but addresses are different.
"James Watson <james@watson.com>", "James Watson <james@gmail.com>"
4: Names match, but addresses excluding mail extensions are same.
"James Watson <james@gmail.com>", "James Watson <james+a@gmail.com>"
For case 4, a --strict check message is generated, and for the
other cases 0, 2 and 3, warnings are generated.
Link: https://lore.kernel.org/lkml/7958ded756c895ca614ba900aae7b830a992475e.camel@perches.com/
Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
---
scripts/checkpatch.pl | 54 +++++++++++++++++++++++++++++++++++++++----
1 file changed, 50 insertions(+), 4 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 31624bbb342e..62c83e9715ab 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -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");
+ }
}
}
--
2.27.0
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
next reply other threads:[~2020-10-05 17:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-05 17:39 Dwaipayan Ray [this message]
2020-10-05 18:23 ` [Linux-kernel-mentees] [PATCH v2] checkpatch: add new warnings to author signoff checks Joe Perches
2020-10-05 18:46 ` Dwaipayan Ray
2020-10-05 18:51 ` Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201005173933.171074-1-dwaipayanray1@gmail.com \
--to=dwaipayanray1@gmail.com \
--cc=joe@perches.com \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).