fix(libc): convert scanf integers as FreeBSD does on Windows #9479

Merged
EagleBearerYS merged 6 commits from upstream-pr/9479 into main 2026-10-25 19:52:27 +00:00
EagleBearerYS commented 2026-10-21 23:01:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T23:01:32Z.


What

On Windows the scanf family (sscanf, vsscanf, fscanf and their callers) translates the guest's length modifiers and hands the format to the host's scanner. Two integer cases differ from FreeBSD 11.4's vfscanf.

  1. A %d, %i, %o, %u, %x or %X without a length modifier, or with h or hh, goes to the host unchanged. The host converts it with its 32-bit long, so an out-of-range value is clamped and errno set to ERANGE. FreeBSD converts every integer with strtoimax or strtoumax and stores the result truncated to the destination type (vfscanf.c L741-L771).
  2. q, FreeBSD's quad length modifier, is not recognized, so %qd, %qu and %qx throw NotImplemented_nid_no_patch ("vsscanf format conversion"). FreeBSD's source treats q like ll (vfscanf.c L529-L531), but the console's own libc doesn't: run natively from three titles, its sscanf returns 0 for %qd and stores nothing (@JJenkx's comment). The console's behaviour overrides FreeBSD 11.4's source here.

Measured with main's code:

Input Format Windows Linux, and FreeBSD
"2147483648" %d 2147483647, errno 34 -2147483648
"3000000000" %i 2147483647, errno 34 -1294967296
"4294967296" %u 4294967295, errno 34 0
"100000000" %x 4294967295, errno 34 0
"3000000000" %qd throws 3000000000 (the console's libc: 0, nothing stored)

A colour or mask written as 0xFFFFFFFF and read with %i into an int therefore comes back as 0x7FFFFFFF.

ScanWindowsArguments_nid_no_patch (WindowsScanning.hpp) now does two things:

  • A q directive ends the scan there with nothing stored, as the console's libc does for %qd, and the count of conversions before it is returned. What the console does with a q after other conversions isn't measured.
  • It scans such a 32-bit-or-narrower conversion as ll into a temporary of the conversion's signedness: long long for %d and %i, unsigned long long for %o, %u, %x and %X. A %n after it shows whether the conversion took place. The value is then stored truncated to the destination's int, short or char, signed or unsigned to match, as FreeBSD's assignment does.

A value beyond the 64-bit range still sets ERANGE, as strtoimax does there. Linux hands the format to glibc, which already truncates this way but reads q as ll; the libc debt file records that difference. No title is claimed.

Overlap, merge order agreed: #9087 also adds a check function after CheckWidePrecision in core/libs/tests/Formatting.cpp and a call at the end of RunChecks, so the two conflict in that test file. Their library changes are in different files: #9087's in Formatting.cpp and WindowsFormatting.hpp, this PR's in WindowsScanning.hpp. This PR merges first, and #9087 then rebases its test file over it, keeping both check functions and both calls; orezraey agreed to that order (comment).

Tested

On GitHub's runners from my fork, merged with main at a6dcea9279 (run):

  • New CheckIntegerScanWidths in guest_formatting checks:
    • truncation for %d, %i ("0xFFFFFFFF" gives -1), %u, %x, %o, %hd ("5000000000" gives -3584) and %hhd ("300" gives 44), with errno left alone;
    • ERANGE for "99999999999999999999" with %d (-1);
    • unsigned destinations above the signed range: %u of 4294967295, %hu of 40000 and of 70000 (4464), %hx of ffff, %hhu of 200 and of 300 (44), and %hho of 377 (255);
    • %qd and %qx;
    • that %n still counts after the new conversions, and that a failed conversion leaves its destination unchanged.
  • Windows: with main's WindowsScanning.hpp guest_formatting fails. With the change it passes 10 runs in a row.
  • Linux: guest_formatting passes with main's code and, 10 runs in a row, with the change; the code change does not apply there, and glibc already gives these results.
  • On both, every test registered under core/libs/prx/libc and core/libs/prx/libkernel passes: 115 and 197 on Linux, 142 and 207 on Windows.
  • The signedness commit, b39956b4e1, after MarcZX10's review (run): guest_formatting passes 10 runs in a row on both. The new unsigned checks also pass with the previous head, since both hosts store the same bits there. In that run's Windows libkernel suite, guest_raise_in_system_call timed out after 30 s with and without the commit.
  • After the merge with main at da54c652e3 (8fab12951e, no conflicts, the PR's own diff unchanged; run): guest_formatting fails on Windows with main's WindowsScanning.hpp; with the change, guest_formatting and guest_wide_formatting pass 10 runs in a row on both runners. The libc and libkernel suites pass on both (116 and 197 on Linux, 143 and 207 on Windows).
  • tools/check_conventions.py --base origin/main passes.
  • Against titles' own libc.prx, by @JJenkx (comment): head 8fab12951e merged onto main f1db096084, on Windows 11 with GCC 15.2.0 UCRT, Release. A loader runs a title's decrypted libc.prx natively and compares its sscanf with this build's on 60,000 random inputs per format, checking the result, the value, the %n count and errno. The copies bundled with three titles give the same counts.
    • %d, %u, %hd and %hhd match the console on all 60,000 inputs each. On main 16,892, 7,541, 7,455 and 7,499 of them differ.
    • %i and %x go from 20,669 and 14,643 differences on main to 3,521 and 3,597. %o, %lld and %3d match on both trees, and %lli and %llx differ as much as on main.
    • The %i and %x differences left, here and on main, are one case: a 0x prefix with no hexadecimal digit after it, which the console treats as a matching failure. That matching rule is outside this PR.
    • ctest -R 'scan|format|stream|libc|wide|string' selects 44 tests, and all pass in three runs of three.
  • The console's sscanf on fixed inputs, by @JJenkx (comment): the libc.prx bundled with PPSA07923, PPSA13934 and PPSA35169, loaded natively on Windows, into a 64-bit destination filled with 0x55…; all three give the same results.
    • Narrow conversions wrap without errno: 2147483648 and -2147483649 with %d give 0x80000000 and 0x7fffffff, 4294967296 and -1 with %u give 0 and 0xffffffff, 99999999999 with %x gives 0x99999999, 300 with %hhd gives 0x2c and 70000 with %hd gives 0x1170. Only the 64-bit ones saturate with ERANGE: %lld and %llu past their range.
    • %qd of 5 returns 0 and stores nothing, which this PR now does too (a809ad7d2f).
  • a809ad7d2f, the q change (run): CheckIntegerScanWidths takes those rows, and %qd of 5 must return 0 with the destination unchanged (Windows only, since Linux goes to glibc).
    • Red on Windows with the previous WindowsScanning.hpp: guest_formatting fails. On Linux it passes before and after, as the change doesn't apply there.
    • Green: guest_formatting and guest_wide_formatting pass 10 runs in a row on both runners, 2 of 2 each, none skipped. The libc and libkernel suites pass on both, run with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • On a PS5, by @rooklz (comment): a payload calling the console's own fscanf on a file in /data. %d on 99999999999 returns 1 and stores 0x4876e7ff with errno 0, %hhd on 300 stores 0x2c, %u on -1 stores 0xffffffff, and %lld on -9223372036854775809 stores INT64_MIN with errno 34: the FreeBSD conversion this PR gives Windows, as they say. They also report two differences from glibc outside this PR: %i on 0x returns -1, and %x on 0xZ returns 0 with Z next, where glibc returns 1 with 0 stored for both.
  • Not tested: macOS, any title.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none (merges before #9087, agreed in its thread; see Overlap)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4959508329 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9479). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-21T23:01:32Z. --- ### What On Windows the scanf family (`sscanf`, `vsscanf`, `fscanf` and their callers) translates the guest's length modifiers and hands the format to the host's scanner. Two integer cases differ from FreeBSD 11.4's `vfscanf`. 1. A `%d`, `%i`, `%o`, `%u`, `%x` or `%X` without a length modifier, or with `h` or `hh`, goes to the host unchanged. The host converts it with its 32-bit `long`, so an out-of-range value is clamped and `errno` set to `ERANGE`. FreeBSD converts every integer with `strtoimax` or `strtoumax` and stores the result truncated to the destination type ([`vfscanf.c` L741-L771](https://github.com/freebsd/freebsd-src/blob/d106002967eff712894ab8b5337bbbff106ce5e0/lib/libc/stdio/vfscanf.c#L741-L771)). 2. `q`, FreeBSD's quad length modifier, is not recognized, so `%qd`, `%qu` and `%qx` throw `NotImplemented_nid_no_patch` ("vsscanf format conversion"). FreeBSD's source treats `q` like `ll` ([`vfscanf.c` L529-L531](https://github.com/freebsd/freebsd-src/blob/d106002967eff712894ab8b5337bbbff106ce5e0/lib/libc/stdio/vfscanf.c#L529-L531)), but the console's own libc doesn't: run natively from three titles, its `sscanf` returns 0 for `%qd` and stores nothing ([@JJenkx's comment](https://github.com/boykopovar/AnyPS5/pull/9479#issuecomment-6374300430)). The console's behaviour overrides FreeBSD 11.4's source here. Measured with `main`'s code: | Input | Format | Windows | Linux, and FreeBSD | |---|---|---|---| | `"2147483648"` | `%d` | 2147483647, `errno` 34 | -2147483648 | | `"3000000000"` | `%i` | 2147483647, `errno` 34 | -1294967296 | | `"4294967296"` | `%u` | 4294967295, `errno` 34 | 0 | | `"100000000"` | `%x` | 4294967295, `errno` 34 | 0 | | `"3000000000"` | `%qd` | throws | 3000000000 (the console's libc: 0, nothing stored) | A colour or mask written as `0xFFFFFFFF` and read with `%i` into an `int` therefore comes back as `0x7FFFFFFF`. `ScanWindowsArguments_nid_no_patch` (`WindowsScanning.hpp`) now does two things: - A `q` directive ends the scan there with nothing stored, as the console's libc does for `%qd`, and the count of conversions before it is returned. What the console does with a `q` after other conversions isn't measured. - It scans such a 32-bit-or-narrower conversion as `ll` into a temporary of the conversion's signedness: `long long` for `%d` and `%i`, `unsigned long long` for `%o`, `%u`, `%x` and `%X`. A `%n` after it shows whether the conversion took place. The value is then stored truncated to the destination's `int`, `short` or `char`, signed or unsigned to match, as FreeBSD's assignment does. A value beyond the 64-bit range still sets `ERANGE`, as `strtoimax` does there. Linux hands the format to glibc, which already truncates this way but reads `q` as `ll`; the libc debt file records that difference. No title is claimed. **Overlap, merge order agreed:** #9087 also adds a check function after `CheckWidePrecision` in `core/libs/tests/Formatting.cpp` and a call at the end of `RunChecks`, so the two conflict in that test file. Their library changes are in different files: #9087's in `Formatting.cpp` and `WindowsFormatting.hpp`, this PR's in `WindowsScanning.hpp`. This PR merges first, and #9087 then rebases its test file over it, keeping both check functions and both calls; orezraey agreed to that order ([comment](https://github.com/boykopovar/AnyPS5/pull/9087#issuecomment-6332231843)). ### Tested On GitHub's runners from my fork, merged with `main` at a6dcea9279 ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39686899496)): - New `CheckIntegerScanWidths` in `guest_formatting` checks: - truncation for `%d`, `%i` (`"0xFFFFFFFF"` gives -1), `%u`, `%x`, `%o`, `%hd` (`"5000000000"` gives -3584) and `%hhd` (`"300"` gives 44), with `errno` left alone; - `ERANGE` for `"99999999999999999999"` with `%d` (-1); - unsigned destinations above the signed range: `%u` of `4294967295`, `%hu` of `40000` and of `70000` (4464), `%hx` of `ffff`, `%hhu` of `200` and of `300` (44), and `%hho` of `377` (255); - `%qd` and `%qx`; - that `%n` still counts after the new conversions, and that a failed conversion leaves its destination unchanged. - Windows: with `main`'s `WindowsScanning.hpp` `guest_formatting` fails. With the change it passes 10 runs in a row. - Linux: `guest_formatting` passes with `main`'s code and, 10 runs in a row, with the change; the code change does not apply there, and glibc already gives these results. - On both, every test registered under `core/libs/prx/libc` and `core/libs/prx/libkernel` passes: 115 and 197 on Linux, 142 and 207 on Windows. - The signedness commit, b39956b4e1, after MarcZX10's review ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39691115114)): `guest_formatting` passes 10 runs in a row on both. The new unsigned checks also pass with the previous head, since both hosts store the same bits there. In that run's Windows libkernel suite, `guest_raise_in_system_call` timed out after 30 s with and without the commit. - **After the merge with `main` at da54c652e3** (8fab12951e, no conflicts, the PR's own diff unchanged; [run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39728826593)): `guest_formatting` fails on Windows with `main`'s `WindowsScanning.hpp`; with the change, `guest_formatting` and `guest_wide_formatting` pass 10 runs in a row on both runners. The libc and libkernel suites pass on both (116 and 197 on Linux, 143 and 207 on Windows). - `tools/check_conventions.py --base origin/main` passes. - **Against titles' own `libc.prx`, by @JJenkx** ([comment](https://github.com/boykopovar/AnyPS5/pull/9479#issuecomment-6354017958)): head 8fab12951e merged onto `main` f1db096084, on Windows 11 with GCC 15.2.0 UCRT, Release. A loader runs a title's decrypted `libc.prx` natively and compares its `sscanf` with this build's on 60,000 random inputs per format, checking the result, the value, the `%n` count and `errno`. The copies bundled with three titles give the same counts. - `%d`, `%u`, `%hd` and `%hhd` match the console on all 60,000 inputs each. On `main` 16,892, 7,541, 7,455 and 7,499 of them differ. - `%i` and `%x` go from 20,669 and 14,643 differences on `main` to 3,521 and 3,597. `%o`, `%lld` and `%3d` match on both trees, and `%lli` and `%llx` differ as much as on `main`. - The `%i` and `%x` differences left, here and on `main`, are one case: a `0x` prefix with no hexadecimal digit after it, which the console treats as a matching failure. That matching rule is outside this PR. - `ctest -R 'scan|format|stream|libc|wide|string'` selects 44 tests, and all pass in three runs of three. - **The console's `sscanf` on fixed inputs, by @JJenkx** ([comment](https://github.com/boykopovar/AnyPS5/pull/9479#issuecomment-6374300430)): the `libc.prx` bundled with PPSA07923, PPSA13934 and PPSA35169, loaded natively on Windows, into a 64-bit destination filled with `0x55…`; all three give the same results. - Narrow conversions wrap without `errno`: `2147483648` and `-2147483649` with `%d` give `0x80000000` and `0x7fffffff`, `4294967296` and `-1` with `%u` give 0 and `0xffffffff`, `99999999999` with `%x` gives `0x99999999`, `300` with `%hhd` gives `0x2c` and `70000` with `%hd` gives `0x1170`. Only the 64-bit ones saturate with `ERANGE`: `%lld` and `%llu` past their range. - `%qd` of `5` returns 0 and stores nothing, which this PR now does too (a809ad7d2f). - **a809ad7d2f, the `q` change** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40054185571)): `CheckIntegerScanWidths` takes those rows, and `%qd` of `5` must return 0 with the destination unchanged (Windows only, since Linux goes to glibc). - **Red** on Windows with the previous `WindowsScanning.hpp`: `guest_formatting` fails. On Linux it passes before and after, as the change doesn't apply there. - **Green:** `guest_formatting` and `guest_wide_formatting` pass 10 runs in a row on both runners, 2 of 2 each, none skipped. The libc and libkernel suites pass on both, run with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **On a PS5, by @rooklz** ([comment](https://github.com/boykopovar/AnyPS5/pull/9479#issuecomment-6390876469)): a payload calling the console's own `fscanf` on a file in `/data`. `%d` on `99999999999` returns 1 and stores `0x4876e7ff` with `errno` 0, `%hhd` on `300` stores `0x2c`, `%u` on `-1` stores `0xffffffff`, and `%lld` on `-9223372036854775809` stores `INT64_MIN` with `errno` 34: the FreeBSD conversion this PR gives Windows, as they say. They also report two differences from glibc outside this PR: `%i` on `0x` returns -1, and `%x` on `0xZ` returns 0 with `Z` next, where glibc returns 1 with 0 stored for both. - Not tested: macOS, any title. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none (merges before #9087, agreed in its thread; see Overlap) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-21 23:03:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T23:03:19Z.

Code review location: core/libs/prx/libc/include/WindowsScanning.hpp; line 22

@@ -16,6 +16,14 @@ inline int ScanWindowsArguments_nid_no_patch(const char* format, const void* sou
     std::vector<void*> pointers;
     std::vector<int> suppressedEnds(static_cast<size_t>(std::count(format, format + std::strlen(format), '%')), -1);
     size_t suppressedCount = 0;
+    struct NarrowInteger {
+        void* destination;
+        size_t size;
+        long long value;

Could this temporary and the final store preserve the conversion signedness? For %u, %o and %x, the translated format is %llu, but this passes &value as a long long*; scanf requires an unsigned long long*. The post-scan stores likewise always use char*, short* or int*, including for %hhu, %hu and %u destinations. These mismatched variadic pointer types and typed stores are undefined behavior even where the host uses identical representations. Please keep a signed/unsigned temporary matching the rewritten conversion and store through the matching destination type; add %hu/%hhu coverage, including values above the corresponding signed range.

<!-- greyfinch-sync:boykopovar/AnyPS5:review-comment:4342872526 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9479#discussion_r4342872526). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T23:03:19Z. **Code review location:** `core/libs/prx/libc/include/WindowsScanning.hpp`; line 22 ~~~~diff @@ -16,6 +16,14 @@ inline int ScanWindowsArguments_nid_no_patch(const char* format, const void* sou std::vector<void*> pointers; std::vector<int> suppressedEnds(static_cast<size_t>(std::count(format, format + std::strlen(format), '%')), -1); size_t suppressedCount = 0; + struct NarrowInteger { + void* destination; + size_t size; + long long value; ~~~~ --- Could this temporary and the final store preserve the conversion signedness? For `%u`, `%o` and `%x`, the translated format is `%llu`, but this passes `&value` as a `long long*`; `scanf` requires an `unsigned long long*`. The post-scan stores likewise always use `char*`, `short*` or `int*`, including for `%hhu`, `%hu` and `%u` destinations. These mismatched variadic pointer types and typed stores are undefined behavior even where the host uses identical representations. Please keep a signed/unsigned temporary matching the rewritten conversion and store through the matching destination type; add `%hu`/`%hhu` coverage, including values above the corresponding signed range.
MarcZX10 commented 2026-10-21 23:03:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T23:03:23Z.

Review: CHANGES_REQUESTED


The unsigned narrow-integer path has undefined behavior: the rewritten %llu/%llx/%llo formats are given a long long*, and the results are stored through signed char*, short* or int*, including for unsigned destinations. I left an inline comment at the temporary declaration with the required signedness fix and tests. The current hosted Linux/Windows build/test jobs are skipped, and the relinker matrix is still running; I have not run a local test.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5607293772 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9479#pullrequestreview-5607293772). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T23:03:23Z. **Review:** CHANGES_REQUESTED --- The unsigned narrow-integer path has undefined behavior: the rewritten `%llu`/`%llx`/`%llo` formats are given a `long long*`, and the results are stored through signed `char*`, `short*` or `int*`, including for unsigned destinations. I left an inline comment at the temporary declaration with the required signedness fix and tests. The current hosted Linux/Windows build/test jobs are skipped, and the relinker matrix is still running; I have not run a local test.
MarcZX10 commented 2026-10-21 23:13:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T23:13:26Z.


Follow-up to my review: the relinker matrix, register-context, write-watch, eligibility, conventions, labels, and report jobs have now completed successfully. The full Linux and Windows build/test jobs were skipped by the PR workflow. The signed/unsigned temporary and destination-pointer issue remains, so the requested code change is unchanged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6328648853 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9479#issuecomment-6328648853). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T23:13:26Z. --- Follow-up to my review: the relinker matrix, register-context, write-watch, eligibility, conventions, labels, and report jobs have now completed successfully. The full Linux and Windows build/test jobs were skipped by the PR workflow. The signed/unsigned temporary and destination-pointer issue remains, so the requested code change is unchanged.
EagleBearerYS commented 2026-10-21 23:25:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T23:25:24Z.

Code review location: core/libs/prx/libc/include/WindowsScanning.hpp; line 22

@@ -16,6 +16,14 @@ inline int ScanWindowsArguments_nid_no_patch(const char* format, const void* sou
     std::vector<void*> pointers;
     std::vector<int> suppressedEnds(static_cast<size_t>(std::count(format, format + std::strlen(format), '%')), -1);
     size_t suppressedCount = 0;
+    struct NarrowInteger {
+        void* destination;
+        size_t size;
+        long long value;

Thanks, @MarcZX10, agreed. b39956b4e1 keeps an unsigned long long temporary for %u, %o, %x and %X, so the rewritten %llu, %llo and %llx get the pointer type they require, and stores those through unsigned char*, unsigned short* or unsigned int*. %d and %i keep the long long temporary and store through signed char*, short* or int*.

CheckIntegerScanWidths gains %u of 4294967295, %hu of 40000 and of 70000 (4464), %hx of ffff, %hhu of 200 and of 300 (44), and %hho of 377 (255). On GitHub's runners (run) guest_formatting passes 10 of 10 on Linux and Windows. The new checks also pass with the previous head, since both hosts store the same bits there, so they pin the values rather than show a failure.

<!-- greyfinch-sync:boykopovar/AnyPS5:review-comment:4343013063 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9479#discussion_r4343013063). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-21T23:25:24Z. **Code review location:** `core/libs/prx/libc/include/WindowsScanning.hpp`; line 22 ~~~~diff @@ -16,6 +16,14 @@ inline int ScanWindowsArguments_nid_no_patch(const char* format, const void* sou std::vector<void*> pointers; std::vector<int> suppressedEnds(static_cast<size_t>(std::count(format, format + std::strlen(format), '%')), -1); size_t suppressedCount = 0; + struct NarrowInteger { + void* destination; + size_t size; + long long value; ~~~~ --- Thanks, @MarcZX10, agreed. b39956b4e1 keeps an `unsigned long long` temporary for `%u`, `%o`, `%x` and `%X`, so the rewritten `%llu`, `%llo` and `%llx` get the pointer type they require, and stores those through `unsigned char*`, `unsigned short*` or `unsigned int*`. `%d` and `%i` keep the `long long` temporary and store through `signed char*`, `short*` or `int*`. `CheckIntegerScanWidths` gains `%u` of `4294967295`, `%hu` of `40000` and of `70000` (4464), `%hx` of `ffff`, `%hhu` of `200` and of `300` (44), and `%hho` of `377` (255). On GitHub's runners ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39691115114)) `guest_formatting` passes 10 of 10 on Linux and Windows. The new checks also pass with the previous head, since both hosts store the same bits there, so they pin the values rather than show a failure.
MarcZX10 commented 2026-10-22 03:37:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T03:37:47Z.

Review: CHANGES_REQUESTED


The latest commit fixes the signedness issue from my earlier review: %u/%o/%x now scan through an unsigned long long temporary and store through unsigned destination types, while signed conversions retain signed temporaries/destinations. The added unsigned narrow cases cover truncation, and the author reports the focused Windows/Linux formatting tests and hosted relinker/platform matrices pass; full Linux/Windows product jobs were skipped.

One repository coordination blocker remains. #9087 is open and edits the same Formatting.cpp test function/call site. The body says whichever PR merges second needs a rebase, but the required merge order/dependency is not recorded and I do not see agreement from #9087's author about this overlap. Please coordinate and state the agreed order in the Depends on checklist (or confirm the changes are order-independent and record the agreed rebase owner), then preserve both test sets. No local tests were run here.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608974102 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9479#pullrequestreview-5608974102). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T03:37:47Z. **Review:** CHANGES_REQUESTED --- The latest commit fixes the signedness issue from my earlier review: `%u/%o/%x` now scan through an `unsigned long long` temporary and store through unsigned destination types, while signed conversions retain signed temporaries/destinations. The added unsigned narrow cases cover truncation, and the author reports the focused Windows/Linux formatting tests and hosted relinker/platform matrices pass; full Linux/Windows product jobs were skipped. One repository coordination blocker remains. #9087 is open and edits the same `Formatting.cpp` test function/call site. The body says whichever PR merges second needs a rebase, but the required merge order/dependency is not recorded and I do not see agreement from #9087's author about this overlap. Please coordinate and state the agreed order in the `Depends on` checklist (or confirm the changes are order-independent and record the agreed rebase owner), then preserve both test sets. No local tests were run here.
MarcZX10 commented 2026-10-22 03:37:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T03:37:48Z.


The signedness correction in the latest head resolves my prior code blocker. The remaining request is merge coordination with #9087 because both change Formatting.cpp test registration/body; please get agreement on sequencing/rebase responsibility and reflect the order in Depends on before requesting another review. Current hosted relinker and platform check matrix is green, while full product builds were skipped.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6332072954 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9479#issuecomment-6332072954). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T03:37:48Z. --- The signedness correction in the latest head resolves my prior code blocker. The remaining request is merge coordination with #9087 because both change `Formatting.cpp` test registration/body; please get agreement on sequencing/rebase responsibility and reflect the order in `Depends on` before requesting another review. Current hosted relinker and platform check matrix is green, while full product builds were skipped.
EagleBearerYS commented 2026-10-22 03:57:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T03:57:00Z.


Thanks, @MarcZX10. orezraey agreed on #9087 that this PR merges first and #9087 then rebases its test file over it, keeping both check functions and both calls in RunChecks (comment). The Overlap section and the Depends on line now say so.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6332310030 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9479#issuecomment-6332310030). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-22T03:57:00Z. --- Thanks, @MarcZX10. orezraey agreed on #9087 that this PR merges first and #9087 then rebases its test file over it, keeping both check functions and both calls in `RunChecks` ([comment](https://github.com/boykopovar/AnyPS5/pull/9087#issuecomment-6332231843)). The Overlap section and the Depends on line now say so.
MarcZX10 commented 2026-10-22 04:30:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:30:23Z.

Review: DISMISSED


The latest head fixes the earlier signedness/undefined-behavior issue: unsigned conversions use an unsigned long long temporary and unsigned destination stores, while signed conversions use signed types. The extensive %d/%i/%u/%x/%o, narrow-width, %q, %n, overflow and failed-conversion cases are covered in the reported Windows/Linux focused runs. The #9087 ordering blocker is now resolved: both authors agree #9479 lands first and #9087 rebases its test changes afterward; the PR records that order. I am requesting changes only because the tested branch remains based on a6dcea9279 while current upstream main is ab347d144d. Please rebase, preserve both Formatting test sets, and rerun guest_formatting, conventions and the overlap scan on current main. Hosted full Linux/Windows product jobs are skipped; I did not run local tests.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5609278947 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9479#pullrequestreview-5609278947). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T04:30:23Z. **Review:** DISMISSED --- The latest head fixes the earlier signedness/undefined-behavior issue: unsigned conversions use an `unsigned long long` temporary and unsigned destination stores, while signed conversions use signed types. The extensive `%d/%i/%u/%x/%o`, narrow-width, `%q`, `%n`, overflow and failed-conversion cases are covered in the reported Windows/Linux focused runs. The #9087 ordering blocker is now resolved: both authors agree #9479 lands first and #9087 rebases its test changes afterward; the PR records that order. I am requesting changes only because the tested branch remains based on a6dcea9279 while current upstream main is ab347d144d88fae054d9770cf0db8d3565735c02. Please rebase, preserve both Formatting test sets, and rerun `guest_formatting`, conventions and the overlap scan on current main. Hosted full Linux/Windows product jobs are skipped; I did not run local tests.
EagleBearerYS commented 2026-10-22 06:00:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T06:00:42Z.


Thanks, @MarcZX10. The branch now has main at da54c652e3 merged in (8fab12951e), with the PR's own diff unchanged. On GitHub's runners (run) guest_formatting and guest_wide_formatting pass 10 runs in a row on both, and guest_formatting fails on Windows with main's code; the libc and libkernel suites pass on both, and conventions pass. Tested now says so.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6333919406 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9479#issuecomment-6333919406). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-22T06:00:42Z. --- Thanks, @MarcZX10. The branch now has `main` at da54c652e3 merged in (8fab12951e), with the PR's own diff unchanged. On GitHub's runners ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39728826593)) `guest_formatting` and `guest_wide_formatting` pass 10 runs in a row on both, and `guest_formatting` fails on Windows with `main`'s code; the libc and libkernel suites pass on both, and conventions pass. Tested now says so.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!9479
No description provided.