Commit 85230942 authored by Alexandre Julliard's avatar Alexandre Julliard

ws2_32: Avoid retrieving the fd twice in WSAIoctl.

parent 971d5f3f
......@@ -2113,11 +2113,6 @@ INT WINAPI WSAIoctl(SOCKET s,
LPWSAOVERLAPPED lpOverlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
{
int fd = get_sock_fd( s, 0, NULL );
INT ret;
if (fd == -1) return SOCKET_ERROR;
TRACE("%d, 0x%08lx, %p, %ld, %p, %ld, %p, %p, %p\n",
s, dwIoControlCode, lpvInBuffer, cbInBuffer, lpbOutBuffer,
cbOutBuffer, lpcbBytesReturned, lpOverlapped, lpCompletionRoutine);
......@@ -2126,50 +2121,40 @@ INT WINAPI WSAIoctl(SOCKET s,
{
case WS_FIONBIO:
if (cbInBuffer != sizeof(u_long)) {
release_sock_fd( s, fd );
WSASetLastError(WSAEFAULT);
return SOCKET_ERROR;
}
ret = WS_ioctlsocket( s, WS_FIONBIO, lpvInBuffer);
if (ret == SOCKET_ERROR) {
release_sock_fd( s, fd );
/* last error already set by WS_ioctlsocket */
return ret;
}
break;
return WS_ioctlsocket( s, WS_FIONBIO, lpvInBuffer);
case WS_FIONREAD:
if (cbOutBuffer != sizeof(u_long)) {
release_sock_fd( s, fd );
WSASetLastError(WSAEFAULT);
return SOCKET_ERROR;
}
ret = WS_ioctlsocket( s, WS_FIONREAD, lpbOutBuffer);
if (ret == SOCKET_ERROR) {
release_sock_fd( s, fd );
/* last error already set by WS_ioctlsocket */
return ret;
}
break;
return WS_ioctlsocket( s, WS_FIONREAD, lpbOutBuffer);
case SIO_GET_INTERFACE_LIST:
{
INTERFACE_INFO* intArray = (INTERFACE_INFO*)lpbOutBuffer;
DWORD size, numInt, apiReturn;
int fd;
TRACE("-> SIO_GET_INTERFACE_LIST request\n");
if (!lpbOutBuffer)
{
release_sock_fd( s, fd );
WSASetLastError(WSAEFAULT);
return SOCKET_ERROR;
}
if (!lpcbBytesReturned)
{
release_sock_fd( s, fd );
WSASetLastError(WSAEFAULT);
return SOCKET_ERROR;
}
fd = get_sock_fd( s, 0, NULL );
if (fd == -1) return SOCKET_ERROR;
apiReturn = GetAdaptersInfo(NULL, &size);
if (apiReturn == ERROR_NO_DATA)
{
......@@ -2273,6 +2258,7 @@ INT WINAPI WSAIoctl(SOCKET s,
}
/* Calculate the size of the array being returned */
*lpcbBytesReturned = sizeof(INTERFACE_INFO) * numInt;
release_sock_fd( s, fd );
break;
}
......@@ -2288,13 +2274,10 @@ INT WINAPI WSAIoctl(SOCKET s,
default:
FIXME("unsupported WS_IOCTL cmd (%08lx)\n", dwIoControlCode);
release_sock_fd( s, fd );
WSASetLastError(WSAEOPNOTSUPP);
return SOCKET_ERROR;
}
/* Function executed with no errors */
release_sock_fd( s, fd );
return 0;
}
......
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