All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aditya Srivastava <yashsri421@gmail.com>
To: lukas.bulwahn@gmail.com
Cc: linux-kernel-mentees@lists.linuxfoundation.org
Subject: [Linux-kernel-mentees] [PATCH] checkpatch: add fix option for BAD_SIGN_OFF
Date: Thu,  3 Dec 2020 00:06:49 +0530	[thread overview]
Message-ID: <20201202183649.9773-1-yashsri421@gmail.com> (raw)

Currently checkpatch warns us if the Co-developed-by line for an author
isn't immediately followed by the Signed-off-by line.

Generally, this warning occurs because of:
1) Absence of Signed-off-by line for the author from the patch
2) Misplaced Signed-off-by line for the author in the patch

Provide a simple fix by:
1) Inserting Signed-off-by line for the author immediately after the
Co-developed-by line

2) Removing Signed-off-by line for the author (if it pre-existed on
some other line)

Suggested-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>
---
 scripts/checkpatch.pl | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 5c9f13a97c12..d8f9d4d8b13d 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2509,6 +2509,9 @@ sub process {
 	my @setup_docs = ();
 	my $setup_docs = 0;
 
+	my %signed_off_by_lines;
+	my %co_developed_by_lines;
+
 	my $camelcase_file_seeded = 0;
 
 	my $checklicenseline = 1;
@@ -2794,6 +2797,7 @@ sub process {
 					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);
+					$signed_off_by_lines{$ctx} = $fixlinenr;
 
 					if ($email_address eq $author_address && $email_name eq $author_name) {
 						$author_sob = $ctx;
@@ -2989,11 +2993,17 @@ sub process {
 					}
 				}
 				if (!defined $lines[$linenr]) {
-					WARN("BAD_SIGN_OFF",
-                                             "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline);
+					if (WARN("BAD_SIGN_OFF",
+						 "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline) &&
+					    $fix) {
+						$co_developed_by_lines{$email} = $fixlinenr;
+					}
 				} elsif ($rawlines[$linenr] !~ /^\s*signed-off-by:\s*(.*)/i) {
-					WARN("BAD_SIGN_OFF",
-					     "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline . "\n" .$rawlines[$linenr]);
+					if (WARN("BAD_SIGN_OFF",
+						 "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline . "\n" .$rawlines[$linenr]) &&
+					    $fix) {
+						$co_developed_by_lines{$email} = $fixlinenr;
+					}
 				} elsif ($1 ne $email) {
 					WARN("BAD_SIGN_OFF",
 					     "Co-developed-by and Signed-off-by: name/email do not match \n" . "$here\n" . $rawline . "\n" .$rawlines[$linenr]);
@@ -7203,6 +7213,16 @@ sub process {
 		ERROR("NOT_UNIFIED_DIFF",
 		      "Does not appear to be a unified-diff format patch\n");
 	}
+
+	if (%co_developed_by_lines) {
+		foreach my $co_developer (keys %co_developed_by_lines) {
+			if (exists($signed_off_by_lines{$co_developer})) {
+				fix_delete_line($signed_off_by_lines{$co_developer}, "Signed-off-by: $co_developer");
+			}
+			fix_insert_line($co_developed_by_lines{$co_developer} + 1, "Signed-off-by: $co_developer");
+		}
+	}
+
 	if ($is_patch && $has_commit_log && $chk_signoff) {
 		if ($signoff == 0) {
 			ERROR("MISSING_SIGN_OFF",
-- 
2.17.1

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

             reply	other threads:[~2020-12-02 18:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02 18:36 Aditya Srivastava [this message]
2020-12-08 16:44 ` [Linux-kernel-mentees] [PATCH] checkpatch: add fix option for BAD_SIGN_OFF Aditya
2020-12-08 16:54   ` Lukas Bulwahn
2020-12-08 17:44     ` Aditya
2020-12-08 17:52       ` Aditya Srivastava
2020-12-08 21:07       ` Lukas Bulwahn
2020-12-09 11:46         ` Aditya
2020-12-09 11:51           ` Lukas Bulwahn
2020-12-12 10:55             ` Aditya

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=20201202183649.9773-1-yashsri421@gmail.com \
    --to=yashsri421@gmail.com \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=lukas.bulwahn@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.