Repository navigation
os/, tools/, onnx/: the same usage-range defect, seven of eight already leaking code - #2262
Conversation
…dy leaking code #2258 fixed `scripts/`: usage text built from `sed -n '16,62p' "$0"`, which is a claim about a file's shape and stops being true when the header above it is edited. The same pattern is in eight more files outside `scripts/`, and **seven had already drifted past the end of their header** -- measured statically, by comparing the range's end with the first line of code: os/v2/mkdebs.sh range 22,45 code starts 44 -> prints code os/v2/mkrepo.sh range 21,27 code starts 23 -> prints code os/v2/mkrootfs.sh range 21,32 code starts 32 -> prints code os/v2/proto.sh range 21,32 code starts 27 -> prints code os/v2/vmtest-v2.sh range 21,34 code starts 31 -> prints code os/v3/puppy/demo-seq-probe.sh range 28,48 code starts 44 -> prints code tools/xhci_keepawake_check.sh range 17,40 code starts 37 -> prints code onnx/bench_npu.sh range 2,30 header ends 45 -> prints only PART of its help (the other direction) `tools/xhci_keepawake_check.sh` is the one that matters most: `docs/axb35-usb-ports.md` and the release notes tell a person to run it with `--require-awake`, and `--help` on it printed code instead of the header. All eight now use the anchored extraction from #2258, defined below the first line of code so its own comment cannot leak: usage() { awk 'NR>1 && /^#/ {sub(/^# ?/,""); print; next} NR>1 {exit}' "$0"; } Verified **statically, without executing them** -- several of these reach for devices (`bench_npu.sh` opens the NPU, which is off by owner order; `demo-seq-probe.sh` and `vmtest-v2.sh` too), and #2258's lesson was that running a help path can take a resource. So: * every file: `bash -n` clean, exactly one `usage()` definition, no self-recursive body, no other line ranges left; * each `usage()` output simulated with the same awk: 16-37 lines of prose, **zero** code-like lines, and `bench_npu.sh` now prints its whole header instead of the first 29 lines of it.
|
VERDICT: READY at Seven printed code, one printed part of itself
Seven where the end overshoots the code start, one where the start undershoots the header. That symmetry is what proves the diagnosis: this is not "the ranges are a bit off", it is a line number standing in for a structural fact — where the usage text ends — and every time a file grows, the number becomes wrong in one direction or the other.
Two asks
Why this is the same defect as #2256 in a different costume#2256 found five tools where |
|
VERDICT: READY at Seven of the eight had already drifted, and the table in the body is the right evidence: each row compares the range's end against the first line of code, e.g. One ask, and it is the same one I made on #2258 — so this is a request for one decision covering both PRs rather than two review notes: the anchored Second, smaller: if the same four-line Scope of my check: the diff's file list (16 files, +48/−117), |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
The same defect #2258 fixed in
scripts/, in the eight places outside it — and it is worse there: seven had already drifted.Measured statically, by comparing each range's end against the first line of code
os/v2/mkdebs.sh22,45os/v2/mkrepo.sh21,27os/v2/mkrootfs.sh21,32os/v2/proto.sh21,32os/v2/vmtest-v2.sh21,34os/v3/puppy/demo-seq-probe.sh28,48tools/xhci_keepawake_check.sh17,40onnx/bench_npu.sh2,30tools/xhci_keepawake_check.shis the one that matters most:docs/axb35-usb-ports.mdand the release notes tell a person to run it with--require-awake, and asking it for--helpprinted code instead of its header.The fix
The anchored extraction from #2258, defined below the first line of code so the function's own comment cannot leak into its output:
Verified without executing any of them
Several of these reach for devices —
bench_npu.shopens the NPU (off by owner order),demo-seq-probe.shandvmtest-v2.shtoo — and #2258's lesson was that running a help path can take a resource. So this PR is verified statically:bash -nclean, exactly oneusage()definition, no self-recursive body (the trap that producedusage() { usage; }in scripts: usage texts stop leaking code, and hw-gate's no-argument path stops taking a GPU ticket #2258), no other line ranges left;usage()output simulated with the same awk: 16–37 lines of prose, zero code-like lines;bench_npu.shnow prints its whole header rather than its first 29 lines.Two of these are legacy (
os/v2/), and I fixed them anyway because they are checked in, documented, and the bug is the same one: someone asking a script how to use it should not have to read shell code to find out.