fix(libc): return the written length from fputs like FreeBSD #4803

Closed
Gashrod1 wants to merge 1 commit from upstream-pr/4803 into main
Gashrod1 commented 2026-10-12 22:26:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Gashrod1 on 2026-10-12T22:26:03Z.


What

fputs_nid_postfix returned the host's fputs result. On success that is 1 on glibc and 0 on the Windows runtime; FreeBSD returns the number of bytes written, capped at INT_MAX (lib/libc/stdio/fputs.c: return (iov.iov_len > INT_MAX ? INT_MAX : iov.iov_len);, in FreeBSD since 11.0). fputs("abc", f) now returns 3 and fputs("", f) returns 0; EOF is still returned on failure.

file_streams checks the exact return for a 17-byte string and for an empty string, where it only checked >= 0 before. It fails on main and passes with the change.

Tested

Linux (Arch, GCC), Release, BUILD_TESTING=ON, based on main ee4962190: file_streams aborts on main and passes with the change (3 runs); full build and full ctest pass. Windows (WinLibs MinGW-w64 GCC 15.2.0 r7, NVIDIA RTX 5060), Release, BUILD_TESTING=ON: full build and full ctest pass (1018 tests, the same 7 skipped as on main). No title or homebrew run.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4835705397 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4803). Originally posted by [Gashrod1](https://github.com/Gashrod1) on 2026-10-12T22:26:03Z. --- ### What `fputs_nid_postfix` returned the host's `fputs` result. On success that is 1 on glibc and 0 on the Windows runtime; FreeBSD returns the number of bytes written, capped at `INT_MAX` ([`lib/libc/stdio/fputs.c`](https://github.com/freebsd/freebsd-src/blob/main/lib/libc/stdio/fputs.c): `return (iov.iov_len > INT_MAX ? INT_MAX : iov.iov_len);`, in FreeBSD since 11.0). `fputs("abc", f)` now returns 3 and `fputs("", f)` returns 0; `EOF` is still returned on failure. `file_streams` checks the exact return for a 17-byte string and for an empty string, where it only checked `>= 0` before. It fails on `main` and passes with the change. ### Tested Linux (Arch, GCC), Release, `BUILD_TESTING=ON`, based on `main` `ee4962190`: `file_streams` aborts on `main` and passes with the change (3 runs); full build and full `ctest` pass. Windows (WinLibs MinGW-w64 GCC 15.2.0 r7, NVIDIA RTX 5060), Release, `BUILD_TESTING=ON`: full build and full `ctest` pass (1018 tests, the same 7 skipped as on `main`). No title or homebrew run. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
oneandonlydean commented 2026-10-14 02:38:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:38:07Z.


Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159648310 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4803#issuecomment-6159648310). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T02:38:07Z. --- Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

Pull request closed

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!4803
No description provided.