Skip to content

checkpatch: skip more kernel-only checks for userspace code

Kir Kolyshkin linux-kselftest lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4checkpatch: is_userspace: exclude kernel code under tools/scripts/checkpatch.pl+6 -00 replies
2/4checkpatch: don't warn about ENOSYS in userspace codescripts/checkpatch.pl+1 -10 replies
3/4checkpatch: don't warn about BUG() in userspace codescripts/checkpatch.pl+3 -20 replies
4/4checkpatch: don't suggest kstrto<type> in userspace codescripts/checkpatch.pl+2 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/4] checkpatch: skip more kernel-only checks for userspace code

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

Signature · 1 line
2.56.0