fix: clear the GCC warnings in ProfileOutput, fopen, Ajm batch jobs and the SHA-256 test #1549

Merged
LeandroLP23 merged 2 commits from upstream-pr/1549 into main 2026-10-10 04:39:38 +00:00
LeandroLP23 commented 2026-10-08 11:58:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-08T11:58:29Z.


What

Clears 21 of the 39 GCC warnings in the Linux CI build and 5 of the 8 in the Windows one. All of them come from code in this repository; 3rdparty is left alone.

  • ProfileOutput.hpp (-Wformat-security, 20 on Linux): ProfilePrint_nid_no_patch("[guestmem]") and the other calls without arguments in GuestMemory.cpp and Recorder.cpp reached snprintf with a non-literal format. A Print(const char*) overload sends that text through "%s". None of these strings contains %, so the output is unchanged.
  • FileAndHeap.cpp (-Wignored-attributes, 1 on Linux): decltype(&std::fclose) carries glibc's attributes into the unique_ptr deleter type; the deleter is now int (*)(std::FILE*).
  • Ajm.cpp (-Wnonnull, 13 on Linux): Append is inlined into the batch-job functions that pass nullptr buffers, and the fortified memcpy warned about them. Append now throws (NotImplemented_nid_no_patch) when a buffer list is null and its count is not zero, since the console's result there is unknown, and copies only when the pointer is set. sceAjmBatchJobRunSplit with nullptr inputs and a count of 1 used to crash in memcpy; GuestAjm.cpp checks that it now throws and leaves the batch untouched.
  • Amd64OnlyWindowsTests.cpp (-Wstringop-overflow, 5 on Windows): a GCC false positive on std::vector<Sha256Step>(n) for the 3-byte struct; passing Sha256Step{} as the value removes it. The vector is still zero-filled and the sequence of random() calls is the same.

Left as is:

  • sceRtcFormatRFC2822 (-Wformat-truncation): the 32-byte buffer is the API's, and the console's behaviour for years past 9999 is unknown.
  • LookBackScan.cpp (-Wstringop-overflow / -Warray-bounds from std::vector::insert, Linux only), a GCC false positive in a test.
  • GuestKernelSync.cpp (NOMINMAX redefined, Windows), new in bb1a4cbe.
  • 3rdparty/glslang.

Tested

Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release with BUILD_TESTING=ON. No title or homebrew.

  • guest_ajm, agc_profile_output, file_position, guest_filesystem, guest_file_vector, guest_host_libc, guest_standard_streams, savedata_replace_file_failure, amd64_only_windows, amd64_only_converter: pass, 3/3 runs each.
  • With the Append check removed, the new guest_ajm case crashes (SegFault); with it, it passes. After the review, the check throws instead of returning SCE_AJM_ERROR_INVALID_PARAMETER; guest_ajm passes.
  • The Linux warnings need glibc's fortified headers, so they were checked with this repository's Build workflow on my fork: Linux 39 → 5 warnings, 442/442 tests passed; Windows 8 → 3 plus the new NOMINMAX one, 437/437 passed (run).
  • #639, the only open PR that touches one of these files (ProfileOutput.hpp), merges that file cleanly with this change.

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:4786422299 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1549). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-08T11:58:29Z. --- ### What Clears 21 of the 39 GCC warnings in the Linux CI build and 5 of the 8 in the Windows one. All of them come from code in this repository; `3rdparty` is left alone. - `ProfileOutput.hpp` (`-Wformat-security`, 20 on Linux): `ProfilePrint_nid_no_patch("[guestmem]")` and the other calls without arguments in `GuestMemory.cpp` and `Recorder.cpp` reached `snprintf` with a non-literal format. A `Print(const char*)` overload sends that text through `"%s"`. None of these strings contains `%`, so the output is unchanged. - `FileAndHeap.cpp` (`-Wignored-attributes`, 1 on Linux): `decltype(&std::fclose)` carries glibc's attributes into the `unique_ptr` deleter type; the deleter is now `int (*)(std::FILE*)`. - `Ajm.cpp` (`-Wnonnull`, 13 on Linux): `Append` is inlined into the batch-job functions that pass `nullptr` buffers, and the fortified `memcpy` warned about them. `Append` now throws (`NotImplemented_nid_no_patch`) when a buffer list is null and its count is not zero, since the console's result there is unknown, and copies only when the pointer is set. `sceAjmBatchJobRunSplit` with `nullptr` inputs and a count of 1 used to crash in `memcpy`; `GuestAjm.cpp` checks that it now throws and leaves the batch untouched. - `Amd64OnlyWindowsTests.cpp` (`-Wstringop-overflow`, 5 on Windows): a GCC false positive on `std::vector<Sha256Step>(n)` for the 3-byte struct; passing `Sha256Step{}` as the value removes it. The vector is still zero-filled and the sequence of `random()` calls is the same. Left as is: - `sceRtcFormatRFC2822` (`-Wformat-truncation`): the 32-byte buffer is the API's, and the console's behaviour for years past 9999 is unknown. - `LookBackScan.cpp` (`-Wstringop-overflow` / `-Warray-bounds` from `std::vector::insert`, Linux only), a GCC false positive in a test. - `GuestKernelSync.cpp` (`NOMINMAX` redefined, Windows), new in bb1a4cbe. - `3rdparty/glslang`. ### Tested Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release with `BUILD_TESTING=ON`. No title or homebrew. - `guest_ajm`, `agc_profile_output`, `file_position`, `guest_filesystem`, `guest_file_vector`, `guest_host_libc`, `guest_standard_streams`, `savedata_replace_file_failure`, `amd64_only_windows`, `amd64_only_converter`: pass, 3/3 runs each. - With the `Append` check removed, the new `guest_ajm` case crashes (SegFault); with it, it passes. After the review, the check throws instead of returning `SCE_AJM_ERROR_INVALID_PARAMETER`; `guest_ajm` passes. - The Linux warnings need glibc's fortified headers, so they were checked with this repository's `Build` workflow on my fork: Linux 39 → 5 warnings, 442/442 tests passed; Windows 8 → 3 plus the new `NOMINMAX` one, 437/437 passed ([run](https://github.com/LeandroLP23/AnyPS5/actions/runs/37770049910)). - #639, the only open PR that touches one of these files (`ProfileOutput.hpp`), merges that file cleanly with this change. ### 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 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
github-actions[bot] commented 2026-10-08 12:54:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T12:54:19Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#2033 core/libs/prx/libc/src/FileAndHeap.cpp L82
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6060318484 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1549#issuecomment-6060318484). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-08T12:54:19Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #2033 | `core/libs/prx/libc/src/FileAndHeap.cpp` [L82](https://github.com/boykopovar/AnyPS5/blob/afb8cd22399115fb57f902392fd75efd2ca624d2/core/libs/prx/libc/src/FileAndHeap.cpp#L82) | | |
oneandonlydean commented 2026-10-09 09:22:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:22:17Z.


Ajm.cpp Append: please throw for a null buffer list with a nonzero count instead of returning SCE_AJM_ERROR_INVALID_PARAMETER, since we don't know what the console returns there. The other warning fixes are fine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078120564 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1549#issuecomment-6078120564). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T09:22:17Z. --- `Ajm.cpp` `Append`: please throw for a null buffer list with a nonzero count instead of returning `SCE_AJM_ERROR_INVALID_PARAMETER`, since we don't know what the console returns there. The other warning fixes are fine.
LeandroLP23 commented 2026-10-09 09:27:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-09T09:27:19Z.


Done in c3735921: Append now throws (NotImplemented_nid_no_patch) for a null buffer list with a nonzero count, and guest_ajm checks that it throws and leaves the batch untouched.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078196832 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1549#issuecomment-6078196832). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-09T09:27:19Z. --- Done in c3735921: `Append` now throws (`NotImplemented_nid_no_patch`) for a null buffer list with a nonzero count, and `guest_ajm` checks that it throws and leaves the batch untouched.
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!1549
No description provided.