docs(libc): correct the RSIZE_MAX that swprintf_s and vswprintf_s assume #9360

Merged
thuanquang merged 1 commit from upstream-pr/9360 into main 2026-10-25 10:42:33 +00:00
thuanquang commented 2026-10-21 19:20:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-21T19:20:32Z.


What

One statement in docs/dev/debt/libc.md no longer matches main; it is replaced with what main does now, and nothing else in the entry changes.

  • swprintf_s and vswprintf_s: "follow C11 K.3.9.1.4 with RSIZE_MAX assumed to be SIZE_MAX >> 1:". vswprintf_s and swprintf_s define RsizeMax = (SIZE_MAX >> 1) / sizeof(char16_t) (core/libs/prx/libc/src/FormattingWide.cpp:268 and :286) and use it for the size check and for clearing buffer[0]. Only snwprintf_s uses SIZE_MAX >> 1 (:247). The code has used this limit since a0bd257a09 (#5454), the commit that also wrote the entry. Now: "follow C11 K.3.9.1.4 with RSIZE_MAX assumed to be (SIZE_MAX >> 1) / sizeof(char16_t):".

Tested

Docs only; nothing was built or run. On origin/main 1698d1ea6a I read docs/dev/debt/libc.md and, under core/libs/prx/libc, SonyCrt.hpp (handler slot, SonyInvokeConstraintHandler, SonyFormatAsctime, SonyCtimeS, SonyAsctimeS, SonyWcscpyS), Strings.cpp memcpy_s, Formatting.cpp FormatSecure, the FormattingWide.cpp wide _s printf functions, Time.cpp ctime_s and asctime_s, and BoundsChecking.cpp violation(), and I grepped every SonyInvokeConstraintHandler and SonyConstraintHandlerSlot use under core/libs/prx. (main 1896871ba7). Each statement was found by a read-only sweep of the debt files and confirmed by two independent verifier passes and a final check on current main. No open pull request edits these sentences (checked against every open PR's diff of this file).

  • Rebased onto main b930da950d (head 5489f07047) for an adjacent-line conflict (#10312 added the strerror entry right after this one); the edited entry itself is unchanged on main. Rechecked on b930da950d (no later change to the file): vswprintf_s and swprintf_s still define the wide limit at FormattingWide.cpp:268 and :286, snwprintf_s keeps SIZE_MAX >> 1 at :247.
  • python tools/check_conventions.py --base origin/main with this title and body passes.
  • Not tested: behaviour on any machine; this changes text only.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4957087399 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9360). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-21T19:20:32Z. --- ### What One statement in `docs/dev/debt/libc.md` no longer matches `main`; it is replaced with what `main` does now, and nothing else in the entry changes. - **swprintf_s and vswprintf_s**: "follow C11 K.3.9.1.4 with `RSIZE_MAX` assumed to be `SIZE_MAX >> 1`:". vswprintf_s and swprintf_s define `RsizeMax = (SIZE_MAX >> 1) / sizeof(char16_t)` (core/libs/prx/libc/src/FormattingWide.cpp:268 and :286) and use it for the size check and for clearing buffer[0]. Only snwprintf_s uses `SIZE_MAX >> 1` (:247). The code has used this limit since a0bd257a09 (#5454), the commit that also wrote the entry. Now: "follow C11 K.3.9.1.4 with `RSIZE_MAX` assumed to be `(SIZE_MAX >> 1) / sizeof(char16_t)`:". ### Tested Docs only; nothing was built or run. On origin/main 1698d1ea6a I read docs/dev/debt/libc.md and, under core/libs/prx/libc, SonyCrt.hpp (handler slot, SonyInvokeConstraintHandler, SonyFormatAsctime, SonyCtimeS, SonyAsctimeS, SonyWcscpyS), Strings.cpp memcpy_s, Formatting.cpp FormatSecure, the FormattingWide.cpp wide _s printf functions, Time.cpp ctime_s and asctime_s, and BoundsChecking.cpp violation(), and I grepped every SonyInvokeConstraintHandler and SonyConstraintHandlerSlot use under core/libs/prx. (`main` `1896871ba7`). Each statement was found by a read-only sweep of the debt files and confirmed by two independent verifier passes and a final check on current `main`. No open pull request edits these sentences (checked against every open PR's diff of this file). - Rebased onto `main` `b930da950d` (head `5489f07047`) for an adjacent-line conflict (#10312 added the strerror entry right after this one); the edited entry itself is unchanged on `main`. Rechecked on `b930da950d` (no later change to the file): `vswprintf_s` and `swprintf_s` still define the wide limit at `FormattingWide.cpp:268` and `:286`, `snwprintf_s` keeps `SIZE_MAX >> 1` at `:247`. - `python tools/check_conventions.py --base origin/main` with this title and body passes. - Not tested: behaviour on any machine; this changes text only. ### Checklist - [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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!9360
No description provided.