mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kir Kolyshkin <kolyshkin@gmail.com>
To: Joe Perches <joe@perches.com>, Andy Whitcroft <apw@canonical.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Kir Kolyshkin <kolyshkin@gmail.com>,
	Dwaipayan Ray <dwaipayanray1@gmail.com>,
	Lukas Bulwahn <lukas.bulwahn@gmail.com>,
	Shuah Khan <shuah@kernel.org>,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] checkpatch: don't suggest kstrto<type> in userspace code
Date: Thu, 22 Oct 2026 15:44:23 -0700	[thread overview]
Message-ID: <20261022224426.2756960-5-kolyshkin@gmail.com> (raw)
In-Reply-To: <20261022224426.2756960-1-kolyshkin@gmail.com>

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@gmail.com>
---
 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


      parent reply	other threads:[~2026-10-22 22:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22 22:44 [PATCH 0/4] checkpatch: skip more kernel-only checks for " Kir Kolyshkin
2026-10-22 22:44 ` [PATCH 1/4] checkpatch: is_userspace: exclude kernel code under tools/ Kir Kolyshkin
2026-10-22 22:44 ` [PATCH 2/4] checkpatch: don't warn about ENOSYS in userspace code Kir Kolyshkin
2026-10-22 22:44 ` [PATCH 3/4] checkpatch: don't warn about BUG() " Kir Kolyshkin
2026-10-22 22:44 ` Kir Kolyshkin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261022224426.2756960-5-kolyshkin@gmail.com \
    --to=kolyshkin@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=dwaipayanray1@gmail.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=lukas.bulwahn@gmail.com \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®