Messages in this thread | | | Subject | Re: [PATCH v4] checkpatch.pl: Add SPDX license tag check | From | Joe Perches <> | Date | Thu, 21 Dec 2017 09:22:57 -0800 |
| |
On Thu, 2017-12-21 at 11:04 -0600, Rob Herring wrote: > Okay, here's what I've ended up with: > > if ($realline == $checklicenseline) { > if ($realfile =~ /\.(?:sh|pl|py)/ && $rawline =~ /\[ \+]\s*\!\#/) { > $checklicenseline = 2; > } elsif ($rawline =~ /^\+/) { > my $comment = ""; > if ($realfile =~ /\.(h|s|S)$/) { > $comment = '/\*'; > } elsif ($realfile =~ /\.(c|dts|dtsi)$/) { > $comment = '//'; > } elsif ($realfile =~ /\.(sh|pl|py)$/) { > $comment = '#'; > } elsif ($realfile =~ /\.rst$/) { > $comment = '\.\.'; > } > > if ($comment !~ /^$/ && > $rawline !~ m@^\+$comment SPDX-License-Identifier: @) { > WARN("SPDX_LICENSE_TAG", > "Missing or malformed SPDX-License-Identifier tag in 1st (or 2nd for scripts) line\n" . > $herecurr); > } > } > }
Seems sensible enough.
Maybe it's better to use \Q$comment\E and a consistent style on comment and rawline
Any checkpatch patch for license style requirements should not be applied until after Documentation/license-rules.rst is in -next.
| |