mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/4] checkpatch: skip more kernel-only checks for userspace code
@ 2026-10-22 22:44 Kir Kolyshkin
  2026-10-22 22:44 ` [PATCH 1/4] checkpatch: is_userspace: exclude kernel code under tools/ Kir Kolyshkin
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Kir Kolyshkin @ 2026-10-22 22:44 UTC (permalink / raw)
  To: Joe Perches, Andy Whitcroft, Andrew Morton
  Cc: Kir Kolyshkin, Dwaipayan Ray, Lukas Bulwahn, Shuah Khan,
	linux-kselftest, linux-kernel

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-22 22:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-22 22:44 [PATCH 0/4] checkpatch: skip more kernel-only checks for userspace code 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 ` [PATCH 4/4] checkpatch: don't suggest kstrto<type> " Kir Kolyshkin

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®