Skip to contentSkip to conversation

scripts: Add exception to license check

PATCH In review Nabih Estefan 2 participants 2 messages Apr 23, 2025 – Apr 24, 2025 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts: Add exception to license check

The documentation for trace events says that every subdirectory which has trace events should have a trace.h header, whose only content is an include of the trace/trace-<subdir>.h file.

Due to that, we should skip it in the checkpatch license check. I'm adding it as an exception to the check instead of its own if so it still throws the warning on all new files instead of ignoring it.

Change-Id Ic2dae14f8cded0dd02d5b231588bd38d8a00e40d
---
 scripts/checkpatch.pl | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +3 -1
index 365892de04..b2c6ac2477 100755
@@ -1685,7 +1685,9 @@ sub process {
 		if ($line =~ /^new file mode\s*\d+\s*$/) {
 		    if ($expect_spdx) {
 			if ($expect_spdx_file =~
-			    /\.(c|h|py|pl|sh|json|inc|Makefile)$/) {
+			    /\.(c|h|py|pl|sh|json|inc|Makefile)$/
+				and not $expect_spdx_file =~ /(trace\.h)$/) {
+				# Files to include auto-generated files don't require a license
 			    # source code files MUST have SPDX license declared
 			    ERROR("New file '$expect_spdx_file' requires " .
 				  "'SPDX-License-Identifier'");
Signature · 1 line
2.49.0.805.g082f7c87e0-goog
#1 lore raw
Quoted 3 lines · Nabih Estefan

The documentation for trace events says that every subdirectory which has trace events should have a trace.h header, whose only content is an include of the trace/trace-<subdir>.h file.

Historically we have not bothered to add the license header to the trace.h files, primarily because its size would dwarf the actual content, and secondly because. the content can probably be sad to be not copyrightable.

With SPDX-License-Identifier being so concise though, the main reason for omitting it goes away. So my feeling is that we should not exempt the trace.h files, and stick with our default rule that *ALL* source files must have SPDX-License-Identifier.

Quoted 28 lines

Due to that, we should skip it in the checkpatch license check. I'm adding it as an exception to the check instead of its own if so it still throws the warning on all new files instead of ignoring it.

Change-Id Ic2dae14f8cded0dd02d5b231588bd38d8a00e40d
---
 scripts/checkpatch.pl | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +3 -1
index 365892de04..b2c6ac2477 100755
@@ -1685,7 +1685,9 @@ sub process {
 		if ($line =~ /^new file mode\s*\d+\s*$/) {
 		    if ($expect_spdx) {
 			if ($expect_spdx_file =~
-			    /\.(c|h|py|pl|sh|json|inc|Makefile)$/) {
+			    /\.(c|h|py|pl|sh|json|inc|Makefile)$/
+				and not $expect_spdx_file =~ /(trace\.h)$/) {
+				# Files to include auto-generated files don't require a license
 			    # source code files MUST have SPDX license declared
 			    ERROR("New file '$expect_spdx_file' requires " .
 				  "'SPDX-License-Identifier'");
Signature · 1 line
2.49.0.805.g082f7c87e0-goog

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|