[vlc-commits] [Git][videolan/vlc][master] compat: add missing errno on Winsock errors

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Tue Jun 28 17:55:13 UTC 2022



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
ddcc2cdc by Steve Lhomme at 2022-06-28T17:24:51+00:00
compat: add missing errno on Winsock errors

Some of the error codes [1] correspond to errno values [2]

[1] https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
[2] https://docs.microsoft.com/en-us/cpp/c-runtime-library/errno-constants

- - - - -


2 changed files:

- compat/recvmsg.c
- compat/sendmsg.c


Changes:

=====================================
compat/recvmsg.c
=====================================
@@ -74,11 +74,51 @@ ssize_t recvmsg(int fd, struct msghdr *msg, int flags)
         return rcvd;
     }
 
-    switch (WSAGetLastError())
+    int err = WSAGetLastError();
+    switch (err)
     {
         case WSAEWOULDBLOCK:
             errno = EAGAIN;
             break;
+        case WSA_NOT_ENOUGH_MEMORY:
+            errno = ENOMEM;
+            break;
+        case WSAEAFNOSUPPORT:
+            errno = EAFNOSUPPORT;
+            break;
+        case WSAENOBUFS:
+            errno = ENOBUFS;
+            break;
+        case WSAEINPROGRESS:
+            errno = EINPROGRESS;
+            break;
+        case WSAEINTR:
+            errno = EINTR;
+            break;
+        case WSAEBADF:
+            errno = EBADF;
+            break;
+        case WSAEACCES:
+            errno = EACCES;
+            break;
+        case WSAEFAULT:
+            errno = EFAULT;
+            break;
+        case WSAEINVAL:
+            errno = EINVAL;
+            break;
+        case WSAEMFILE:
+            errno = EMFILE;
+            break;
+        case WSAEALREADY:
+            errno = EALREADY;
+            break;
+        case WSAECONNRESET:
+            errno = ECONNRESET;
+            break;
+        default:
+            errno = err;
+            break;
     }
     return -1;
 }


=====================================
compat/sendmsg.c
=====================================
@@ -64,11 +64,51 @@ ssize_t sendmsg(int fd, const struct msghdr *msg, int flags)
     if (ret == 0)
         return sent;
 
-    switch (WSAGetLastError())
+    int err = WSAGetLastError();
+    switch (err)
     {
         case WSAEWOULDBLOCK:
             errno = EAGAIN;
             break;
+        case WSA_NOT_ENOUGH_MEMORY:
+            errno = ENOMEM;
+            break;
+        case WSAEAFNOSUPPORT:
+            errno = EAFNOSUPPORT;
+            break;
+        case WSAENOBUFS:
+            errno = ENOBUFS;
+            break;
+        case WSAEINPROGRESS:
+            errno = EINPROGRESS;
+            break;
+        case WSAEINTR:
+            errno = EINTR;
+            break;
+        case WSAEBADF:
+            errno = EBADF;
+            break;
+        case WSAEACCES:
+            errno = EACCES;
+            break;
+        case WSAEFAULT:
+            errno = EFAULT;
+            break;
+        case WSAEINVAL:
+            errno = EINVAL;
+            break;
+        case WSAEMFILE:
+            errno = EMFILE;
+            break;
+        case WSAEALREADY:
+            errno = EALREADY;
+            break;
+        case WSAECONNRESET:
+            errno = ECONNRESET;
+            break;
+        default:
+            errno = err;
+            break;
     }
     return -1;
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/ddcc2cdcff84e6a83a4dfe581fddde6f524877aa

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/ddcc2cdcff84e6a83a4dfe581fddde6f524877aa
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list