Skip to content

socket: use name sockerr for socket error variables#21998

Closed
vszakats wants to merge 32 commits into
curl:masterfrom
vszakats:sockerr1
Closed

socket: use name sockerr for socket error variables#21998
vszakats wants to merge 32 commits into
curl:masterfrom
vszakats:sockerr1

Conversation

@vszakats

@vszakats vszakats commented Jun 13, 2026

Copy link
Copy Markdown
Member

Also:

  • add comment explaining a sockerr = errno (vs. SOCKERRNO)
    assigment.

@github-actions github-actions Bot added the tests label Jun 13, 2026
@vszakats vszakats marked this pull request as draft June 13, 2026 14:35
@vszakats vszakats marked this pull request as ready for review June 13, 2026 17:33
@vszakats vszakats changed the title tidy-up: prefer name sockerr for socket error variables socket: use name sockerr for socket error variables Jun 13, 2026
@vszakats vszakats requested a review from Copilot June 14, 2026 10:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes naming for socket error variables by renaming many local error/err variables to sockerr across lib and test server code, and adds an explanatory comment for a deliberate sockerr = errno assignment in the socket connection filter.

Changes:

  • Rename socket error variables to sockerr across multiple test servers and library modules for consistency.
  • Update related logging/strerror call sites to use the renamed variable.
  • Add an in-code comment in lib/cf-socket.c explaining why errno (not SOCKERRNO) is used in a specific failure path.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/server/util.c Rename local socket error variable(s) to sockerr in unix-socket bind helper/daemon setup.
tests/server/tftpd.c Rename socket error variable to sockerr in socket setup and error logging.
tests/server/sws.c Rename socket error variables to sockerr in request handling, connect, accept, and server setup paths.
tests/server/socksd.c Rename socket error variables; adjusts one cleanup-site local variable.
tests/server/sockfilt.c Rename socket error variables to sockerr in juggle/select/accept and setup paths.
tests/server/rtspd.c Rename socket error variables to sockerr in recv/listen/accept and setup paths.
tests/server/mqttd.c Rename socket error variables to sockerr in select/accept and setup paths.
tests/server/dnsd.c Rename socket error variables to sockerr in socket setup and error logging.
tests/libtest/first.h Rename select() error variables in exe_select_test macro (ecsockerr).
lib/tftp.c Rename local socket error variable to sockerr in error handling path.
lib/telnet.c Rename WinSock error variable to sockerr when reporting WSAEnumNetworkEvents failures.
lib/socketpair.c Rename return/temporary socket error variable to sockerr in wakeup signaling.
lib/hostip4.c Rename h_errnop-style variable to sockerr in gethostbyname_r resolver path.
lib/ftp.c Rename local socket error variables to sockerr in FTP active-mode socket open/bind paths.
lib/cf-socket.c Rename internal socket error state/parameter names to sockerr and add comment for errno assignment.
lib/asyn-thrdd.c Rename threaded resolver item error field from sock_error to sockerr.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/cf-socket.c Outdated
Comment thread lib/hostip4.c Outdated
Comment thread lib/hostip4.c Outdated
Comment thread lib/hostip4.c Outdated
Comment thread lib/hostip4.c Outdated
Comment thread tests/server/socksd.c

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Comment thread lib/cf-socket.c Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Comment thread tests/server/util.c
Comment thread tests/server/sws.c
@vszakats vszakats closed this in fe2df80 Jun 14, 2026
@vszakats vszakats deleted the sockerr1 branch June 14, 2026 12:18
vszakats added a commit that referenced this pull request Jun 14, 2026
In `socksd` and `sws` error messages.

Also:
- show the messages only if `unlink()` failed.
- rename a return code variable and sync a message text for consistency.

Ref: https://pubs.opengroup.org/onlinepubs/9699919799/functions/unlink.html

Spotted by Copilot in `socksd.c`
Bug: #21998 (comment)
Follow-up to 80eb71a #8687

Closes #22005
vszakats added a commit that referenced this pull request Jun 14, 2026
- sws: fix socket error code in `select()` failure message.
  Spotted by Copilot
  Bug: #21998 (comment)
- sws: do not call `SOCKERRNO` twice on error.
- dnsd: do not call `SOCKERRNO` twice on error.
- dnsd: replace `goto` with `while()` to sync with rest of code.
- dnsd: `sendto()` fail message fixes:
  - replace `int` cast with `%zu` mask.
  - drop redundant newline.
  - show socket error string like rest of code.
  - report not-fully-sent error separately from socket errors.

Closes #22007
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants