diff options
Diffstat (limited to 'scripts/checkpatch.pl')
| -rwxr-xr-x | scripts/checkpatch.pl | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index b464a4c3f863..0f022b56f117 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
| @@ -2257,6 +2257,8 @@ sub process { | |||
| 2257 | 2257 | ||
| 2258 | my $camelcase_file_seeded = 0; | 2258 | my $camelcase_file_seeded = 0; |
| 2259 | 2259 | ||
| 2260 | my $checklicenseline = 1; | ||
| 2261 | |||
| 2260 | sanitise_line_reset(); | 2262 | sanitise_line_reset(); |
| 2261 | my $line; | 2263 | my $line; |
| 2262 | foreach my $rawline (@rawlines) { | 2264 | foreach my $rawline (@rawlines) { |
| @@ -2448,6 +2450,7 @@ sub process { | |||
| 2448 | } else { | 2450 | } else { |
| 2449 | $check = $check_orig; | 2451 | $check = $check_orig; |
| 2450 | } | 2452 | } |
| 2453 | $checklicenseline = 1; | ||
| 2451 | next; | 2454 | next; |
| 2452 | } | 2455 | } |
| 2453 | 2456 | ||
| @@ -2911,6 +2914,30 @@ sub process { | |||
| 2911 | } | 2914 | } |
| 2912 | } | 2915 | } |
| 2913 | 2916 | ||
| 2917 | # check for using SPDX license tag at beginning of files | ||
| 2918 | if ($realline == $checklicenseline) { | ||
| 2919 | if ($rawline =~ /^[ \+]\s*\#\!\s*\//) { | ||
| 2920 | $checklicenseline = 2; | ||
| 2921 | } elsif ($rawline =~ /^\+/) { | ||
| 2922 | my $comment = ""; | ||
| 2923 | if ($realfile =~ /\.(h|s|S)$/) { | ||
| 2924 | $comment = '/*'; | ||
| 2925 | } elsif ($realfile =~ /\.(c|dts|dtsi)$/) { | ||
| 2926 | $comment = '//'; | ||
| 2927 | } elsif (($checklicenseline == 2) || $realfile =~ /\.(sh|pl|py|awk|tc)$/) { | ||
| 2928 | $comment = '#'; | ||
| 2929 | } elsif ($realfile =~ /\.rst$/) { | ||
| 2930 | $comment = '..'; | ||
| 2931 | } | ||
| 2932 | |||
| 2933 | if ($comment !~ /^$/ && | ||
| 2934 | $rawline !~ /^\+\Q$comment\E SPDX-License-Identifier: /) { | ||
| 2935 | WARN("SPDX_LICENSE_TAG", | ||
| 2936 | "Missing or malformed SPDX-License-Identifier tag in line $checklicenseline\n" . $herecurr); | ||
| 2937 | } | ||
| 2938 | } | ||
| 2939 | } | ||
| 2940 | |||
| 2914 | # check we are in a valid source file if not then ignore this hunk | 2941 | # check we are in a valid source file if not then ignore this hunk |
| 2915 | next if ($realfile !~ /\.(h|c|s|S|sh|dtsi|dts)$/); | 2942 | next if ($realfile !~ /\.(h|c|s|S|sh|dtsi|dts)$/); |
| 2916 | 2943 | ||
