fix(nwc24): use a defined unsigned retry mask #1006

Merged
coah80 merged 1 commits from agent/bittle/download-retry-mask into main 2026-10-03 00:43:12 +00:00
coah80 commented 2026-10-03 00:42:27 +00:00 (Migrated from github.com)

Correctness fix

The validated retry-count range includes 31. Shifting signed 1 by 31 is undefined in C; use 1U for the existing 32-bit retry mask. Error precedence and all accepted/rejected inputs are preserved.

Independent verification

  • Complete NWC24Download object and all 1027 report measures unchanged; every allocated byte and normalized relocation unchanged
  • Exact functions 26/30, code 8456/12496, data 80/80 and fuzzy 99.169655% preserved
  • Parent verified the harness contains the exact production helper and reran 270,336 cases under UBSan: all byte counts, boundary/one-hot/complement masks, enable states and validation outcomes
  • The baseline reproducer fails at count 31 with the expected signed-shift diagnostic; the corrected helper passes
  • All 26 exact functions retain ctxdiff zero; pool 3/3 and literal audit clean
  • Full 43U all_source/report/progress/DOL and worktree/diff checks pass

This is a local predicate test, not network/filesystem integration. No percentage gain, new exact function, header, layout, metadata or linking change claimed.

Parent baseline: e4a9449256
Tested tree: 0a81776259
DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d

No merge performed or requested by this author.

Note

Use unsigned shift for retry mask in nwc24.CheckDlTaskRetry

Replaces the signed left shift used to test the high bit of the u32 retry mask in nwc24.CheckDlTaskRetry with an unsigned shift. Signed left shift of 1 << 31 is undefined behavior in C. Validation order, retry-count bounds, and disabled-result handling are unchanged. Adds an audit record in nwc24-download-retry-mask-20261003.md covering the change, rejected alternatives, and binary-comparison results.

Macroscope summarized 656fe85.

## Correctness fix The validated retry-count range includes 31. Shifting signed 1 by 31 is undefined in C; use 1U for the existing 32-bit retry mask. Error precedence and all accepted/rejected inputs are preserved. ## Independent verification - Complete NWC24Download object and all 1027 report measures unchanged; every allocated byte and normalized relocation unchanged - Exact functions 26/30, code 8456/12496, data 80/80 and fuzzy 99.169655% preserved - Parent verified the harness contains the exact production helper and reran 270,336 cases under UBSan: all byte counts, boundary/one-hot/complement masks, enable states and validation outcomes - The baseline reproducer fails at count 31 with the expected signed-shift diagnostic; the corrected helper passes - All 26 exact functions retain ctxdiff zero; pool 3/3 and literal audit clean - Full 43U all_source/report/progress/DOL and worktree/diff checks pass This is a local predicate test, not network/filesystem integration. No percentage gain, new exact function, header, layout, metadata or linking change claimed. Parent baseline: e4a9449256b34b8a7047fe45c204116ed26e3b5b Tested tree: 0a81776259d43170c898d3ffce3cedf0dc57d38c DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d No merge performed or requested by this author. <!-- Macroscope's pull request summary starts here --> <!-- Macroscope will only edit the content between these invisible markers, and the markers themselves will not be visible in the GitHub rendered markdown. --> <!-- If you delete either of the start / end markers from your PR's description, Macroscope will append its summary at the bottom of the description. --> > [!NOTE] > ### Use unsigned shift for retry mask in `nwc24.CheckDlTaskRetry` > Replaces the signed left shift used to test the high bit of the u32 retry mask in `nwc24.CheckDlTaskRetry` with an unsigned shift. Signed left shift of `1 << 31` is undefined behavior in C. Validation order, retry-count bounds, and disabled-result handling are unchanged. Adds an audit record in [nwc24-download-retry-mask-20261003.md](https://github.com/coah80/wii-ipl/pull/1006/files#diff-206d956b96ccc62c7443ec2ec49d151a57b3770f584f749bec99cc5f6149d862) covering the change, rejected alternatives, and binary-comparison results. > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized 656fe85.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here -->
coah80 commented 2026-10-03 00:43:10 +00:00 (Migrated from github.com)

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.
Sign in to join this conversation.