* [PATCH] scripts: checkversion: match complete version macro names
@ 2026-12-01 22:10 Hamdy Abou El Anein
0 siblings, 0 replies; only message in thread
From: Hamdy Abou El Anein @ 2026-12-01 22:10 UTC (permalink / raw)
To: nathan, nsc; +Cc: linux-kbuild, linux-kernel, rdunlap, breno3011alves
The version macro checks match substrings of unrelated identifiers.
For example, MY_LINUX_VERSION_CODE and KERNEL_VERSION_EXTRA are
mistaken for macros from linux/version.h. Also, the non-word
character required before KERNEL_VERSION prevents detection at the
start of a line.
Use word boundaries around the complete set of version macro names
to avoid these false positives and detect uses at the start of a line.
Tested with all five version macros, longer unrelated identifiers,
a macro at the start of a line, unused and needed includes, and
existing comment and string handling.
AI assistance: ChatGPT identified the issue, prepared the fix and
commit message, and ran local regression tests.
Signed-off-by: Hamdy Abou El Anein <info@daylightlinux.ch>
---
scripts/checkversion.pl | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/scripts/checkversion.pl b/scripts/checkversion.pl
index 94cd49eff605..3685f080f69e 100755
--- a/scripts/checkversion.pl
+++ b/scripts/checkversion.pl
@@ -44,9 +44,7 @@ foreach my $file (@ARGV) {
# Look for uses: LINUX_VERSION_CODE, KERNEL_VERSION,
# LINUX_VERSION_MAJOR, LINUX_VERSION_PATCHLEVEL, LINUX_VERSION_SUBLEVEL
- if (($_ =~ /LINUX_VERSION_CODE/) || ($_ =~ /\WKERNEL_VERSION/) ||
- ($_ =~ /LINUX_VERSION_MAJOR/) || ($_ =~ /LINUX_VERSION_PATCHLEVEL/) ||
- ($_ =~ /LINUX_VERSION_SUBLEVEL/)) {
+ if (m/\b(?:KERNEL_VERSION|LINUX_VERSION_(?:CODE|MAJOR|PATCHLEVEL|SUBLEVEL))\b/) {
$fUseVersion = 1;
last if $iLinuxVersion;
}
--
2.56.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-01 22:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 22:10 [PATCH] scripts: checkversion: match complete version macro names Hamdy Abou El Anein
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox