]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_doswin: avoid Windowsisms in socket code (cont.)
authorViktor Szakats <commit@vsz.me>
Tue, 27 Jan 2026 23:46:37 +0000 (00:46 +0100)
committerViktor Szakats <commit@vsz.me>
Wed, 28 Jan 2026 02:26:45 +0000 (03:26 +0100)
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

src/tool_doswin.c

index 4ee7ae5828c12c04ac8edfa4cf0e570e487fa25c..5cc885137f4e267b6b7ee3b96dbc7e7bf520f276 100644 (file)
@@ -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;
     }