From: Rob Herring <robh@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH] checkpatch.pl: Add SPDX license tag check
Date: Wed, 8 Nov 2017 19:10:47 -0600 [thread overview]
Message-ID: <20171109011047.20040-1-robh@kernel.org> (raw)
Add a check warning if SPDX-License-Identifier tags are not used in
newly added files.
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Joe Perches <joe@perches.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Rob Herring <robh@kernel.org>
---
I rewrote my previous version to check more than just dts files. It also
now looks for a tag in added files rather than trying a fuzzy match on
freeform license text.
scripts/checkpatch.pl | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8b80bac055e4..6665735123e5 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2185,6 +2185,8 @@ sub process {
my $commit_log_has_diff = 0;
my $reported_maintainer_file = 0;
my $non_utf8_charset = 0;
+ my $added_file = 0;
+ my $missing_spdx_license = 0;
my $last_blank_line = 0;
my $last_coalesced_string_linenr = -1;
@@ -2368,6 +2370,16 @@ sub process {
$here = "#$linenr: " if (!$file);
$here = "#$realline: " if ($file);
+ # determine if this is a new file
+ if ($line =~ m@^\-\-\-\s/@) {
+ if ($line =~ m@/dev/null@) {
+ $added_file = 1;
+ $missing_spdx_license++;
+ } else {
+ $added_file = 0;
+ }
+ }
+
my $found_file = 0;
# extract the filename as it passes
if ($line =~ /^diff --git.*?(\S+)$/) {
@@ -2865,6 +2877,14 @@ sub process {
}
}
+# check for using SPDX tag instead of free form license text
+ if ($added_file &&
+ ($rawline =~ /\bSPDX-License-Identifier/ ||
+ $realfile =~ /Documentation/)) {
+ $missing_spdx_license--;
+ $added_file = 0;
+ }
+
# check we are in a valid source file if not then ignore this hunk
next if ($realfile !~ /\.(h|c|s|S|sh|dtsi|dts)$/);
@@ -6399,6 +6419,11 @@ sub process {
"Missing Signed-off-by: line(s)\n");
}
+ if ($missing_spdx_license) {
+ WARN("SPDX_LICENSE_TAG",
+ "Missing SPDX-License-Identifier tags in added files. Use tags instead of full license text.\n");
+ }
+
print report_dump();
if ($summary && !($clean == 1 && $quiet == 1)) {
print "$filename " if ($summary_file);
--
2.14.1
next reply other threads:[~2017-11-09 1:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-09 1:10 Rob Herring [this message]
2017-11-09 2:10 ` [PATCH] checkpatch.pl: Add SPDX license tag check Joe Perches
2017-11-09 9:12 ` Greg Kroah-Hartman
2017-11-09 13:55 ` Joe Perches
2017-11-09 13:47 ` Rob Herring
2017-11-09 15:39 ` Joe Perches
2017-11-09 18:12 ` Rob Herring
2017-11-09 18:27 ` Joe Perches
-- strict thread matches above, loose matches on Subject: below --
2018-02-01 21:14 Rob Herring
2018-02-01 21:49 ` Joe Perches
2018-02-02 7:56 ` Greg Kroah-Hartman
2018-02-08 14:23 ` Philippe Ombredanne
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=20171109011047.20040-1-robh@kernel.org \
--to=robh@kernel.org \
--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