From: Joe Perches <joe@perches.com>
To: Rob Herring <robh@kernel.org>, Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, Andy Whitcroft <apw@canonical.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Philippe Ombredanne <pombredanne@nexb.com>
Subject: Re: [PATCH v6] checkpatch.pl: Add SPDX license tag check
Date: Fri, 02 Feb 2018 13:18:02 -0800 [thread overview]
Message-ID: <1517606282.7489.165.camel@perches.com> (raw)
In-Reply-To: <20180202154026.15298-1-robh@kernel.org>
On Fri, 2018-02-02 at 09:40 -0600, Rob Herring wrote:
> Add SPDX license tag check based on the rules defined in
> Documentation/process/license-rules.rst. To summarize, SPDX license tags
> should be on the 1st line (or 2nd line in scripts) using the appropriate
> comment style for the file type.
>
> Cc: Andy Whitcroft <apw@canonical.com>
> Cc: Joe Perches <joe@perches.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Philippe Ombredanne <pombredanne@nexb.com>
> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Joe Perches <joe@perches.com>
> ---
> v6:
> - Dropped script extension check and only look for #!/... on 1st line. A
> text executable file was not reliable either.
> - Support .awk and .tc which may or may not have a #!/.
> - Fixed a typo in script "#!" regex and also match on first /.
> - Add Greg's ack.
>
> scripts/checkpatch.pl | 27 +++++++++++++++++++++++++++
> 1 file changed, 27 insertions(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index ba03f17ff662..6db245e5f93b 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2225,6 +2225,8 @@ sub process {
>
> my $camelcase_file_seeded = 0;
>
> + my $checklicenseline = 1;
> +
> sanitise_line_reset();
> my $line;
> foreach my $rawline (@rawlines) {
> @@ -2416,6 +2418,7 @@ sub process {
> } else {
> $check = $check_orig;
> }
> + $checklicenseline = 1;
> next;
> }
>
> @@ -2866,6 +2869,30 @@ sub process {
> }
> }
>
> +# check for using SPDX license tag at beginning of files
> + if ($realline == $checklicenseline) {
> + if ($rawline =~ /^[ \+]\s*\#\!\s*\//) {
> + $checklicenseline = 2;
> + } elsif ($rawline =~ /^\+/) {
> + my $comment = "";
> + if ($realfile =~ /\.(h|s|S)$/) {
> + $comment = '/*';
> + } elsif ($realfile =~ /\.(c|dts|dtsi)$/) {
> + $comment = '//';
> + } elsif (($checklicenseline == 2) || $realfile =~ /\.(sh|pl|py|awk|tc)$/) {
> + $comment = '#';
> + } elsif ($realfile =~ /\.rst$/) {
> + $comment = '..';
> + }
> +
> + if ($comment !~ /^$/ &&
> + $rawline !~ /^\+\Q$comment\E SPDX-License-Identifier: /) {
> + WARN("SPDX_LICENSE_TAG",
> + "Missing or malformed SPDX-License-Identifier tag in line $checklicenseline\n" . $herecurr);
> + }
> + }
> + }
> +
> # check we are in a valid source file if not then ignore this hunk
> next if ($realfile !~ /\.(h|c|s|S|sh|dtsi|dts)$/);
>
next prev parent reply other threads:[~2018-02-02 21:18 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-02 15:40 [PATCH v6] checkpatch.pl: Add SPDX license tag check Rob Herring
2018-02-02 15:49 ` Igor Stoppa
2018-02-02 16:12 ` Greg Kroah-Hartman
2018-02-02 16:17 ` Jonathan Corbet
2018-02-02 18:27 ` Rob Herring
2018-02-02 19:06 ` Joe Perches
2018-02-02 20:18 ` Kate Stewart
2018-02-02 20:26 ` Kate Stewart
2018-02-02 20:55 ` Joe Perches
2018-02-08 14:41 ` Philippe Ombredanne
2018-02-02 20:57 ` Rob Herring
2018-02-02 21:10 ` Joe Perches
2018-02-03 13:41 ` Igor Stoppa
2018-02-08 14:44 ` Philippe Ombredanne
2018-02-08 14:35 ` Philippe Ombredanne
2018-02-08 17:24 ` Joe Perches
2018-02-08 18:09 ` Philippe Ombredanne
2018-02-02 21:18 ` Joe Perches [this message]
2018-02-09 0:35 ` Joe Perches
2018-02-09 5:58 ` 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=1517606282.7489.165.camel@perches.com \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=apw@canonical.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pombredanne@nexb.com \
--cc=robh@kernel.org \
--cc=tglx@linutronix.de \
/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).