Commit b69eb168 authored by Bruno Jesus's avatar Bruno Jesus Committed by Alexandre Julliard

ws2_32: Convert EBADF errno to ENOTSOCK.

parent 383ed3ce
...@@ -863,7 +863,6 @@ static UINT sock_get_error( int err ) ...@@ -863,7 +863,6 @@ static UINT sock_get_error( int err )
switch(err) switch(err)
{ {
case EINTR: return WSAEINTR; case EINTR: return WSAEINTR;
case EBADF: return WSAEBADF;
case EPERM: case EPERM:
case EACCES: return WSAEACCES; case EACCES: return WSAEACCES;
case EFAULT: return WSAEFAULT; case EFAULT: return WSAEFAULT;
...@@ -872,6 +871,7 @@ static UINT sock_get_error( int err ) ...@@ -872,6 +871,7 @@ static UINT sock_get_error( int err )
case EWOULDBLOCK: return WSAEWOULDBLOCK; case EWOULDBLOCK: return WSAEWOULDBLOCK;
case EINPROGRESS: return WSAEINPROGRESS; case EINPROGRESS: return WSAEINPROGRESS;
case EALREADY: return WSAEALREADY; case EALREADY: return WSAEALREADY;
case EBADF:
case ENOTSOCK: return WSAENOTSOCK; case ENOTSOCK: return WSAENOTSOCK;
case EDESTADDRREQ: return WSAEDESTADDRREQ; case EDESTADDRREQ: return WSAEDESTADDRREQ;
case EMSGSIZE: return WSAEMSGSIZE; case EMSGSIZE: return WSAEMSGSIZE;
...@@ -2901,9 +2901,6 @@ int WINAPI WS_bind(SOCKET s, const struct WS_sockaddr* name, int namelen) ...@@ -2901,9 +2901,6 @@ int WINAPI WS_bind(SOCKET s, const struct WS_sockaddr* name, int namelen)
errno = loc_errno; errno = loc_errno;
switch (errno) switch (errno)
{ {
case EBADF:
SetLastError(WSAENOTSOCK);
break;
case EADDRNOTAVAIL: case EADDRNOTAVAIL:
SetLastError(WSAEINVAL); SetLastError(WSAEINVAL);
break; break;
...@@ -3360,7 +3357,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level, ...@@ -3360,7 +3357,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
convert_sockopt(&level, &optname); convert_sockopt(&level, &optname);
if (getsockopt(fd, level, optname, optval, (socklen_t *)optlen) != 0 ) if (getsockopt(fd, level, optname, optval, (socklen_t *)optlen) != 0 )
{ {
SetLastError((errno == EBADF) ? WSAENOTSOCK : wsaErrno()); SetLastError(wsaErrno());
ret = SOCKET_ERROR; ret = SOCKET_ERROR;
} }
release_sock_fd( s, fd ); release_sock_fd( s, fd );
...@@ -3370,7 +3367,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level, ...@@ -3370,7 +3367,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
return SOCKET_ERROR; return SOCKET_ERROR;
if (getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, optval, (socklen_t *)optlen) != 0 ) if (getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, optval, (socklen_t *)optlen) != 0 )
{ {
SetLastError((errno == EBADF) ? WSAENOTSOCK : wsaErrno()); SetLastError(wsaErrno());
ret = SOCKET_ERROR; ret = SOCKET_ERROR;
} }
else else
...@@ -3467,7 +3464,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level, ...@@ -3467,7 +3464,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
if (getsockopt(fd, SOL_SOCKET, SO_LINGER, &lingval, &len) != 0 ) if (getsockopt(fd, SOL_SOCKET, SO_LINGER, &lingval, &len) != 0 )
{ {
SetLastError((errno == EBADF) ? WSAENOTSOCK : wsaErrno()); SetLastError(wsaErrno());
ret = SOCKET_ERROR; ret = SOCKET_ERROR;
} }
else else
...@@ -3519,7 +3516,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level, ...@@ -3519,7 +3516,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
return SOCKET_ERROR; return SOCKET_ERROR;
if (getsockopt(fd, SOL_SOCKET, SO_ERROR, optval, (socklen_t *)optlen) != 0 ) if (getsockopt(fd, SOL_SOCKET, SO_ERROR, optval, (socklen_t *)optlen) != 0 )
{ {
SetLastError((errno == EBADF) ? WSAENOTSOCK : wsaErrno()); SetLastError(wsaErrno());
ret = SOCKET_ERROR; ret = SOCKET_ERROR;
} }
release_sock_fd( s, fd ); release_sock_fd( s, fd );
...@@ -3565,7 +3562,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level, ...@@ -3565,7 +3562,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
} }
else if (getsockopt(fd, SOL_SOCKET, SO_LINGER, &lingval, &len) != 0) else if (getsockopt(fd, SOL_SOCKET, SO_LINGER, &lingval, &len) != 0)
{ {
SetLastError((errno == EBADF) ? WSAENOTSOCK : wsaErrno()); SetLastError(wsaErrno());
ret = SOCKET_ERROR; ret = SOCKET_ERROR;
} }
else else
...@@ -3643,7 +3640,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level, ...@@ -3643,7 +3640,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
convert_sockopt(&level, &optname); convert_sockopt(&level, &optname);
if (getsockopt(fd, level, optname, &tv, &len) != 0 ) if (getsockopt(fd, level, optname, &tv, &len) != 0 )
{ {
SetLastError((errno == EBADF) ? WSAENOTSOCK : wsaErrno()); SetLastError(wsaErrno());
ret = SOCKET_ERROR; ret = SOCKET_ERROR;
} }
else else
...@@ -3668,7 +3665,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level, ...@@ -3668,7 +3665,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
if (getsockopt(fd, SOL_SOCKET, SO_TYPE, optval, (socklen_t *)optlen) != 0 ) if (getsockopt(fd, SOL_SOCKET, SO_TYPE, optval, (socklen_t *)optlen) != 0 )
{ {
SetLastError((errno == EBADF) ? WSAENOTSOCK : wsaErrno()); SetLastError(wsaErrno());
ret = SOCKET_ERROR; ret = SOCKET_ERROR;
} }
else else
...@@ -3829,7 +3826,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level, ...@@ -3829,7 +3826,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
convert_sockopt(&level, &optname); convert_sockopt(&level, &optname);
if (getsockopt(fd, level, optname, optval, (socklen_t *)optlen) != 0 ) if (getsockopt(fd, level, optname, optval, (socklen_t *)optlen) != 0 )
{ {
SetLastError((errno == EBADF) ? WSAENOTSOCK : wsaErrno()); SetLastError(wsaErrno());
ret = SOCKET_ERROR; ret = SOCKET_ERROR;
} }
release_sock_fd( s, fd ); release_sock_fd( s, fd );
...@@ -3863,7 +3860,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level, ...@@ -3863,7 +3860,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
convert_sockopt(&level, &optname); convert_sockopt(&level, &optname);
if (getsockopt(fd, level, optname, optval, (socklen_t *)optlen) != 0 ) if (getsockopt(fd, level, optname, optval, (socklen_t *)optlen) != 0 )
{ {
SetLastError((errno == EBADF) ? WSAENOTSOCK : wsaErrno()); SetLastError(wsaErrno());
ret = SOCKET_ERROR; ret = SOCKET_ERROR;
} }
release_sock_fd( s, fd ); release_sock_fd( s, fd );
...@@ -3898,7 +3895,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level, ...@@ -3898,7 +3895,7 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
convert_sockopt(&level, &optname); convert_sockopt(&level, &optname);
if (getsockopt(fd, level, optname, optval, (socklen_t *)optlen) != 0 ) if (getsockopt(fd, level, optname, optval, (socklen_t *)optlen) != 0 )
{ {
SetLastError((errno == EBADF) ? WSAENOTSOCK : wsaErrno()); SetLastError(wsaErrno());
ret = SOCKET_ERROR; ret = SOCKET_ERROR;
} }
release_sock_fd( s, fd ); release_sock_fd( s, fd );
...@@ -4164,7 +4161,7 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID ...@@ -4164,7 +4161,7 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
} }
if ((fd = get_sock_fd( s, 0, NULL )) == -1) return SOCKET_ERROR; if ((fd = get_sock_fd( s, 0, NULL )) == -1) return SOCKET_ERROR;
if (ioctl(fd, FIONREAD, out_buff ) == -1) if (ioctl(fd, FIONREAD, out_buff ) == -1)
status = (errno == EBADF) ? WSAENOTSOCK : wsaErrno(); status = wsaErrno();
release_sock_fd( s, fd ); release_sock_fd( s, fd );
break; break;
} }
...@@ -4182,7 +4179,7 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID ...@@ -4182,7 +4179,7 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID
/* SO_OOBINLINE sockets must always return TRUE to SIOCATMARK */ /* SO_OOBINLINE sockets must always return TRUE to SIOCATMARK */
if ((getsockopt(fd, SOL_SOCKET, SO_OOBINLINE, &oob, &oobsize ) == -1) if ((getsockopt(fd, SOL_SOCKET, SO_OOBINLINE, &oob, &oobsize ) == -1)
|| (!oob && ioctl(fd, SIOCATMARK, &atmark ) == -1)) || (!oob && ioctl(fd, SIOCATMARK, &atmark ) == -1))
status = (errno == EBADF) ? WSAENOTSOCK : wsaErrno(); status = wsaErrno();
else else
{ {
/* The SIOCATMARK value read from ioctl() is reversed /* The SIOCATMARK value read from ioctl() is reversed
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment