From: Viktor Szakats Date: Tue, 27 Jan 2026 23:46:37 +0000 (+0100) Subject: tool_doswin: avoid Windowsisms in socket code (cont.) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4e2232c434473c0a1175f2bd2576673aa8c4692;p=thirdparty%2Fcurl.git tool_doswin: avoid Windowsisms in socket code (cont.) For general readability. Also to match the rest of the source code. - bump `send()` result type from `int` to `ssize_t`. - fix an `int` to be `curl_socklen_t`. - `.S_un.S_addr` -> `.s_addr`. - `SD_RECEIVE` -> `SHUT_RD`. - `SD_SEND` -> `SHUT_WR`. Follow-up to a81ab3e6db370f31fca2fc67ca8bfda263f15caa #20452 Follow-up to 9a2663322c330ff11275abafd612e9c99407a94a #17572 Closes #20457 --- diff --git a/src/tool_doswin.c b/src/tool_doswin.c index 4ee7ae5828..5cc885137f 100644 --- a/src/tool_doswin.c +++ b/src/tool_doswin.c @@ -708,7 +708,7 @@ static DWORD WINAPI win_stdin_thread_func(void *thread_data) { struct win_thread_data *tdata = (struct win_thread_data *)thread_data; DWORD n; - int nwritten; + ssize_t nwritten; char buffer[BUFSIZ]; BOOL r; @@ -726,7 +726,7 @@ static DWORD WINAPI win_stdin_thread_func(void *thread_data) sclose(tdata->socket_l); tdata->socket_l = CURL_SOCKET_BAD; - if(shutdown(socket_w, SD_RECEIVE)) { + if(shutdown(socket_w, SHUT_RD)) { errorf("shutdown error: %d", SOCKERRNO); goto ThreadCleanup; } @@ -760,7 +760,8 @@ ThreadCleanup: curl_socket_t win32_stdin_read_thread(void) { bool r; - int rc = 0, socksize = 0; + int rc = 0; + curl_socklen_t socksize = 0; struct win_thread_data *tdata = NULL; struct sockaddr_in selfaddr; static HANDLE stdin_thread = NULL; @@ -791,7 +792,7 @@ curl_socket_t win32_stdin_read_thread(void) socksize = sizeof(selfaddr); memset(&selfaddr, 0, socksize); selfaddr.sin_family = AF_INET; - selfaddr.sin_addr.S_un.S_addr = htonl(INADDR_LOOPBACK); + selfaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); /* Bind to any available loopback port */ if(bind(tdata->socket_l, (const struct sockaddr *)&selfaddr, socksize)) { errorf("bind error: %d", SOCKERRNO); @@ -846,7 +847,7 @@ curl_socket_t win32_stdin_read_thread(void) break; } - if(shutdown(socket_r, SD_SEND)) { + if(shutdown(socket_r, SHUT_WR)) { errorf("shutdown error: %d", SOCKERRNO); break; }