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 0/4] checkpatch: skip more kernel-only checks for userspace code
Date: Thu, 22 Oct 2026 15:44:19 -0700 [thread overview]
Message-ID: <20261022224426.2756960-1-kolyshkin@gmail.com> (raw)
Commit 99b70ece33d8 ("checkpatch: suppress strscpy warnings for
userspace tools") added is_userspace() to skip checks which only make
sense for the kernel. This series extends that to a few more checks
which produce false positives for userspace code under tools/:
- ENOSYS: the "ENOSYS means invalid syscall nr" rule is about the
kernel ABI; in userspace, errno == ENOSYS is the standard way to
detect a missing syscall (e.g. to skip a selftest on older kernels);
- AVOID_BUG: "Do not crash the kernel" does not apply to userspace,
where BUG()/BUG_ON() are assert-like shims;
- SSCANF_TO_KSTRTO: kstrto<type> is not available in userspace.
Running "checkpatch.pl -f" (with --strict for AVOID_BUG, which is
a CHECK in file mode) on the files under tools/ that use ENOSYS, BUG()
or sscanf() gives 699 such warnings before this series (ENOSYS: 188,
AVOID_BUG: 491, SSCANF_TO_KSTRTO: 20), and none after.
Since tools/ also contains some kernel code (test modules, Kbuild-built
mocks, rvgen templates), patch 1 makes is_userspace() return false for
those locations, so they are still subject to all the kernel checks
(this also applies to the existing strcpy/strlcpy/strncpy checks).
Kir Kolyshkin (4):
checkpatch: is_userspace: exclude kernel code under tools/
checkpatch: don't warn about ENOSYS in userspace code
checkpatch: don't warn about BUG() in userspace code
checkpatch: don't suggest kstrto<type> in userspace code
scripts/checkpatch.pl | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
base-commit: f47d223627f80cb7a1eb14c585fe6cb35de5e984
--
2.56.0
next 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 Kir Kolyshkin [this message]
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 ` [PATCH 4/4] checkpatch: don't suggest kstrto<type> " Kir Kolyshkin
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-1-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®