linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Tobin C. Harding" <me@tobin.cc>
To: Joe Perches <joe@perches.com>
Cc: "Tobin C. Harding" <me@tobin.cc>,
	linux-kernel@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Andy Whitcroft <apw@canonical.com>
Subject: [PATCH 4/4] checkpatch: add check for tag Co-Developed-by
Date: Fri,  8 Dec 2017 10:27:51 +1100	[thread overview]
Message-ID: <1512689271-28051-5-git-send-email-me@tobin.cc> (raw)
In-Reply-To: <1512689271-28051-1-git-send-email-me@tobin.cc>

From: Joe Perches <joe@perches.com>

Recently signature tag Co-Developed-by was added to the
kernel (Documentation/process/5.Posting.rst). checkpatch.pl doesn't know
about it yet. All prior tags used all lowercase characters except for first
character. Checks for this format had to be re-worked to allow for the
new tag.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tobin C. Harding <me@tobin.cc>
---

Greg,

This patch has the same brief commit and achieves the same aim as the
code you reviewed. I'm adding your tag here even though the code is
totally different. I believe you were reviewing the behaviour of the
code not the actual logic.

Yell if I'm wrong.

thanks,
Tobin.

 scripts/checkpatch.pl | 58 +++++++++++++++++++++++++++++++--------------------
 1 file changed, 35 insertions(+), 23 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 6df99d1ebca5..36f3b00783a9 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -461,16 +461,18 @@ our $logFunctions = qr{(?x:
 	seq_vprintf|seq_printf|seq_puts
 )};
 
-our $signature_tags = qr{(?xi:
-	Signed-off-by:|
-	Acked-by:|
-	Tested-by:|
-	Reviewed-by:|
-	Reported-by:|
-	Suggested-by:|
-	To:|
-	Cc:
-)};
+our @valid_signatures = (
+	"Signed-off-by:",
+	"Acked-by:",
+	"Tested-by:",
+	"Reviewed-by:",
+	"Reported-by:",
+	"Suggested-by:",
+	"Co-Developed-by:",
+	"To:",
+	"Cc:"
+);
+my $signature_tags = "(?x:" . join('|', @valid_signatures) . ")";
 
 our @typeListMisordered = (
 	qr{char\s+(?:un)?signed},
@@ -2183,6 +2185,17 @@ sub pos_last_openparen {
 	return length(expand_tabs(substr($line, 0, $last_openparen))) + 1;
 }
 
+sub get_preferred_sign_off {
+	my ($sign_off) = @_;
+
+	foreach my $sig (@valid_signatures) {
+		if (lc($sign_off) eq lc($sig)) {
+			return $sig;
+		}
+	}
+	return "";
+}
+
 sub process {
 	my $filename = shift;
 
@@ -2489,35 +2502,34 @@ sub process {
 			my $sign_off = $2;
 			my $space_after = $3;
 			my $email = $4;
-			my $ucfirst_sign_off = ucfirst(lc($sign_off));
+			my $preferred_sign_off = ucfirst(lc($sign_off));
 
-			if ($sign_off !~ /$signature_tags/) {
+			if ($sign_off !~ /$signature_tags/i) {
 				WARN("BAD_SIGN_OFF",
 				     "Non-standard signature: $sign_off\n" . $herecurr);
-			}
-			if (defined $space_before && $space_before ne "") {
+			} elsif ($sign_off !~ /$signature_tags/) {
+				$preferred_sign_off = get_preferred_sign_off($sign_off);
 				if (WARN("BAD_SIGN_OFF",
-					 "Do not use whitespace before $ucfirst_sign_off\n" . $herecurr) &&
+					 "'$preferred_sign_off' is the preferred signature form\n" . $herecurr) &&
 				    $fix) {
-					$fixed[$fixlinenr] =
-					    "$ucfirst_sign_off $email";
+					$fixed[$fixlinenr] = "$preferred_sign_off $email";
 				}
 			}
-			if ($sign_off =~ /-by:$/i && $sign_off ne $ucfirst_sign_off) {
+			if (defined $space_before && $space_before ne "") {
 				if (WARN("BAD_SIGN_OFF",
-					 "'$ucfirst_sign_off' is the preferred signature form\n" . $herecurr) &&
+					 "Do not use whitespace before $preferred_sign_off\n" . $herecurr) &&
 				    $fix) {
 					$fixed[$fixlinenr] =
-					    "$ucfirst_sign_off $email";
+					    "$preferred_sign_off $email";
 				}
-
 			}
+
 			if (!defined $space_after || $space_after ne " ") {
 				if (WARN("BAD_SIGN_OFF",
-					 "Use a single space after $ucfirst_sign_off\n" . $herecurr) &&
+					 "Use a single space after $preferred_sign_off\n" . $herecurr) &&
 				    $fix) {
 					$fixed[$fixlinenr] =
-					    "$ucfirst_sign_off $email";
+					    "$preferred_sign_off $email";
 				}
 			}
 
-- 
2.7.4

  parent reply	other threads:[~2017-12-07 23:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-07 23:27 [PATCH 0/4] checkpatch: update warnings Tobin C. Harding
2017-12-07 23:27 ` [PATCH 1/4] checkpatch: add sub routine get_stat_real() Tobin C. Harding
2017-12-07 23:27 ` [PATCH 2/4] checkpatch: add sub routine get_stat_here() Tobin C. Harding
2017-12-07 23:27 ` [PATCH 3/4] checkpatch: warn for use of %px Tobin C. Harding
2017-12-07 23:27 ` Tobin C. Harding [this message]
2017-12-08  7:42   ` [PATCH 4/4] checkpatch: add check for tag Co-Developed-by Greg Kroah-Hartman
2017-12-09  1:18     ` Tobin C. Harding

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=1512689271-28051-5-git-send-email-me@tobin.cc \
    --to=me@tobin.cc \
    --cc=apw@canonical.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.com \
    --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).