From: Joe Perches Date: Fri, 8 Mar 2019 00:28:42 +0000 (-0800) Subject: checkpatch: add test for SPDX-License-Identifier on wrong line # X-Git-Tag: v5.4-rc1~1483^2~46 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a8da38a9cf0e9889a6334bbd6e7364307b571cc1;p=platform%2Fkernel%2Flinux-rpi.git checkpatch: add test for SPDX-License-Identifier on wrong line # Warn when any SPDX-License-Identifier: tag is not created on the proper line number. Link: http://lkml.kernel.org/r/9b74ee87f8c1b8fd310e213fcb4994d58610fcb6.camel@perches.com Signed-off-by: Joe Perches Cc: Linus Walleij Cc: "Enrico Weigelt, metux IT consult" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index cbbeb38..8d8d26b 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3073,6 +3073,14 @@ sub process { # check we are in a valid source file if not then ignore this hunk next if ($realfile !~ /\.(h|c|s|S|sh|dtsi|dts)$/); +# check for using SPDX-License-Identifier on the wrong line number + if ($realline != $checklicenseline && + $rawline =~ /\bSPDX-License-Identifier:/ && + substr($line, @-, @+ - @-) eq "$;" x (@+ - @-)) { + WARN("SPDX_LICENSE_TAG", + "Misplaced SPDX-License-Identifier tag - use line $checklicenseline instead\n" . $herecurr); + } + # line length limit (with some exclusions) # # There are a few types of lines that may extend beyond $max_line_length: