[PATCH] scripts: checkversion: match complete version macro names

From: Hamdy Abou El Anein

Date: Tue Dec 01 2026 - 17:10:46 EST


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@xxxxxxxxxxxxxxxx>
---
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