Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753152AbdLUG2z (ORCPT ); Thu, 21 Dec 2017 01:28:55 -0500 Received: from smtprelay0201.hostedemail.com ([216.40.44.201]:52063 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751505AbdLUG2w (ORCPT ); Thu, 21 Dec 2017 01:28:52 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::,RULES_HIT:41:355:379:541:599:800:960:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1431:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2693:2828:3138:3139:3140:3141:3142:3354:3622:3653:3865:3866:3867:3868:3870:3871:3873:3874:4250:4321:5007:6117:6119:7875:7901:10004:10400:10848:11232:11658:11914:12043:12291:12740:12760:12895:13069:13311:13357:13439:14181:14659:14721:21080:21220:21451:21627:30034:30054:30070:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: error66_6a3f32671cd2d X-Filterd-Recvd-Size: 2838 Message-ID: <1513837728.1234.146.camel@perches.com> Subject: Re: [PATCH v4] checkpatch.pl: Add SPDX license tag check From: Joe Perches To: Rob Herring , linux-kernel@vger.kernel.org, Thomas Gleixner Cc: Andy Whitcroft , Greg Kroah-Hartman , Philippe Ombredanne Date: Wed, 20 Dec 2017 22:28:48 -0800 In-Reply-To: <20171220234625.16521-1-robh@kernel.org> References: <20171220234625.16521-1-robh@kernel.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.26.1-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1911 Lines: 62 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 > Cc: Joe Perches > Cc: Greg Kroah-Hartman > Cc: Thomas Gleixner > Cc: Philippe Ombredanne > Signed-off-by: Rob Herring > --- > 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 ?