refactor(libressl): drop errno saves around guest copies #25937
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/25937"
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?
Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-11-22T22:51:50Z.
What
Twelve LibreSSL source files each define small helpers that save
errno, callGuestCopyIn_nid_no_patch,GuestCopyOut_nid_no_patchorGuestWritable_nid_no_patch, and restoreerrno. Since #21243, those three libc functions restoreerrnothemselves:CopyGuestBytes,GuestCopyOut_nid_no_patchandGuestWritable_nid_no_patcheach hold aRestoreErrnoinlibc/src/General.cpp. As noted when #21639 was closed, the save around them is now redundant.CopyGuestInPreservingErrno,CopyGuestOutPreservingErrno,CopyGuestBytesInPreservingErrno,CopyInPreservingErrno,CopyOutPreservingErrno,WritablePreservingErrno) are removed. Their callers call the libc functions directly, which take the same arguments.CopyGuestInPreservingErrno(T&, const T*)andCopyGuestOutPreservingErrno(T*, const T&)) stay, because they take the size from the type. Each becomes one line overGuestPtr.CopyGuestStringPreservingErrnoinBio.cppandBioFileSocket.cppstill reads a guest string in chunks. Only its inner call changes.Files:
libSceLibreSsl/src/{Bio,BioFileSocket,ProtocolSelection}.cppandlibSceLibreSsl3/src/{KeyComponents,OcspFindStatus,RsaSetters,SignatureAlgorithms,X509,X509Algor,X509CmpTime,X509StoreContext,X509Validity}.cpp, 180 lines removed and 68 added. I left alone the LibreSSL files that open pull requests touch. If this shape is welcome, the same helpers in other libraries (FreeType, ICU and some others, about 90 definitions in all) can follow in separate pull requests.No change in behaviour.
Tested
Windows 11 (10.0.26300), WinLibs GCC 15.2.0 r7, Release.
ctest -R 'ssl|x509|ocsp|rsa|bio|asn1', with its 183 build outputs fromtools/select_tests.py targets: 213 of 213 onmain8affaf75a2and 213 of 213 with this change applied to it.tools/check_conventions.pypasses.tools/pr_overlap.py --branchfinds no overlap with the 2476 open pull requests.Not run: Linux and macOS.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T23:06:25Z.
Review: APPROVED
Reviewed — looks good
The changed wrappers only duplicated errno restoration already provided by the libc guest-memory functions, and the replacements preserve the same copy operations.
What I ran
Reviewed head
a29613840d2244a93cd0434d4f4634a799d29f1b. Read the prepared diff and all 12 changed files listed in the manifest; checked the relevant guest-copy implementations inGeneral.cppandGuestPtr.hpp. No commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The author reports Windows tests and convention checks in the PR description; these were not run as part of this review. Linux and macOS behavior was not verified.
To get this to a good state
Nothing is required.