From: Joe Perches <joe@perches.com>
To: Rob Herring <robh@kernel.org>,
linux-kernel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>
Cc: Andy Whitcroft <apw@canonical.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Philippe Ombredanne <pombredanne@nexb.com>
Subject: Re: [PATCH v4] checkpatch.pl: Add SPDX license tag check
Date: Wed, 20 Dec 2017 22:28:48 -0800 [thread overview]
Message-ID: <1513837728.1234.146.camel@perches.com> (raw)
In-Reply-To: <20171220234625.16521-1-robh@kernel.org>
On Wed, 2017-12-20 at 17:46 -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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Philippe Ombredanne <pombredanne@nexb.com>
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
> Thomas, if you are inclined and Joe is happy with this, can you add this
> on top of your series adding license-rules.rst.
>
> v4:
> - Reference license-rules.rst
> - Add comment style checks based on file types
> - Check .rst files
>
> v3:
> - Since we specify that the tag goes on the 1st or 2nd line, the logic
> can be greatly simplified compared to v2 because we can just use the
> line number. And now the check is improved too.
>
> scripts/checkpatch.pl | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -2866,6 +2866,31 @@ sub process {
> }
> }
>
> +# check for using SPDX license tag at beginning of files
> + if ($rawline =~ /^\+/ && !($realline == 1 && $rawline =~ /^[\s\+]#!/)) {
This test will enter this block for every added line of the patch.
Needs to be /^[ \+]/ and not [\t\+] and probably should just be ^\+
I'd probably have something like
my $checklicenseline = 1;
at the start of sub process
and use something
if ($realline == $checklicenseline) {
if ($realfile =~ /\.(?:sh|pl|py)/ && $rawline =~ /\[ \+]\s*\!\#/) {
$checklicenseline = 2;
} elsif (etc...) {
}
}
> + } elsif ($realfile =~ /\.rst$/) {
> + $comment = '..';
\.\.
What about .txt, .json, .cocci, and .awk ?
next prev parent reply other threads:[~2017-12-21 6:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-20 23:46 [PATCH v4] checkpatch.pl: Add SPDX license tag check Rob Herring
2017-12-21 6:28 ` Joe Perches [this message]
2017-12-21 17:04 ` Rob Herring
2017-12-21 17:22 ` Joe Perches
2017-12-21 7:15 ` 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=1513837728.1234.146.camel@perches.com \
--to=joe@perches.com \
--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 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.