]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
core: stop redefining `E*` macros on Windows, map `EACCES`, related fixes
authorViktor Szakats <commit@vsz.me>
Sat, 8 Mar 2025 01:18:35 +0000 (02:18 +0100)
committerViktor Szakats <commit@vsz.me>
Wed, 12 Mar 2025 23:03:25 +0000 (00:03 +0100)
Before this patch, standard `E*` errno codes were redefined on Windows,
onto matching winsock2 `WSA*` error codes, which have different values.
This broke uses where using the `E*` value in non-socket context, or
other places expecting a POSIX `errno`, e.g. file I/O, threads, IDN or
interfacing with dependencies.

Fix it by introducing a curl-specific `SOCKE*` set of macros that map to
`WSA*` on Windows and standard POSIX codes on other platforms. Then
verify and update the code to use `SOCKE*` or `E*` macro depending on
context.

- Add `SOCKE*` macros that map to either winsock2 or POSIX error codes.
  And use them with `SOCKERRNO` or in contexts requiring
  platform-dependent socket error codes.

  This fixes `E*` uses which were supposed be POSIX values, not `WSA*`
  socket errors, on Windows:
  - lib/curl_multibyte.c
  - lib/curl_threads.c
  - lib/idn.c
  - lib/vtls/gtls.c
  - lib/vtls/rustls.c
  - src/tool_cb_wrt.c
  - src/tool_dirhie.c

- Ban `E*` codes having a `SOCKE*` mapping, via checksrc.
Authored-by: Daniel Stenberg
- Add exceptions for `E*` codes used in file I/O, or other contexts
  requiring POSIX error codes.

Also:
- ftp: fix missing `SOCKEACCES` mapping for Windows.
- add `SOCKENOMEM` for `Curl_getaddrinfo()` via `asyn-thread.c`.
- tests/server/sockfilt: fix to set `SOCKERRNO` in local `select()`
  override on Windows.
- lib/inet_ntop: fix to return `WSAEINVAL` on Windows, where `ENOSPC` is
  used on other platforms. To simulate Windows' built-in `inet_ntop()`,
  as tested on a Win10 machine.
  Note:
  - WINE returns `STATUS_INVALID_PARAMETER` = `0xC000000D`.
  - Microsoft documentation says it returns `WSA_INVALID_PARAMETER`
    (= `ERROR_INVALID_PARAMETER`) 87:
    https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-inet_ntop#return-value
- lib/inet_ntop: drop redundant `CURL_SETERRNO(ENOSPC)`.
  `inet_ntop4()` already sets it before returning `NULL`.
- replace stray `WSAEWOULDBLOCK` with `USE_WINSOCK` macro to detect
  winsock2.
- move existing `SOCKE*` mappings from `tests/server` to
  `curl_setup_once.h`.
- add missing `EINTR`, `EINVAL` constants for WinCE.

Follow-up to abf80aae384319ef9b19ffbd0d69a1fbe7421f1f #16612
Follow-up to d69425ed7d0918aceddd96048b146a9df85638ec #16615
Bug: https://github.com/curl/curl/pull/16553#issuecomment-2704679377

Closes #16621

36 files changed:
CMake/CurlTests.c
docs/examples/.checksrc
lib/amigaos.c
lib/asyn-thread.c
lib/cf-socket.c
lib/connect.c
lib/curl_multibyte.c
lib/curl_setup.h
lib/curl_setup_once.h
lib/curl_threads.c
lib/ftp.c
lib/idn.c
lib/inet_ntop.c
lib/inet_pton.c
lib/memdebug.c
lib/multi.c
lib/openldap.c
lib/select.c
lib/select.h
lib/socketpair.c
lib/telnet.c
lib/vquic/vquic.c
lib/vtls/gtls.c
lib/vtls/rustls.c
packages/OS400/ccsidcurl.c
packages/OS400/os400sys.c
scripts/checksrc.pl
src/tool_cb_wrt.c
src/tool_dirhie.c
src/tool_operate.c
tests/libtest/first.c
tests/server/rtspd.c
tests/server/sockfilt.c
tests/server/sws.c
tests/server/util.c
tests/server/util.h

index 69a996a0477d4ec314e7f01c2617d49625ca3af9..de2313080dd72c142d4aac932a63577be7390089 100644 (file)
@@ -278,6 +278,7 @@ int main(void)
 {
   char buffer[1024];
   /* This will not compile if strerror_r does not return a char* */
+  /* !checksrc! disable ERRNOVAR 1 */
   check(strerror_r(EACCES, buffer, sizeof(buffer))[0]);
   return 0;
 }
@@ -294,6 +295,7 @@ int main(void)
 {
   char buffer[1024];
   /* This will not compile if strerror_r does not return an int */
+  /* !checksrc! disable ERRNOVAR 1 */
   check(strerror_r(EACCES, buffer, sizeof(buffer)));
   return 0;
 }
index 37f7909524a1e8337245a7fc3398cdab8c070966..cfcd695bd01bf20f2a336a4cf513d0d25feb1862 100644 (file)
@@ -1,2 +1,3 @@
-disable TYPEDEFSTRUCT
 disable BANNEDFUNC
+disable ERRNOVAR
+disable TYPEDEFSTRUCT
index c4872f248d92755ab99b1fb3c250716c6afb3cfe..ac6d6b41937dd8a911e304470ef55531de9f27f7 100644 (file)
@@ -184,7 +184,7 @@ int Curl_amiga_select(int nfds, fd_set *readfds, fd_set *writefds,
 {
   int r = WaitSelect(nfds, readfds, writefds, errorfds, timeout, 0);
   /* Ensure Ctrl-C signal is actioned */
-  if((r == -1) && (SOCKERRNO == EINTR))
+  if((r == -1) && (SOCKERRNO == SOCKEINTR))
     raise(SIGINT);
   return r;
 }
index bf7f144ad5a38ed6a0554f609903c534836b59e9..c057ee8eb8ceaafe90b13bf3bcbbbd405e7b77ec 100644 (file)
@@ -49,9 +49,9 @@
 #endif
 
 #ifdef HAVE_GETADDRINFO
-#  define RESOLVER_ENOMEM  EAI_MEMORY
+#  define RESOLVER_ENOMEM  EAI_MEMORY  /* = WSA_NOT_ENOUGH_MEMORY on Windows */
 #else
-#  define RESOLVER_ENOMEM  ENOMEM
+#  define RESOLVER_ENOMEM  SOCKENOMEM
 #endif
 
 #include "urldata.h"
@@ -433,6 +433,7 @@ static bool init_resolve_thread(struct Curl_easy *data,
                                 const struct addrinfo *hints)
 {
   struct thread_data *td = &data->state.async.thdata;
+  /* !checksrc! disable ERRNOVAR 1 */
   int err = ENOMEM;
   struct Curl_async *async = &data->state.async;
 
index 260b52333d2018262098ec6ae26859a7e5b90b2c..e02b0351270acbca134bcccf707515d1a7380517 100644 (file)
@@ -868,7 +868,7 @@ static bool verifyconnect(curl_socket_t sockfd, int *error)
     err = 0;
   }
 #endif
-  if((0 == err) || (EISCONN == err))
+  if((0 == err) || (SOCKEISCONN == err))
     /* we are connected, awesome! */
     rc = TRUE;
   else
@@ -891,10 +891,10 @@ static CURLcode socket_connect_result(struct Curl_easy *data,
                                       const char *ipaddress, int error)
 {
   switch(error) {
-  case EINPROGRESS:
-  case EWOULDBLOCK:
+  case SOCKEINPROGRESS:
+  case SOCKEWOULDBLOCK:
 #if defined(EAGAIN)
-#if (EAGAIN) != (EWOULDBLOCK)
+#if (EAGAIN) != (SOCKEWOULDBLOCK)
     /* On some platforms EAGAIN and EWOULDBLOCK are the
      * same value, and on others they are different, hence
      * the odd #if
@@ -1515,15 +1515,16 @@ static ssize_t cf_socket_send(struct Curl_cfilter *cf, struct Curl_easy *data,
     int sockerr = SOCKERRNO;
 
     if(
-#ifdef WSAEWOULDBLOCK
+#ifdef USE_WINSOCK
       /* This is how Windows does it */
-      (WSAEWOULDBLOCK == sockerr)
+      (SOCKEWOULDBLOCK == sockerr)
 #else
       /* errno may be EWOULDBLOCK or on some systems EAGAIN when it returned
          due to its inability to send off data without blocking. We therefore
          treat both error codes the same here */
-      (EWOULDBLOCK == sockerr) || (EAGAIN == sockerr) || (EINTR == sockerr) ||
-      (EINPROGRESS == sockerr)
+      (SOCKEWOULDBLOCK == sockerr) ||
+      (EAGAIN == sockerr) || (SOCKEINTR == sockerr) ||
+      (SOCKEINPROGRESS == sockerr)
 #endif
       ) {
       /* this is just a case of EWOULDBLOCK */
@@ -1583,14 +1584,15 @@ static ssize_t cf_socket_recv(struct Curl_cfilter *cf, struct Curl_easy *data,
     int sockerr = SOCKERRNO;
 
     if(
-#ifdef WSAEWOULDBLOCK
+#ifdef USE_WINSOCK
       /* This is how Windows does it */
-      (WSAEWOULDBLOCK == sockerr)
+      (SOCKEWOULDBLOCK == sockerr)
 #else
       /* errno may be EWOULDBLOCK or on some systems EAGAIN when it returned
          due to its inability to send off data without blocking. We therefore
          treat both error codes the same here */
-      (EWOULDBLOCK == sockerr) || (EAGAIN == sockerr) || (EINTR == sockerr)
+      (SOCKEWOULDBLOCK == sockerr) ||
+      (EAGAIN == sockerr) || (SOCKEINTR == sockerr)
 #endif
       ) {
       /* this is just a case of EWOULDBLOCK */
index 327a6c36d8cc1ee38dc3182ef4c65c5f925d7738..18a592a7a76b0032211cbe7232061ff8c9a78dcf 100644 (file)
@@ -306,7 +306,7 @@ bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen,
 
   addr[0] = '\0';
   *port = 0;
-  CURL_SETERRNO(EAFNOSUPPORT);
+  CURL_SETERRNO(SOCKEAFNOSUPPORT);
   return FALSE;
 }
 
@@ -608,8 +608,8 @@ static CURLcode baller_connect(struct Curl_cfilter *cf,
       else if(Curl_timediff(*now, baller->started) >= baller->timeoutms) {
         infof(data, "%s connect timeout after %" FMT_TIMEDIFF_T
               "ms, move on!", baller->name, baller->timeoutms);
-#if defined(ETIMEDOUT)
-        baller->error = ETIMEDOUT;
+#ifdef SOCKETIMEDOUT
+        baller->error = SOCKETIMEDOUT;
 #endif
         baller->result = CURLE_OPERATION_TIMEDOUT;
       }
@@ -770,11 +770,8 @@ evaluate:
         Curl_timediff(now, data->progress.t_startsingle),
         curl_easy_strerror(result));
 
-#ifdef WSAETIMEDOUT
-  if(WSAETIMEDOUT == data->state.os_errno)
-    result = CURLE_OPERATION_TIMEDOUT;
-#elif defined(ETIMEDOUT)
-  if(ETIMEDOUT == data->state.os_errno)
+#ifdef SOCKETIMEDOUT
+  if(SOCKETIMEDOUT == data->state.os_errno)
     result = CURLE_OPERATION_TIMEDOUT;
 #endif
 
index 9c9fae6653ff2ea52faee757a3dc0fb7d9217fa5..3c8077d9de3a5920133184e3396c0a4ef97c1fc8 100644 (file)
@@ -269,6 +269,7 @@ int curlx_win32_open(const char *filename, int oflag, ...)
     curlx_unicodefree(filename_w);
   }
   else
+    /* !checksrc! disable ERRNOVAR 1 */
     CURL_SETERRNO(EINVAL);
 #else
   if(fix_excessive_path(filename, &fixed))
@@ -299,6 +300,7 @@ FILE *curlx_win32_fopen(const char *filename, const char *mode)
     result = _wfopen(target, mode_w);
   }
   else
+    /* !checksrc! disable ERRNOVAR 1 */
     CURL_SETERRNO(EINVAL);
   curlx_unicodefree(filename_w);
   curlx_unicodefree(mode_w);
@@ -335,6 +337,7 @@ int curlx_win32_stat(const char *path, struct_stat *buffer)
     curlx_unicodefree(path_w);
   }
   else
+    /* !checksrc! disable ERRNOVAR 1 */
     CURL_SETERRNO(EINVAL);
 #else
   if(fix_excessive_path(path, &fixed))
index 86c8cb07b6d05595e9af66f9c40116e8353fb4b5..c8605fd200e6f7710eca6de96cc187a8a32cd5b9 100644 (file)
 /* Terrible workarounds to make Windows CE compile */
 #define errno 0
 #define CURL_SETERRNO(x) ((void)(x))
+#define EINTR  4
 #define EAGAIN 11
 #define ENOMEM 12
 #define EACCES 13
 #define EEXIST 17
 #define EISDIR 21
+#define EINVAL 22
 #define ENOSPC 28
 #define strerror(x) "?"
 #else
index 9f13dc4189aeba8addb2411871446f59b85d5a48..c1051e0faefe11144d7cd015dc96906dc5d586c0 100644 (file)
@@ -321,32 +321,39 @@ typedef unsigned int bit;
  */
 
 #ifdef USE_WINSOCK
-#undef  EBADF            /* override definition in errno.h */
-#define EBADF            WSAEBADF
-#undef  EINTR            /* override definition in errno.h */
-#define EINTR            WSAEINTR
-#undef  EINVAL           /* override definition in errno.h */
-#define EINVAL           WSAEINVAL
-#undef  EWOULDBLOCK      /* override definition in errno.h */
-#define EWOULDBLOCK      WSAEWOULDBLOCK
-#undef  EINPROGRESS      /* override definition in errno.h */
-#define EINPROGRESS      WSAEINPROGRESS
-#undef  EMSGSIZE         /* override definition in errno.h */
-#define EMSGSIZE         WSAEMSGSIZE
-#undef  EAFNOSUPPORT     /* override definition in errno.h */
-#define EAFNOSUPPORT     WSAEAFNOSUPPORT
-#undef  EADDRINUSE       /* override definition in errno.h */
-#define EADDRINUSE       WSAEADDRINUSE
-#undef  EADDRNOTAVAIL    /* override definition in errno.h */
-#define EADDRNOTAVAIL    WSAEADDRNOTAVAIL
-#undef  ECONNRESET       /* override definition in errno.h */
-#define ECONNRESET       WSAECONNRESET
-#undef  EISCONN          /* override definition in errno.h */
-#define EISCONN          WSAEISCONN
-#undef  ETIMEDOUT        /* override definition in errno.h */
-#define ETIMEDOUT        WSAETIMEDOUT
-#undef  ECONNREFUSED     /* override definition in errno.h */
-#define ECONNREFUSED     WSAECONNREFUSED
+#define SOCKEACCES        WSAEACCES
+#define SOCKEADDRINUSE    WSAEADDRINUSE
+#define SOCKEADDRNOTAVAIL WSAEADDRNOTAVAIL
+#define SOCKEAFNOSUPPORT  WSAEAFNOSUPPORT
+#define SOCKEBADF         WSAEBADF
+#define SOCKECONNREFUSED  WSAECONNREFUSED
+#define SOCKECONNRESET    WSAECONNRESET
+#define SOCKEINPROGRESS   WSAEINPROGRESS
+#define SOCKEINTR         WSAEINTR
+#define SOCKEINVAL        WSAEINVAL
+#define SOCKEISCONN       WSAEISCONN
+#define SOCKEMSGSIZE      WSAEMSGSIZE
+#define SOCKENOMEM        WSA_NOT_ENOUGH_MEMORY
+#define SOCKETIMEDOUT     WSAETIMEDOUT
+#define SOCKEWOULDBLOCK   WSAEWOULDBLOCK
+#else
+#define SOCKEACCES        EACCES
+#define SOCKEADDRINUSE    EADDRINUSE
+#define SOCKEADDRNOTAVAIL EADDRNOTAVAIL
+#define SOCKEAFNOSUPPORT  EAFNOSUPPORT
+#define SOCKEBADF         EBADF
+#define SOCKECONNREFUSED  ECONNREFUSED
+#define SOCKECONNRESET    ECONNRESET
+#define SOCKEINPROGRESS   EINPROGRESS
+#define SOCKEINTR         EINTR
+#define SOCKEINVAL        EINVAL
+#define SOCKEISCONN       EISCONN
+#define SOCKEMSGSIZE      EMSGSIZE
+#define SOCKENOMEM        ENOMEM
+#ifdef ETIMEDOUT
+#define SOCKETIMEDOUT     ETIMEDOUT
+#endif
+#define SOCKEWOULDBLOCK   EWOULDBLOCK
 #endif
 
 /*
index 6f90bfed15a35059aaa1e8eed64571cf7d8abfcf..54f0dcee4955f3d10cacc96e801faaebde4b8bcd 100644 (file)
@@ -127,6 +127,7 @@ curl_thread_t Curl_thread_create(
   if((t == 0) || (t == LongToHandle(-1L))) {
 #ifdef UNDER_CE
     DWORD gle = GetLastError();
+    /* !checksrc! disable ERRNOVAR 1 */
     int err = (gle == ERROR_ACCESS_DENIED ||
                gle == ERROR_NOT_ENOUGH_MEMORY) ?
                EACCES : EINVAL;
index 849254f451cb492616f0bcf3e188fe3b455d31ee..50e3e5273844f4477a9bbb806899d7af7fdd1ca7 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -1063,7 +1063,7 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data,
     if(bind(portsock, sa, sslen) ) {
       /* It failed. */
       error = SOCKERRNO;
-      if(possibly_non_local && (error == EADDRNOTAVAIL)) {
+      if(possibly_non_local && (error == SOCKEADDRNOTAVAIL)) {
         /* The requested bind address is not local. Use the address used for
          * the control connection instead and restart the port loop
          */
@@ -1080,7 +1080,7 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data,
         possibly_non_local = FALSE; /* do not try this again */
         continue;
       }
-      if(error != EADDRINUSE && error != EACCES) {
+      if(error != SOCKEADDRINUSE && error != SOCKEACCES) {
         failf(data, "bind(port=%hu) failed: %s", port,
               Curl_strerror(error, buffer, sizeof(buffer)));
         goto out;
index 401aa9aa48cccc3fb971ec3838887901a360f1f3..6a96527aee2090f043ff2fbdea28478013c0050c 100644 (file)
--- a/lib/idn.c
+++ b/lib/idn.c
@@ -71,6 +71,7 @@ static CURLcode iconv_to_utf8(const char *in, size_t inlen,
     *outlen -= iconv_outlen;
     iconv_close(cd);
     if(iconv_result == (size_t)-1) {
+      /* !checksrc! disable ERRNOVAR 1 */
       if(errno == ENOMEM)
         return CURLE_OUT_OF_MEMORY;
       else
@@ -80,6 +81,7 @@ static CURLcode iconv_to_utf8(const char *in, size_t inlen,
     return CURLE_OK;
   }
   else {
+    /* !checksrc! disable ERRNOVAR 1 */
     if(errno == ENOMEM)
       return CURLE_OUT_OF_MEMORY;
     else
index 51126ce9c4ca35ab20793e702ef17eea8ff2ade0..26d84a907b9f72058eb8f21a705adab3c952dc6f 100644 (file)
@@ -74,7 +74,11 @@ static char *inet_ntop4(const unsigned char *src, char *dst, size_t size)
 
   len = strlen(tmp);
   if(len == 0 || len >= size) {
+#ifdef USE_WINSOCK
+    CURL_SETERRNO(WSAEINVAL);
+#else
     CURL_SETERRNO(ENOSPC);
+#endif
     return NULL;
   }
   strcpy(dst, tmp);
@@ -153,7 +157,6 @@ static char *inet_ntop6(const unsigned char *src, char *dst, size_t size)
     if(i == 6 && best.base == 0 &&
         (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
       if(!inet_ntop4(src + 12, tp, sizeof(tmp) - (tp - tmp))) {
-        CURL_SETERRNO(ENOSPC);
         return NULL;
       }
       tp += strlen(tp);
@@ -171,7 +174,11 @@ static char *inet_ntop6(const unsigned char *src, char *dst, size_t size)
   /* Check for overflow, copy, and we are done.
    */
   if((size_t)(tp - tmp) > size) {
+#ifdef USE_WINSOCK
+    CURL_SETERRNO(WSAEINVAL);
+#else
     CURL_SETERRNO(ENOSPC);
+#endif
     return NULL;
   }
   strcpy(dst, tmp);
@@ -197,7 +204,7 @@ char *curlx_inet_ntop(int af, const void *src, char *buf, size_t size)
   case AF_INET6:
     return inet_ntop6((const unsigned char *)src, buf, size);
   default:
-    CURL_SETERRNO(EAFNOSUPPORT);
+    CURL_SETERRNO(SOCKEAFNOSUPPORT);
     return NULL;
   }
 }
index 7531f719c73de87f7b03e2cd14344da80dfe0c88..5a871a3099490a377a0aa62bc2335fbfe1a7e825 100644 (file)
@@ -80,7 +80,7 @@ curlx_inet_pton(int af, const char *src, void *dst)
   case AF_INET6:
     return inet_pton6(src, (unsigned char *)dst);
   default:
-    CURL_SETERRNO(EAFNOSUPPORT);
+    CURL_SETERRNO(SOCKEAFNOSUPPORT);
     return -1;
   }
   /* NOTREACHED */
index d72d557013da3ef2b75d8e4b378e08aadd988dde..05b625cfcec3812de7ea1c041fa3e239d9f751e4 100644 (file)
@@ -117,13 +117,12 @@ static bool countcheck(const char *func, int line, const char *source)
       fprintf(stderr, "LIMIT %s:%d %s reached memlimit\n",
               source, line, func);
       fflush(curl_dbg_logfile); /* because it might crash now */
+      /* !checksrc! disable ERRNOVAR 1 */
       CURL_SETERRNO(ENOMEM);
       return TRUE; /* RETURN ERROR! */
     }
     else
       memsize--; /* countdown */
-
-
   }
 
   return FALSE; /* allow this */
index ee3cad724ac1594b76e38c829c209e224b25a1b1..7b54850a63b0c9677bb7feada6c5c34f3f448fb3 100644 (file)
@@ -1328,7 +1328,7 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
                when there is no more data, breaking the loop. */
             nread = wakeup_read(multi->wakeup_pair[0], buf, sizeof(buf));
             if(nread <= 0) {
-              if(nread < 0 && EINTR == SOCKERRNO)
+              if(nread < 0 && SOCKEINTR == SOCKERRNO)
                 continue;
               break;
             }
@@ -1429,11 +1429,11 @@ CURLMcode curl_multi_wakeup(CURLM *m)
         int err = SOCKERRNO;
         int return_success;
 #ifdef USE_WINSOCK
-        return_success = WSAEWOULDBLOCK == err;
+        return_success = SOCKEWOULDBLOCK == err;
 #else
-        if(EINTR == err)
+        if(SOCKEINTR == err)
           continue;
-        return_success = EWOULDBLOCK == err || EAGAIN == err;
+        return_success = SOCKEWOULDBLOCK == err || EAGAIN == err;
 #endif
         if(!return_success)
           return CURLM_WAKEUP_FAILURE;
index 8b5cebd60115082fb75b72d3c3b755e787006fae..dd07499e11e622d5ee9451c2ecf09bcd3b11dedb 100644 (file)
@@ -1170,7 +1170,7 @@ ldapsb_tls_read(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len)
 
       ret = (li->recv)(data, FIRSTSOCKET, buf, len, &err);
       if(ret < 0 && err == CURLE_AGAIN) {
-        SET_SOCKERRNO(EWOULDBLOCK);
+        SET_SOCKERRNO(SOCKEWOULDBLOCK);
       }
     }
   }
@@ -1189,7 +1189,7 @@ ldapsb_tls_write(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len)
       CURLcode err = CURLE_SEND_ERROR;
       ret = (li->send)(data, FIRSTSOCKET, buf, len, FALSE, &err);
       if(ret < 0 && err == CURLE_AGAIN) {
-        SET_SOCKERRNO(EWOULDBLOCK);
+        SET_SOCKERRNO(SOCKEWOULDBLOCK);
       }
     }
   }
index a7e9ce53ac2f7744c70e61f3a901ef8b23867e85..23280c6d989e783b2df98dfd083a261374b0f14b 100644 (file)
@@ -74,7 +74,7 @@ int Curl_wait_ms(timediff_t timeout_ms)
   if(!timeout_ms)
     return 0;
   if(timeout_ms < 0) {
-    SET_SOCKERRNO(EINVAL);
+    SET_SOCKERRNO(SOCKEINVAL);
     return -1;
   }
 #if defined(MSDOS)
@@ -96,7 +96,7 @@ int Curl_wait_ms(timediff_t timeout_ms)
   }
 #endif /* _WIN32 */
   if(r) {
-    if((r == -1) && (SOCKERRNO == EINTR))
+    if((r == -1) && (SOCKERRNO == SOCKEINTR))
       /* make EINTR from select or poll not a "lethal" error */
       r = 0;
     else
@@ -312,7 +312,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms)
     pending_ms = 0;
   r = poll(ufds, nfds, pending_ms);
   if(r <= 0) {
-    if((r == -1) && (SOCKERRNO == EINTR))
+    if((r == -1) && (SOCKERRNO == SOCKEINTR))
       /* make EINTR from select or poll not a "lethal" error */
       r = 0;
     return r;
@@ -360,7 +360,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms)
   */
   r = our_select(maxfd, &fds_read, &fds_write, &fds_err, timeout_ms);
   if(r <= 0) {
-    if((r == -1) && (SOCKERRNO == EINTR))
+    if((r == -1) && (SOCKERRNO == SOCKEINTR))
       /* make EINTR from select or poll not a "lethal" error */
       r = 0;
     return r;
index 60e166b0014b192c218d40efdb77bdb38c6e7681..10968fab7f898eb19ef58b4602befaac6dc953fb 100644 (file)
@@ -93,7 +93,7 @@ int Curl_wait_ms(timediff_t timeout_ms);
 #define FDSET_SOCK(x) 1
 #define VERIFY_SOCK(x) do { \
   if(!VALID_SOCK(x)) { \
-    SET_SOCKERRNO(WSAEINVAL); \
+    SET_SOCKERRNO(SOCKEINVAL); \
     return -1; \
   } \
 } while(0)
@@ -105,7 +105,7 @@ int Curl_wait_ms(timediff_t timeout_ms);
 
 #define VERIFY_SOCK(x) do {                     \
     if(!VALID_SOCK(x) || !FDSET_SOCK(x)) {      \
-      SET_SOCKERRNO(EINVAL);                    \
+      SET_SOCKERRNO(SOCKEINVAL);                \
       return -1;                                \
     }                                           \
   } while(0)
index 0bb70419dbe203f47f1e0aa9731a17281b8413e5..85fb7a826cff7131bb31d9163c61224a2b428608 100644 (file)
@@ -223,15 +223,15 @@ int Curl_socketpair(int domain, int type, int protocol,
         if(Curl_timediff(Curl_now(), start) > (60 * 1000))
           goto error;
         if(
-#ifdef WSAEWOULDBLOCK
+#ifdef USE_WINSOCK
           /* This is how Windows does it */
-          (WSAEWOULDBLOCK == sockerr)
+          (SOCKEWOULDBLOCK == sockerr)
 #else
           /* errno may be EWOULDBLOCK or on some systems EAGAIN when it
              returned due to its inability to send off data without
              blocking. We therefore treat both error codes the same here */
-          (EWOULDBLOCK == sockerr) || (EAGAIN == sockerr) ||
-          (EINTR == sockerr) || (EINPROGRESS == sockerr)
+          (SOCKEWOULDBLOCK == sockerr) || (EAGAIN == sockerr) ||
+          (SOCKEINTR == sockerr) || (SOCKEINPROGRESS == sockerr)
 #endif
           ) {
           continue;
index ee4d73b24300835caa018b27aeb0567fe76ebc17..f35298ab7ce474096f84eacaed160f6ccc536426 100644 (file)
@@ -1449,7 +1449,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
       events.lNetworkEvents = 0;
       if(WSAEnumNetworkEvents(sockfd, event_handle, &events) == SOCKET_ERROR) {
         err = SOCKERRNO;
-        if(err != EINPROGRESS) {
+        if(err != SOCKEINPROGRESS) {
           infof(data, "WSAEnumNetworkEvents failed (%d)", err);
           keepon = FALSE;
           result = CURLE_READ_ERROR;
@@ -1554,7 +1554,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
           /* In test 1452, macOS sees a ECONNRESET sometimes? Is this the
            * telnet test server not shutting down the socket in a clean way?
            * Seems to be timing related, happens more on slow debug build */
-          if(data->state.os_errno == ECONNRESET) {
+          if(data->state.os_errno == SOCKECONNRESET) {
             DEBUGF(infof(data, "telnet_do, unexpected ECONNRESET on recv"));
           }
           break;
index a36d424702a238c7ef941e36e78b6c011b318e88..1e7a258b612d1ae1ed8c60c8c9383bf785d025a3 100644 (file)
@@ -148,17 +148,18 @@ static CURLcode do_sendmsg(struct Curl_cfilter *cf,
 #endif
 
 
-  while((sent = sendmsg(qctx->sockfd, &msg, 0)) == -1 && SOCKERRNO == EINTR)
+  while((sent = sendmsg(qctx->sockfd, &msg, 0)) == -1 &&
+        SOCKERRNO == SOCKEINTR)
     ;
 
   if(sent == -1) {
     switch(SOCKERRNO) {
     case EAGAIN:
-#if EAGAIN != EWOULDBLOCK
-    case EWOULDBLOCK:
+#if EAGAIN != SOCKEWOULDBLOCK
+    case SOCKEWOULDBLOCK:
 #endif
       return CURLE_AGAIN;
-    case EMSGSIZE:
+    case SOCKEMSGSIZE:
       /* UDP datagram is too large; caused by PMTUD. Just let it be lost. */
       break;
     case EIO:
@@ -186,16 +187,16 @@ static CURLcode do_sendmsg(struct Curl_cfilter *cf,
 
   while((sent = send(qctx->sockfd,
                      (const char *)pkt, (SEND_TYPE_ARG3)pktlen, 0)) == -1 &&
-        SOCKERRNO == EINTR)
+        SOCKERRNO == SOCKEINTR)
     ;
 
   if(sent == -1) {
-    if(SOCKERRNO == EAGAIN || SOCKERRNO == EWOULDBLOCK) {
+    if(SOCKERRNO == EAGAIN || SOCKERRNO == SOCKEWOULDBLOCK) {
       return CURLE_AGAIN;
     }
     else {
       failf(data, "send() returned %zd (errno %d)", sent, SOCKERRNO);
-      if(SOCKERRNO != EMSGSIZE) {
+      if(SOCKERRNO != SOCKEMSGSIZE) {
         return CURLE_SEND_ERROR;
       }
       /* UDP datagram is too large; caused by PMTUD. Just let it be
@@ -392,14 +393,14 @@ static CURLcode recvmmsg_packets(struct Curl_cfilter *cf,
     }
 
     while((mcount = recvmmsg(qctx->sockfd, mmsg, n, 0, NULL)) == -1 &&
-          SOCKERRNO == EINTR)
+          SOCKERRNO == SOCKEINTR)
       ;
     if(mcount == -1) {
-      if(SOCKERRNO == EAGAIN || SOCKERRNO == EWOULDBLOCK) {
+      if(SOCKERRNO == EAGAIN || SOCKERRNO == SOCKEWOULDBLOCK) {
         CURL_TRC_CF(data, cf, "ingress, recvmmsg -> EAGAIN");
         goto out;
       }
-      if(!cf->connected && SOCKERRNO == ECONNREFUSED) {
+      if(!cf->connected && SOCKERRNO == SOCKECONNREFUSED) {
         struct ip_quadruple ip;
         Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip);
         failf(data, "QUIC: connection to %s port %u refused",
@@ -484,13 +485,13 @@ static CURLcode recvmsg_packets(struct Curl_cfilter *cf,
     msg.msg_namelen = sizeof(remote_addr);
     msg.msg_controllen = sizeof(msg_ctrl);
     while((nread = recvmsg(qctx->sockfd, &msg, 0)) == -1 &&
-          SOCKERRNO == EINTR)
+          SOCKERRNO == SOCKEINTR)
       ;
     if(nread == -1) {
-      if(SOCKERRNO == EAGAIN || SOCKERRNO == EWOULDBLOCK) {
+      if(SOCKERRNO == EAGAIN || SOCKERRNO == SOCKEWOULDBLOCK) {
         goto out;
       }
-      if(!cf->connected && SOCKERRNO == ECONNREFUSED) {
+      if(!cf->connected && SOCKERRNO == SOCKECONNREFUSED) {
         struct ip_quadruple ip;
         Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip);
         failf(data, "QUIC: connection to %s port %u refused",
@@ -558,14 +559,14 @@ static CURLcode recvfrom_packets(struct Curl_cfilter *cf,
     while((nread = recvfrom(qctx->sockfd, (char *)buf, bufsize, 0,
                             (struct sockaddr *)&remote_addr,
                             &remote_addrlen)) == -1 &&
-          SOCKERRNO == EINTR)
+          SOCKERRNO == SOCKEINTR)
       ;
     if(nread == -1) {
-      if(SOCKERRNO == EAGAIN || SOCKERRNO == EWOULDBLOCK) {
+      if(SOCKERRNO == EAGAIN || SOCKERRNO == SOCKEWOULDBLOCK) {
         CURL_TRC_CF(data, cf, "ingress, recvfrom -> EAGAIN");
         goto out;
       }
-      if(!cf->connected && SOCKERRNO == ECONNREFUSED) {
+      if(!cf->connected && SOCKERRNO == SOCKECONNREFUSED) {
         struct ip_quadruple ip;
         Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip);
         failf(data, "QUIC: connection to %s port %u refused",
index 6924140299ab0de8e00897ff736836bc986d8d65..7db06e759ae7b3adaa24628802dacdd4a8b36646 100644 (file)
@@ -100,6 +100,7 @@ static ssize_t gtls_push(void *s, const void *buf, size_t blen)
               blen, nwritten, result);
   backend->gtls.io_result = result;
   if(nwritten < 0) {
+    /* !checksrc! disable ERRNOVAR 1 */
     gnutls_transport_set_errno(backend->gtls.session,
                                (CURLE_AGAIN == result) ? EAGAIN : EINVAL);
     nwritten = -1;
@@ -121,6 +122,7 @@ static ssize_t gtls_pull(void *s, void *buf, size_t blen)
   if(!backend->gtls.shared_creds->trust_setup) {
     result = Curl_gtls_client_trust_setup(cf, data, &backend->gtls);
     if(result) {
+      /* !checksrc! disable ERRNOVAR 1 */
       gnutls_transport_set_errno(backend->gtls.session, EINVAL);
       backend->gtls.io_result = result;
       return -1;
@@ -132,6 +134,7 @@ static ssize_t gtls_pull(void *s, void *buf, size_t blen)
               blen, nread, result);
   backend->gtls.io_result = result;
   if(nread < 0) {
+    /* !checksrc! disable ERRNOVAR 1 */
     gnutls_transport_set_errno(backend->gtls.session,
                                (CURLE_AGAIN == result) ? EAGAIN : EINVAL);
     nread = -1;
index 529d6b9c1cb3c0ff96d56f384e21ecacd469bf19..61c7bdf87e610bac1d5ee00201ffb3b3ca425639 100644 (file)
@@ -98,6 +98,7 @@ read_cb(void *userdata, uint8_t *buf, uintptr_t len, uintptr_t *out_n)
                                     (char *)buf, len, &result);
   if(nread < 0) {
     nread = 0;
+    /* !checksrc! disable ERRNOVAR 4 */
     if(CURLE_AGAIN == result)
       ret = EAGAIN;
     else
index 48f7f6d4aeb1296a49e5e72bf95a73c8bb459c78..ccd397f0e6334691f6a99418e40403844838d3e0 100644 (file)
@@ -290,6 +290,7 @@ curl_easy_escape_ccsid(CURL *handle, const char *string, int length,
   char *d;
 
   if(!string) {
+    /* !checksrc! disable ERRNOVAR 1 */
     errno = EINVAL;
     return (char *) NULL;
     }
@@ -320,6 +321,7 @@ curl_easy_unescape_ccsid(CURL *handle, const char *string, int length,
   char *d;
 
   if(!string) {
+    /* !checksrc! disable ERRNOVAR 1 */
     errno = EINVAL;
     return (char *) NULL;
     }
index 07be5dcc514bbfc6e1cebeae56ad3523c2a4f476..7be72085498b48b16c924757b54547868c96eff3 100644 (file)
@@ -357,6 +357,7 @@ Curl_gss_convert_in_place(OM_uint32 *minor_status, gss_buffer_t buf)
       gss_release_buffer(minor_status, buf);
 
       if(minor_status)
+        /* !checksrc! disable ERRNOVAR 1 */
         *minor_status = ENOMEM;
 
       return -1;
@@ -388,6 +389,7 @@ Curl_gss_import_name_a(OM_uint32 *minor_status, gss_buffer_t in_name,
   in.value = malloc(i + 1);
   if(!in.value) {
     if(minor_status)
+      /* !checksrc! disable ERRNOVAR 1 */
       *minor_status = ENOMEM;
 
     return GSS_S_FAILURE;
@@ -451,6 +453,7 @@ Curl_gss_init_sec_context_a(OM_uint32 *minor_status,
       in.value = malloc(i + 1);
       if(!in.value) {
         if(minor_status)
+          /* !checksrc! disable ERRNOVAR 1 */
           *minor_status = ENOMEM;
 
         return GSS_S_FAILURE;
@@ -801,6 +804,7 @@ sockaddr2ebcdic(struct sockaddr_storage *dstaddr,
 
   if(!srcaddr || srclen < offsetof(struct sockaddr, sa_family) +
      sizeof(srcaddr->sa_family) || srclen > sizeof(*dstaddr)) {
+    /* !checksrc! disable ERRNOVAR 1 */
     errno = EINVAL;
     return -1;
   }
@@ -838,6 +842,7 @@ sockaddr2ascii(struct sockaddr *dstaddr, int dstlen,
   if(srclen > dstlen)
     srclen = dstlen;
   if(!srcaddr || srclen < 0) {
+    /* !checksrc! disable ERRNOVAR 1 */
     errno = EINVAL;
     return -1;
   }
index 8289c14c5c6e2d1b46d7daa8bcd0e370cf7f2583..2ebb8650f60bd26c5e26732e73d751c574e4c584 100755 (executable)
@@ -97,6 +97,7 @@ my %warnings = (
     'EMPTYLINEBRACE'        => 'Empty line before the open brace',
     'EQUALSNOSPACE'         => 'equals sign without following space',
     'EQUALSNULL'            => 'if/while comparison with == NULL',
+    'ERRNOVAR'              => 'use of bare errno define',
     'EXCLAMATIONSPACE'      => 'Whitespace after exclamation mark in expression',
     'FOPENMODE'             => 'fopen needs a macro for the mode string',
     'INCLUDEDUP',           => 'same file is included again',
@@ -1022,6 +1023,12 @@ sub scanfile {
                       "space after exclamation mark");
         }
 
+        if($nostr =~ /(.*)\b(EACCES|EADDRINUSE|EADDRNOTAVAIL|EAFNOSUPPORT|EBADF|ECONNREFUSED|ECONNRESET|EINPROGRESS|EINTR|EINVAL|EISCONN|EMSGSIZE|ENOMEM|ETIMEDOUT|EWOULDBLOCK)\b/) {
+            checkwarn("ERRNOVAR",
+                      $line, length($1), $file, $ol,
+                      "use of bare errno define $2, use SOCK$2");
+        }
+
         # check for more than one consecutive space before open brace or
         # question mark. Skip lines containing strings since they make it hard
         # due to artificially getting multiple spaces
index f33f338d6562d96beedf5eb7db05c83012e4d6c8..7a575c98f6b1b13351368a7ade909015dc078551 100644 (file)
@@ -68,6 +68,7 @@ bool tool_create_output_file(struct OutStruct *outs,
     do {
       fd = open(fname, O_CREAT | O_WRONLY | O_EXCL | CURL_O_BINARY, OPENMODE);
       /* Keep retrying in the hope that it is not interrupted sometime */
+      /* !checksrc! disable ERRNOVAR 1 */
     } while(fd == -1 && errno == EINTR);
     if(config->file_clobber_mode == CLOBBER_NEVER && fd == -1) {
       int next_num = 1;
@@ -86,6 +87,7 @@ bool tool_create_output_file(struct OutStruct *outs,
       }
       memcpy(newname, fname, len);
       newname[len] = '.';
+      /* !checksrc! disable ERRNOVAR 1 */
       while(fd == -1 && /* have not successfully opened a file */
             (errno == EEXIST || errno == EISDIR) &&
             /* because we keep having files that already exist */
index 1360ddd6bb2a098bc122c9e2421960c7bdaad045..ac9b969a8da76b0ada16be3eb8351f5919667bd9 100644 (file)
@@ -48,6 +48,7 @@ static void show_dir_errno(struct GlobalConfig *global, const char *name)
 {
   switch(errno) {
 #ifdef EACCES
+  /* !checksrc! disable ERRNOVAR 1 */
   case EACCES:
     errorf(global, "You do not have permission to create %s", name);
     break;
@@ -129,6 +130,7 @@ CURLcode create_dir_hierarchy(const char *outfile, struct GlobalConfig *global)
       return result;
 
     /* Create directory. Ignore access denied error to allow traversal. */
+    /* !checksrc! disable ERRNOVAR 1 */
     if(!skip && (-1 == mkdir(curlx_dyn_ptr(&dirbuf), (mode_t)0000750)) &&
        (errno != EACCES) && (errno != EEXIST)) {
       show_dir_errno(global, curlx_dyn_ptr(&dirbuf));
index 3a8d932973b5c8032c6c08bd7863ca4d5d1cde7b..24e62d3fbbca4def092798731ec6164ea9beb3e9 100644 (file)
@@ -547,7 +547,7 @@ static CURLcode post_per_transfer(struct GlobalConfig *global,
             (CURLE_COULDNT_CONNECT == result)) {
       long oserrno = 0;
       curl_easy_getinfo(curl, CURLINFO_OS_ERRNO, &oserrno);
-      if(ECONNREFUSED == oserrno)
+      if(SOCKECONNREFUSED == oserrno)
         retry = RETRY_CONNREFUSED;
     }
     else if((CURLE_OK == result) ||
index a70fd54e5f4ca4a7a3a1657ed8aec26fd12ff43d..3192b8a94256350aac5cc2857ce921c361270c1f 100644 (file)
@@ -41,7 +41,7 @@ int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc,
                    struct timeval *tv)
 {
   if(nfds < 0) {
-    SET_SOCKERRNO(EINVAL);
+    SET_SOCKERRNO(SOCKEINVAL);
     return -1;
   }
 #ifdef USE_WINSOCK
index 81ecf041199aa4e447914b9331475b9294d04e98..9d6a58b9a35c721b1271bf6a2560844c11a52d88 100644 (file)
@@ -573,6 +573,7 @@ static void rtspd_storerequest(char *reqbuf, size_t totalsize)
 
   do {
     dump = fopen(dumpfile, "ab");
+    /* !checksrc! disable ERRNOVAR 1 */
   } while(!dump && ((error = errno) == EINTR));
   if(!dump) {
     logmsg("Error opening file %s error (%d) %s",
@@ -589,6 +590,7 @@ static void rtspd_storerequest(char *reqbuf, size_t totalsize)
       goto storerequest_cleanup;
     if(written > 0)
       writeleft -= written;
+    /* !checksrc! disable ERRNOVAR 1 */
   } while((writeleft > 0) && ((error = errno) == EINTR));
 
   if(writeleft == 0)
index 6dfd52b82be92a8d8052298282f6921aba2e4844..3fad138ab02a64c19da86735f3be66d564912010 100644 (file)
@@ -228,6 +228,7 @@ static ssize_t fullread(int filedes, void *buffer, size_t nbytes)
 
     if(rc < 0) {
       error = errno;
+      /* !checksrc! disable ERRNOVAR 1 */
       if((error == EINTR) || (error == EAGAIN))
         continue;
       if(error == CURL_WIN32_EPIPE) {
@@ -279,6 +280,7 @@ static ssize_t fullwrite(int filedes, const void *buffer, size_t nbytes)
 
     if(wc < 0) {
       error = errno;
+      /* !checksrc! disable ERRNOVAR 1 */
       if((error == EINTR) || (error == EAGAIN))
         continue;
       logmsg("writing to file descriptor: %d,", filedes);
@@ -624,7 +626,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
 
   /* check if the input value is valid */
   if(nfds < 0) {
-    CURL_SETERRNO(EINVAL);
+    SET_SOCKERRNO(SOCKEINVAL);
     return -1;
   }
 
@@ -645,7 +647,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
   /* create internal event to abort waiting threads */
   abort = CreateEvent(NULL, TRUE, FALSE, NULL);
   if(!abort) {
-    CURL_SETERRNO(ENOMEM);
+    SET_SOCKERRNO(SOCKENOMEM);
     return -1;
   }
 
@@ -653,7 +655,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
   data = calloc(nfds, sizeof(struct select_ws_data));
   if(!data) {
     CloseHandle(abort);
-    CURL_SETERRNO(ENOMEM);
+    SET_SOCKERRNO(SOCKENOMEM);
     return -1;
   }
 
@@ -662,7 +664,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
   if(!handles) {
     CloseHandle(abort);
     free(data);
-    CURL_SETERRNO(ENOMEM);
+    SET_SOCKERRNO(SOCKENOMEM);
     return -1;
   }
 
index 19a287f0ae668220ebc896ef241f5dce35f64675..ef3d126a64205e451983c8af61d8366991a506a8 100644 (file)
@@ -761,6 +761,7 @@ static void sws_storerequest(const char *reqbuf, size_t totalsize)
 
   do {
     dump = fopen(dumpfile, "ab");
+    /* !checksrc! disable ERRNOVAR 1 */
   } while(!dump && ((error = errno) == EINTR));
   if(!dump) {
     logmsg("[2] Error opening file %s error (%d) %s",
@@ -777,6 +778,7 @@ static void sws_storerequest(const char *reqbuf, size_t totalsize)
       goto storerequest_cleanup;
     if(written > 0)
       writeleft -= written;
+    /* !checksrc! disable ERRNOVAR 1 */
   } while((writeleft > 0) && ((error = errno) == EINTR));
 
   if(writeleft == 0)
index 79b64c39afe2d6c7682096349cab658ad98a1fe1..06395f096d9a040deeab4bc83a8bca5a2bc1593b 100644 (file)
@@ -128,6 +128,7 @@ void logmsg(const char *msg, ...)
 
   do {
     logfp = fopen(serverlogfile, "ab");
+    /* !checksrc! disable ERRNOVAR 1 */
   } while(!logfp && (errno == EINTR));
   if(logfp) {
     fprintf(logfp, "%s %s\n", timebuf, buffer);
@@ -353,6 +354,7 @@ void set_advisor_read_lock(const char *filename)
 
   do {
     lockfile = fopen(filename, "wb");
+    /* !checksrc! disable ERRNOVAR 1 */
   } while(!lockfile && ((error = errno) == EINTR));
   if(!lockfile) {
     logmsg("Error creating lock file %s error (%d) %s",
@@ -379,6 +381,7 @@ void clear_advisor_read_lock(const char *filename)
 
   do {
     res = unlink(filename);
+    /* !checksrc! disable ERRNOVAR 1 */
   } while(res && ((error = errno) == EINTR));
   if(res)
     logmsg("Error removing lock file %s error (%d) %s",
index dd9c13039f558c11a1d6eaec5117f41a065069ef..09008f1042a322c6bf6a0ea919d42eb6a3ddfddd 100644 (file)
  ***************************************************************************/
 #include "server_setup.h"
 
-#ifdef USE_WINSOCK
-#define SOCKEADDRINUSE   WSAEADDRINUSE
-#define SOCKECONNREFUSED WSAECONNREFUSED
-#define SOCKEINPROGRESS  WSAEINPROGRESS
-#define SOCKEINTR        WSAEINTR
-#define SOCKEINVAL       WSAEINVAL
-#define SOCKEISCONN      WSAEISCONN
-#define SOCKEWOULDBLOCK  WSAEWOULDBLOCK
-#else
-#define SOCKEADDRINUSE   EADDRINUSE
-#define SOCKECONNREFUSED ECONNREFUSED
-#define SOCKEINPROGRESS  EINPROGRESS
-#define SOCKEINTR        EINTR
-#define SOCKEINVAL       EINVAL
-#define SOCKEISCONN      EISCONN
-#define SOCKEWOULDBLOCK  EWOULDBLOCK
-#endif
-
 enum {
   DOCNUMBER_NOTHING    = -7,
   DOCNUMBER_QUIT       = -6,