[PATCH 4/4] checkpatch: don't suggest kstrto<type> in userspace code
From: Kir Kolyshkin
Date: Thu Oct 22 2026 - 18:45:56 EST
The SSCANF_TO_KSTRTO check suggests using kstrto<type> instead of a
single-variable sscanf(). These helpers are kernel-only and are not
available to userspace code under tools/, so the suggestion can not be
followed there.
Use is_userspace() to skip the check for such files.
Signed-off-by: Kir Kolyshkin <kolyshkin@xxxxxxxxx>
---
scripts/checkpatch.pl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index be0e0493d4a2..7a520faec34e 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -7204,8 +7204,8 @@ sub process {
"unchecked sscanf return value\n" . "$here\n$stat_real\n");
}
-# check for simple sscanf that should be kstrto<foo>
- if ($perl_version_ok &&
+# check for simple sscanf that should be kstrto<foo> (not available in userspace)
+ if ($perl_version_ok && !is_userspace($realfile) &&
defined $stat &&
$line =~ /\bsscanf\b/) {
my $lc = $stat =~ tr@\n@@;
--
2.56.0