Code review fix-pass: tiers 0-15#30
Merged
Merged
Conversation
Apply analyzed fixes from local/gs-docs/reviews/core-review-straightforward-full.md
covering all 16 review tiers. Each finding was read against the actual code,
fixed when the change was clear-cut and low-risk, or marked NOT FIXED with a
concrete per-finding justification (cross-tier dependency, signature change
required, self-resolved, etc.) — no bulk-deferred entries remain.
Highlights by tier:
- Tier 9 (storage): journal-load error propagation, ftruncate-based zero-fill
(replaces 40k-iteration write loops), race-safe fopen, archive.c mkdir-p +
dead verbose flag, checkpoint_machine JSON escaping + sweep_others NULL
guards, checkpoint.c CHECKPOINT_MAX_ALLOC caps, snprintf model_id, bail-on-
fopen-failure (replaces silent zero-fill corruption).
- Tier 10 (networking): O(2^n) NBP wildcard matcher rewritten as iterative
two-pointer O(n*m) (closes a CPU-exhaustion DoS); process_packet/llap_in
made const-correct end-to-end; llap_send oversize rejection; MAX_SHARES
made module-private; emit_json_escaped for hostile APM partition names;
dead includes and Phase-5c tombstone comments removed.
- Tier 11 (debugger): macos_atrap_name lookup-result-discarded bug;
trace-buffer ring corruption on first wrap; framebuffer checksum static-
accum-byte concurrency hazard; mnemonic-buffer bounds check; O(N²) clear
loops replaced with bulk helpers; malloc→calloc for zero-init.
- Tier 12 (shell): V_BYTES inline-render cap (64 + "...N more"); emit_json_
escaped for partition name/type; ${...} body size cap; dead ternary in cp.
- Tier 13 (system): config_get_image bounds check; config_add_image runtime
check (was assert-only — silent overflow in release builds); printf→LOG
across system_ensure_machine; drive_catalog_find_closest NULL checks.
- Tier 14 (machines): IICX_*_IO_PENALTY triple-definition consolidated; soft-
power-off log level corrected (0→1); dead SE30_RAM_END / PLUS_RAM_TOP
removed; via2_output collapsed.
- Tier 15 (platform): platform_ticks 32-bit time_t overflow fix; gs_download
returns -1 on failure (was always 0) + short-read detection; redundant
global_emulator clobber removed; dead run_startup_command + rolling-
instruction-counter tracking removed; platform_play_8bit_pwm const-correct.
Earlier tiers (0-8) cover CPU/memory/mmu/peripherals/VFS fixes from prior
review sessions in this same pass.
Two issues surfaced after the Tier 0-15 review pass landed: - `tests/unit/support/stub_memory.c`: the test stub declared `int g_page_count` but the real `memory.h` now declares it `uint32_t` (Tier-4 type tightening). The mismatch broke unit compilation in CI's "Run unit tests (CPU)" step. - `src/core/cpu/cpu_internal.h`: the Tier-5 MOVEM post-increment refactor introduced "skip writeback when An is in the register list" on 68000, citing M68000PRM. The cpu test vectors expect the post-incremented `ea` to always win — failures show the expected-vs-actual delta is exactly N_regs * size, the post-increment amount. Reverted to the prior always-writeback logic that matches the captured test data. Local: tests/unit/run → 14/14 suites pass; make integration-test → 38/38 pass. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Batch fix-pass driven by
local/gs-docs/reviews/core-review-straightforward-full.md. Each of the ~900 findings was read against the actual code, fixed when the change was clear-cut and low-risk, or marked NOT FIXED with a per-finding justification (cross-tier dependency, signature change required, self-resolved, etc.) — no bulk-deferred entries remain in the review file.Highlights by tier
ftruncate-based zero-fill replaces 40k-iteration write loops; race-safefopen; archive.cmkdir-p+ dead verbose flag; checkpoint_machine JSON escaping +sweep_othersNULL guards; checkpoint.cCHECKPOINT_MAX_ALLOCcaps;snprintfmodel_id; bail-on-fopen-failure (replaces silent zero-fill corruption).process_packet/llap_inconst-correct end-to-end;llap_sendoversize rejection;MAX_SHARESmodule-private;emit_json_escapedfor hostile APM partition names; dead includes and Phase-5c tombstone comments removed.macos_atrap_namelookup-result-discarded bug; trace ring-buffer corruption on first wrap; framebuffer-checksum static-accum-byte concurrency hazard; mnemonic buffer bounds check; O(N²) clear loops replaced with bulk helpers;malloc→callocfor zero-init.V_BYTESinline-render cap (64 + "...N more");emit_json_escapedfor partition name/type;${...}body-size cap; dead ternary incp.config_get_imagebounds check;config_add_imageruntime check (was assert-only — silent overflow in release builds);printf→LOGacrosssystem_ensure_machine;drive_catalog_find_closestNULL checks.IICX_*_IO_PENALTYtriple-definition consolidated; soft-power-off log level corrected (0→1); dead constants removed; via2_output collapsed.platform_ticks32-bittime_toverflow fix;gs_downloadreturns -1 on failure (was always 0) + short-read detection; redundantglobal_emulatorclobber removed; deadrun_startup_command+ rolling-instruction-counter tracking removed;platform_play_8bit_pwmconst-correct.CI follow-up commit
Initial CI run failed in "Run unit tests (CPU)" with a type-mismatch in
tests/unit/support/stub_memory.c(test stub still declaredint g_page_countafter the Tier-4 header change touint32_t). Fixing that locally revealed a second regression: the Tier-5 MOVEM post-increment refactor incpu_internal.hintroduced "skip An writeback when An is in the list (on 68000)", citing M68000PRM — but the CPU test vectors expect the post-incrementedeato always win (expected/actual deltas are exactlyN_regs * size). Reverted to the prior always-writeback logic.Test plan
make headless— cleanmake -C tests/unit run— 14/14 suites passmake integration-test— 38/38 pass🤖 Generated with Claude Code