fix(chans): preserve wrapped hex-count rounding without signed overflow #1048
Reference in New Issue
Block a user
Delete Branch "agent/bittle/chans-rounding-review"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Reachable source-width correction
Both hexadecimal-size passes in VmBlobPackCommon evaluated (count + 1) / 2 in signed 32-bit arithmetic. The existing parser accepts H2147483647, so that addition has signed-overflow UB. Perform only the addition in u32, convert the wrapped word to s32, then preserve the existing signed division and all surrounding error checks.
The original PPC produces -1073741824 at INT_MAX; this patch preserves that result and the signed 64-bit argument passed to the existing space check. It does not replace it with positive rounding. The out-of-range u32-to-s32 conversion is implementation-defined in C; configured MWCC and host GCC bit-preserving behavior were verified. No universal C-portability claim or fuzzy gain.
Independent verification
Rebased and tested on 409ef82dd8fe5f2416540b7b3037451b0cd43a33; tree
7c50ee9bae.These are focused arithmetic/parser/original-slice tests, not a complete VM or Wii runtime test. Detailed evidence and separately rejected union trial: tools/decomp-assist/CHANSVm-pack-rounding-20261003.md. No linking flags or other regions changed.
Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.