checkpatch: skip more kernel-only checks for userspace code
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest4 patches 0 repliesNew
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | checkpatch: is_userspace: exclude kernel code under tools/scripts/ | +6 | 0 replies | |
| 2/4 | checkpatch: don't warn about ENOSYS in userspace codescripts/ | +1 | 0 replies | |
| 3/4 | checkpatch: don't warn about BUG() in userspace codescripts/ | +3 | 0 replies | |
| 4/4 | checkpatch: don't suggest kstrto<type> in userspace codescripts/ | +2 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
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