Skip to content

Commit

Permalink
checkpatch: add test for SPDX-License-Identifier on wrong line #
Browse files Browse the repository at this point in the history
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 <joe@perches.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: "Enrico Weigelt, metux IT consult" <lkml@metux.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
JoePerches authored and torvalds committed Mar 8, 2019
1 parent 98005e8 commit a8da38a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a8da38a

Please sign in to comment.