checkpatch: add test for SPDX-License-Identifier on wrong line #
authorJoe Perches <[email protected]>
Fri, 8 Mar 2019 00:28:42 +0000 (16:28 -0800)
committerLinus Torvalds <[email protected]>
Fri, 8 Mar 2019 02:32:01 +0000 (18:32 -0800)
Warn when any SPDX-License-Identifier: tag is not created on the proper
line number.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Joe Perches <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: "Enrico Weigelt, metux IT consult" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
scripts/checkpatch.pl

index cbbeb3830a4878d10c0e1b081a5d4f77b8216c45..8d8d26b5cbbd8913b649ef6556050f1795f018d5 100755 (executable)
@@ -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: