aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2025-05-15 14:13:13 +0100
committerDaniel P. Berrangé <berrange@redhat.com>2025-05-22 11:24:41 +0100
commit1f59381d6c0126cf0348977caa73ab8f7cfa1269 (patch)
tree0264a4529bb6ac75e202315db0d77287df5de260
parentb36934063c5550a3fcb1b36027fd1a509142e4f9 (diff)
downloadqemu-1f59381d6c0126cf0348977caa73ab8f7cfa1269.zip
qemu-1f59381d6c0126cf0348977caa73ab8f7cfa1269.tar.gz
qemu-1f59381d6c0126cf0348977caa73ab8f7cfa1269.tar.bz2
scripts/checkpatch: reject license boilerplate on new files
The previous commit mandates use of SPDX-License-Identifier on common source files, and encourages it on all other files. Some contributors are none the less still also including the license boilerplate text. This is redundant and will potentially cause trouble if inconsistent with the SPDX declaration. Match common boilerplate text blurbs and report them as invalid, for newly added files. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Cédric Le Goater <clg@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
-rwxr-xr-xscripts/checkpatch.pl23
1 files changed, 23 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index da13102..9291bc9 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -365,6 +365,18 @@ our @typeList = (
qr{guintptr},
);
+# Match text found in common license boilerplate comments:
+# for new files the SPDX-License-Identifier line is sufficient.
+our @LICENSE_BOILERPLATE = (
+ "licensed under the terms of the GNU GPL",
+ "under the terms of the GNU General Public License",
+ "under the terms of the GNU Lesser General Public",
+ "Permission is hereby granted, free of charge",
+ "GNU GPL, version 2 or later",
+ "See the COPYING file"
+);
+our $LICENSE_BOILERPLATE_RE = join("|", @LICENSE_BOILERPLATE);
+
# Load common spelling mistakes and build regular expression list.
my $misspellings;
my %spelling_fix;
@@ -1497,6 +1509,13 @@ sub process_end_of_file {
"' need 'SPDX-License-Identifier'?");
}
}
+ if ($fileinfo->{action} eq "new" &&
+ exists $fileinfo->{facts}->{sawboilerplate}) {
+ ERROR("New file '" . $fileinfo->{filenew} . "' must " .
+ "not have license boilerplate header text, only " .
+ "the SPDX-License-Identifier, unless this file was " .
+ "copied from existing code already having such text.");
+ }
}
sub process {
@@ -1799,6 +1818,10 @@ sub process {
&checkspdx($realfile, $1);
}
+ if ($rawline =~ /$LICENSE_BOILERPLATE_RE/) {
+ $fileinfo->{facts}->{sawboilerplate} = 1;
+ }
+
if ($rawline =~ m,(SPDX-[a-zA-Z0-9-_]+):,) {
my $tag = $1;
my @permitted = qw(