Repository navigation
tools/kernel-pr-check: a checkpatch that can't run fails the check instead of passing it - #288
Conversation
checkpatch's stderr went to /dev/null and its exit status was never read: only ": ERROR:" lines in its report could fail the check. So a checker the merge base didn't have, one that didn't compile, died (as the real one does when --root isn't a kernel tree) or was killed printed nothing, and the empty report passed as "checkpatch --strict: no errors". Read the status as checkpatch sets it: 0 when it reports nothing, 1 when it reports something. Anything else, or a 1 with no diagnostic in the report, fails the check as "didn't run to the end", with the commit, the exit status and what checkpatch said: its stderr, and any stdout line that isn't a diagnostic (it prints some of its own failures there, such as a perl too old). Clean commits, warnings and errors read as before. tests/kernel-pr-check's stand-in now exits as checkpatch does, and covers a warning-only commit (still a pass) and a checker that crashes, doesn't compile, exits 1 with no report, dies on a signal or isn't in the merge base. --help prints the whole header again: it stopped a line short. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…deletes The builds delete and rewrite OUT/src, OUT/src-base, OUT/build and OUT/build-base, but --build was only refused inside the kernel tree. An OUT one level above a tree named src (-C /x/src --build /x) passed, and the builds' rm -rf of OUT/src deleted the checkout the tool promises never to touch. An OUT/src that holds a worktree's git directory went the same way, and a symlink at OUT/build into the tree had make build in the tree and the device-tree step delete its arch/arm64/boot/dts. Resolve every directory the builds delete or rewrite, symlinks included, and refuse an OUT where one of them is the tree or its git directory, holds it or lies inside it. The tree's own path is now resolved physically too, so a symlinked -C is compared by what it points at. An OUT beside the tree, or holding a tree under another name, still builds. The guard and the deletes share one list of what is deleted, so a new delete can't slip past it. The header says where the builds go, and --help now prints all of it (it stopped a line short before). tests/kernel-pr-check covers these layouts, and a symlink deeper in OUT/build, with an rm that records what it is asked to delete under the fixtures and deletes none of it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thank you. Reading checkpatch's exit status and showing its stderr only on failure is a clear improvement: a checker that never ran shouldn't read as "no errors". I checked the assumption it rests on against the real Because linux-omarchy-mobile's CI runs this tool from our As I said on #287: the two PRs each add a header line and both set |
|
Thanks. #310 changed this tool on
Your checkpatch changes merged cleanly into main's new |
…lers; --help prints the header, 3,48p)
…tions, --help 3,49p; tests: main's --no-checkpatch and trailer tests before the checker tests)
… one line longer here, 3,49p)
--help printed a hard-coded line range of the header comment, so every change to the header had to move the range by hand: #287 and #288 each added a header line and both set it to '3,37p', and with #310 on main the merged ranges became '3,46p' and '3,47p'. Whichever change missed the update cut the header's last line. On #287 the maintainer suggested working the range out from the file instead. --help now prints from line 3 to the first line that isn't a comment, with the awk line tools/nv-backup and tools/phone-provision already use (without their "# " stripping, so the output keeps its current form). On today's header its output is byte for byte what '3,49p' printed. tests/kernel-pr-check gains a check that runs --help on a copy of the tool with one more header line, and compares it with the header up to the line before `set -uo pipefail`. It failed with the old range (the last header line was missing) and passes with this change. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Fourteen tools printed --help as a hard-coded line range of their header comment (sed -n '3,NNp'), the pattern that cut kernel-pr-check's header after #287, #288 and #310 each edited it. On #287 the maintainer suggested working the range out from the file; #529 did that for kernel-pr-check alone. This moves all of them onto one helper, tools/lib/usage.sh: usage_from_header prints the comment lines from line 3 up to the first line that isn't a comment (#529's awk line), with "# " taken off or, with --raw, kept. Tools load it only for --help, so the copies the tests make of a tool, with only the lib files it needs, still run. kernel-pr-check moves onto it too. Ten tools print byte for byte what they printed before (cmp of stdout, stderr and exit status, and of phone-demo's and phone-mirror's error usage). Five ranges were already wrong, and print the header now: fetch-toolchain and build-flame-probe printed two lines of code after it; install-phone cut --reinstall, --unsigned and its last paragraph, build-rootfs cut --channel, and release cut its check-bundle stage. build-packages, phone-demo and release print only the start of a longer header, so the helper takes a paragraph count (a bare "#" line ends one) and their output stays what the range meant. install-phone keeps the awk line inline, as nv-backup and phone-provision already do: make-bundle ships these three alone, without tools/lib (review lesson L-497). tests/tools-help fails if any tool still hard-codes the range, and runs --help on every tool that prints its header (the helper's users and the three inline ones): it must print the header, or whole paragraphs from its start, and no code, and a copy whose header has grown by a line must print that line too. It replaces #529's single-tool check in tests/kernel-pr-check. On the base it fails on the range check, and the per-tool check fails for 13 of the 15 tools. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Derek Ross <derekross@gmail.com>
…stead of passing it (derekross#288) checkpatch's stderr went to /dev/null and its exit status was never read: only ": ERROR:" lines in its report could fail the check. So a checker the merge base didn't have, one that didn't compile, died (as the real one does when --root isn't a kernel tree) or was killed printed nothing, and the empty report passed as "checkpatch --strict: no errors". Read the status as checkpatch sets it: 0 when it reports nothing, 1 when it reports something. Anything else, or a 1 with no diagnostic in the report, fails the check as "didn't run to the end", with the commit, the exit status and what checkpatch said: its stderr, and any stdout line that isn't a diagnostic (it prints some of its own failures there, such as a perl too old). Clean commits, warnings and errors read as before. tests/kernel-pr-check's stand-in now exits as checkpatch does, and covers a warning-only commit (still a pass) and a checker that crashes, doesn't compile, exits 1 with no report, dies on a signal or isn't in the merge base. --help prints the whole header again: it stopped a line short. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ross#529) --help printed a hard-coded line range of the header comment, so every change to the header had to move the range by hand: derekross#287 and derekross#288 each added a header line and both set it to '3,37p', and with derekross#310 on main the merged ranges became '3,46p' and '3,47p'. Whichever change missed the update cut the header's last line. On derekross#287 the maintainer suggested working the range out from the file instead. --help now prints from line 3 to the first line that isn't a comment, with the awk line tools/nv-backup and tools/phone-provision already use (without their "# " stripping, so the output keeps its current form). On today's header its output is byte for byte what '3,49p' printed. tests/kernel-pr-check gains a check that runs --help on a copy of the tool with one more header line, and compares it with the header up to the line before `set -uo pipefail`. It failed with the old range (the last header line was missing) and passes with this change. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…ekross#559) Fourteen tools printed --help as a hard-coded line range of their header comment (sed -n '3,NNp'), the pattern that cut kernel-pr-check's header after derekross#287, derekross#288 and derekross#310 each edited it. On derekross#287 the maintainer suggested working the range out from the file; derekross#529 did that for kernel-pr-check alone. This moves all of them onto one helper, tools/lib/usage.sh: usage_from_header prints the comment lines from line 3 up to the first line that isn't a comment (derekross#529's awk line), with "# " taken off or, with --raw, kept. Tools load it only for --help, so the copies the tests make of a tool, with only the lib files it needs, still run. kernel-pr-check moves onto it too. Ten tools print byte for byte what they printed before (cmp of stdout, stderr and exit status, and of phone-demo's and phone-mirror's error usage). Five ranges were already wrong, and print the header now: fetch-toolchain and build-flame-probe printed two lines of code after it; install-phone cut --reinstall, --unsigned and its last paragraph, build-rootfs cut --channel, and release cut its check-bundle stage. build-packages, phone-demo and release print only the start of a longer header, so the helper takes a paragraph count (a bare "#" line ends one) and their output stays what the range meant. install-phone keeps the awk line inline, as nv-backup and phone-provision already do: make-bundle ships these three alone, without tools/lib (review lesson L-497). tests/tools-help fails if any tool still hard-codes the range, and runs --help on every tool that prints its header (the helper's users and the three inline ones): it must print the header, or whole paragraphs from its start, and no code, and a copy whose header has grown by a line must print that line too. It replaces derekross#529's single-tool check in tests/kernel-pr-check. On the base it fails on the range check, and the per-tool check fails for 13 of the 15 tools. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Derek Ross <derekross@gmail.com>
What and why
If checkpatch couldn't run,
tools/kernel-pr-checkreported "checkpatch --strict: no errors". It threw away checkpatch's stderr and never read its exit status, so only: ERROR:lines could fail the check. A checker missing from the merge base, one that didn't compile, or one that died or was killed produced an empty report, and that empty report passed. Example: the real checkpatch dies with "--root does not point at a valid tree" (exit 2) when the tree it checks against isn't a kernel tree.The check now reads checkpatch's exit status as checkpatch sets it: 0 when it reports nothing, 1 when it reports something. Anything else, or a 1 with no diagnostic in the report, fails as "checkpatch --strict didn't run to the end". The failure names the commit and the exit status, and shows what checkpatch said: its stderr and any non-diagnostic stdout line. Clean commits, warnings and errors read as before.
--helpalso prints the header's last line again, which it had been cutting off.Device and build
tools/kernel-pr-checkruns on the laptop and in CI, never on a phone; CONTRIBUTING §6.5)uname -r): n/aChecks (no phone needed)
tools/pr-check origin/mainpassestests/allpassestests/packagespasses: not run, no package touchedversionbumped: n/a, no package changedCo-Authored-By:orAssisted-by:trailer, never aSigned-off-by:tests/kernel-pr-checkcovers each of these:Its stand-in checkpatch now exits as the real one does. Run against the old tool, the new tests fail at the first new case: "a crashing checker: exit 0, expected 1".
I also checked against upstream's own
scripts/checkpatch.plon a stand-in kernel tree, without committing it:--rootnow fails, where it used to pass as "no errors".On the phone
--buildpath (unchanged by this PR)userdata, weakens the storage guard, or reads registers from userspace (AGENTS.md §1)Found by Opus 5.5 High, Terra 6.1 Max, Kimi K3.1 High and Sol 6.1 xhigh (OPUS-S14-005; TERRA-BUILD_INSTALL-016; KIMI-S02-011; SOL-XHIGH-R2:release_build:SOL61XH-R2-RB-018).
Generated with Claude Opus 5.5 and GPT-6.1 Sol in T3 Code Nightly