Re: [PATCH] checkpatch: Verify SPDX comment style

From: Joe Perches
Date: Tue Feb 05 2019 - 21:21:46 EST


On Tue, 2019-02-05 at 14:21 -0800, Andrew Morton wrote:
> On Thu, 10 Jan 2019 16:05:11 -0800 Joe Perches <joe@xxxxxxxxxxx> wrote:
>
> > Using SPDX commenting style // or /* is specified for
> > various file types in Documentation/process/license-rules.rst
> > so add an appropriate test for .[chsS] files because many
> > proposed file additions and patches do not use the correct style.
>
> Dan's
> http://lkml.kernel.org/r/154899811738.3165233.12325692939590944259.stgit@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> is giving me
>
> WARNING: Missing or malformed SPDX-License-Identifier tag in line 1
> #500: FILE: mm/shuffle.h:1:
> +// SPDX-License-Identifier: GPL-2.0
>
> and switching it to /* */ doesn't fix. This happens with or without
> this patch applied. What to do?

Umm, fix checkpatch?

---
scripts/checkpatch.pl | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 37f81fe93c01..216480ae29d1 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3053,21 +3053,21 @@ sub process {
# check SPDX comment style for .[chsS] files
if ($realfile =~ /\.[chsS]$/ &&
$rawline =~ /SPDX-License-Identifier:/ &&
- $rawline !~ /^\+\s*\Q$comment\E\s*/) {
+ $rawline !~ m@^\+\s*\Q$comment\E\s*@) {
WARN("SPDX_LICENSE_TAG",
"Improper SPDX comment style for '$realfile', please use '$comment' instead\n" . $herecurr);
}

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);
+ $rawline !~ m@^\+\Q$comment\E SPDX-License-Identifier: @) {
+ WARN("SPDX_LICENSE_TAG",
+ "Missing or malformed SPDX-License-Identifier tag in line $checklicenseline\n" . $herecurr);
} elsif ($rawline =~ /(SPDX-License-Identifier: .*)/) {
- my $spdx_license = $1;
- if (!is_SPDX_License_valid($spdx_license)) {
- WARN("SPDX_LICENSE_TAG",
- "'$spdx_license' is not supported in LICENSES/...\n" . $herecurr);
- }
+ my $spdx_license = $1;
+ if (!is_SPDX_License_valid($spdx_license)) {
+ WARN("SPDX_LICENSE_TAG",
+ "'$spdx_license' is not supported in LICENSES/...\n" . $herecurr);
+ }
}
}
}