net: report ENOPROTOOPT for unknown socket options on Windows #2021
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!2021
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2021/head"
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?
@lukanatroshvili67 on GitHub · 2026-10-31 13:02 UTC · original
lukanatroshvili67:fix/windows-net-sockopt→main· +24 −2 · 1 files · 1 commits · closed without mergingOn Windows,
sceNetSetsockopt/sceNetGetsockoptwith an unknownSOL_SOCKEToption returnEINVALinstead ofENOPROTOOPT. That fails thiskernel_file_systemcheck:On Windows,
ConvertSocketOptionNamepasses unmapped options through, because Winsock uses the BSD option numbers. Winsock then rejects an unknown option withWSAEINVALinstead ofWSAENOPROTOOPT. A standalone probe confirms it:setsockopt/getsockopt(SOL_SOCKET, 0x7fffffff)on a UDP socket both fail with 10022.setsockoptalso returnsWSAEINVALfor an invalid value, so the error alone isn't enough. When either call fails withWSAEINVAL, the newSetHostSocketOptionErrorprobes the option withgetsockoptand a 64-byte buffer.getsockoptreports a short buffer asWSAEFAULT, so it fails withWSAEINVALonly for an unknown option, and only then does the guest getENOPROTOOPT. Every other failure keeps the original error. Linux and macOS are unchanged.Testing (Windows 11, clang-cl 19.1.5)
kernel_file_systemstops earlier without them. The run then gets to the next, unrelated check ("initial NP callback matches the selected emulated sign-in state").kyty_emulatorbuilds.@coderabbitai[bot] on GitHub · 2026-10-31 13:06 UTC · original
Findings
6288da28-9f8a-421f-8b4e-3807542945d5Reviewing files that changed from the base of the PR and between
026189166fand4fe6690ab3.src/libs/network.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Walkthrough
The change adds
SetHostSocketOptionErrorto distinguish an unknown socket option from otherWSAEINVALerrors on Windows.GetsockoptandSetsockoptuse this helper when their host calls fail. On non-Windows platforms, the helper uses the existing host-socket error conversion.Suggested reviewers:
nmzikChange: Bug fix
Merge Risk:
Low · up to
4fe66Invalid socket levels can receive the wrong error on Windows; restrict probing to SOL_SOCKET before merging.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 1 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
@ -1069,0 +1071,4 @@// Winsock reports an unknown option as WSAEINVAL, which setsockopt also uses for invalid// values. getsockopt with a large buffer fails with WSAEINVAL only for an unknown option.const int error = WSAGetLastError();if (error == WSAEINVAL) {@coderabbitai[bot] on GitHub · 2026-10-31 13:06 UTC · original
Restrict the probe to
SOL_SOCKET.An invalid level such as
0x8000can make both calls returnWSAEINVAL. The helper then returnsENOPROTOOPTinstead of preservingEINVAL. Winsock documentsWSAEINVALfor invalid levels. (learn.microsoft.com)Run the probe only when
level == SOL_SOCKET.@coderabbitai[bot] on GitHub · 2026-10-31 13:06 UTC · original · reviewed
Actionable comments posted: 1
6288da28-9f8a-421f-8b4e-3807542945d5Reviewing files that changed from the base of the PR and between
026189166fand4fe6690ab3.src/libs/network.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Pull request closed