Skip to contentSkip to conversation

checkpatch: allow build files to reference other build files

PATCH Superseded Will McVicker 2 participants 3 messages Jan 12, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpatch: allow build files to reference other build files

Add an exception to the EMBEDDED_FILENAME warning for build files. This fixes the below warnings where the Kconfig and Makefile files reference other similarly named build files.

WARNING:EMBEDDED_FILENAME: It's generally not useful to have the filename in the file
#24: FILE: Kconfig:34:
+source "drivers/willmcvicker/Kconfig"

WARNING:EMBEDDED_FILENAME: It's generally not useful to have the filename in the file
#36: FILE: Makefile:667:
+ } > Makefile

---
 scripts/checkpatch.pl | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +3 -1
index f8343b34a28b..62939f5800cf 100755
@@ -3785,7 +3785,9 @@ sub process {
 		}
 
 # check for embedded filenames
-		if ($rawline =~ /^\+.*\b\Q$realfile\E\b/) {
+		if ($rawline =~ /^\+.*\b\Q$realfile\E\b/ &&
+			$realfile !~ /Kconfig.*/ &&
+			$realfile !~ /Makefile.*/) {
 			WARN("EMBEDDED_FILENAME",
 			     "It's generally not useful to have the filename in the file\n" . $herecurr);
 		}

base-commit: 70d201a40823acba23899342d62bc2644051ad2e

Signature · 1 line
2.43.0.275.g3460e3d667-goog
maintainer
#1 lore raw
Quoted 9 lines · Will McVicker

Add an exception to the EMBEDDED_FILENAME warning for build files. This fixes the below warnings where the Kconfig and Makefile files reference other similarly named build files.

WARNING:EMBEDDED_FILENAME: It's generally not useful to have the filename in the file
#24: FILE: Kconfig:34:
+source "drivers/willmcvicker/Kconfig"

Quoted 4 lines

WARNING:EMBEDDED_FILENAME: It's generally not useful to have the filename in the file
#36: FILE: Makefile:667:
+ } > Makefile

No need to wrap here I think.

scripts/checkpatch.pl

Quoted 1 line
scripts/checkpatch.pl +0 -0

[]

scripts/checkpatch.pl sub process { · line 3790

Quoted 8 lines
scripts/checkpatch.pl +3 -1
@@ -3785,7 +3785,9 @@ sub process {
 		}
 
 # check for embedded filenames
-		if ($rawline =~ /^\+.*\b\Q$realfile\E\b/) {
+		if ($rawline =~ /^\+.*\b\Q$realfile\E\b/ &&
+			$realfile !~ /Kconfig.*/ &&
+			$realfile !~ /Makefile.*/) {

Align to open parenthesis please.
It's not useful to have .* before the /

So perhaps better to be

		if ($rawline =~ /^\+.*\b\Q$realfile\E\b/ &&
		    $realfile !~ /(?:Kconfig|Makefile)/) {
Quoted 3 lines
scripts/checkpatch.pl +0 -0
 			WARN("EMBEDDED_FILENAME",
 			     "It's generally not useful to have the filename in the file\n" . $herecurr);
 		}
#2 lore raw
Quoted 10 lines · Joe Perches
Quoted 9 lines · Will McVicker

Add an exception to the EMBEDDED_FILENAME warning for build files. This fixes the below warnings where the Kconfig and Makefile files reference other similarly named build files.

WARNING:EMBEDDED_FILENAME: It's generally not useful to have the filename in the file
#24: FILE: Kconfig:34:
+source "drivers/willmcvicker/Kconfig"

Quoted 6 lines
Quoted 4 lines

WARNING:EMBEDDED_FILENAME: It's generally not useful to have the filename in the file
#36: FILE: Makefile:667:
+ } > Makefile

No need to wrap here I think.

You're right. I'll update in v2.

Quoted 6 lines

scripts/checkpatch.pl

Quoted 2 lines
scripts/checkpatch.pl +0 -0

[]

Quoted 3 lines
scripts/checkpatch.pl +0 -0
@@ -3785,7 +3785,9 @@ sub process {
 		}
 
Quoted 8 lines

scripts/checkpatch.pl sub process { · line 3790

Quoted 5 lines
scripts/checkpatch.pl +3 -1
 # check for embedded filenames
-		if ($rawline =~ /^\+.*\b\Q$realfile\E\b/) {
+		if ($rawline =~ /^\+.*\b\Q$realfile\E\b/ &&
+			$realfile !~ /Kconfig.*/ &&
+			$realfile !~ /Makefile.*/) {

Align to open parenthesis please.
It's not useful to have .* before the /

I was following other references in this file, but looks like you're right that it's not needed. Your recommendation passed the tests I have. So I'll update the regex in v2.

Thanks,
Will

Quoted 10 lines

So perhaps better to be

		if ($rawline =~ /^\+.*\b\Q$realfile\E\b/ &&
		    $realfile !~ /(?:Kconfig|Makefile)/) {
Quoted 3 lines
scripts/checkpatch.pl +0 -0
 			WARN("EMBEDDED_FILENAME",
 			     "It's generally not useful to have the filename in the file\n" . $herecurr);
 		}