LibCore/LibIPC/Meta: Stop using deprecated Winsock functions
This commit stops using deprecated WSA functions. While the ANSI versions are most likely not going anywhere, Windows is natively UTF-16 so it has to convert to ANSI internally. All the ANSI functions in Winsock are marked as deprecated. The macro suppressing the warnings is no longer defined.
This commit is contained in:
parent
473391fd26
commit
3a86e779bd
6 changed files with 10 additions and 12 deletions
|
|
@ -76,7 +76,7 @@ int windows_socketpair(SOCKET socks[2], int make_overlapped)
|
|||
if (::listen(listener, 1) == SOCKET_ERROR)
|
||||
break;
|
||||
|
||||
socks[0] = WSASocket(AF_INET, SOCK_STREAM, 0, NULL, 0, flags);
|
||||
socks[0] = WSASocketW(AF_INET, SOCK_STREAM, 0, NULL, 0, flags);
|
||||
if (socks[0] == INVALID_SOCKET)
|
||||
break;
|
||||
if (connect(socks[0], &a.addr, sizeof(a.inaddr)) == SOCKET_ERROR)
|
||||
|
|
|
|||
|
|
@ -213,10 +213,10 @@ ErrorOr<int> dup(int handle)
|
|||
return Error::from_windows_error(ERROR_INVALID_HANDLE);
|
||||
}
|
||||
if (is_socket(handle)) {
|
||||
WSAPROTOCOL_INFO pi = {};
|
||||
if (WSADuplicateSocket(handle, GetCurrentProcessId(), &pi))
|
||||
WSAPROTOCOL_INFOW pi = {};
|
||||
if (WSADuplicateSocketW(handle, GetCurrentProcessId(), &pi))
|
||||
return Error::from_windows_error();
|
||||
SOCKET socket = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, &pi, 0, WSA_FLAG_OVERLAPPED | WSA_FLAG_NO_HANDLE_INHERIT);
|
||||
SOCKET socket = WSASocketW(AF_INET, SOCK_STREAM, IPPROTO_TCP, &pi, 0, WSA_FLAG_OVERLAPPED | WSA_FLAG_NO_HANDLE_INHERIT);
|
||||
if (socket == INVALID_SOCKET)
|
||||
return Error::from_windows_error();
|
||||
return socket;
|
||||
|
|
|
|||
|
|
@ -69,9 +69,9 @@ ErrorOr<File> decode(Decoder& decoder)
|
|||
if (handle_type == HandleType::Generic) {
|
||||
TRY(decoder.decode_into(handle));
|
||||
} else if (handle_type == HandleType::Socket) {
|
||||
WSAPROTOCOL_INFO pi = {};
|
||||
WSAPROTOCOL_INFOW pi = {};
|
||||
TRY(decoder.decode_into({ reinterpret_cast<u8*>(&pi), sizeof(pi) }));
|
||||
handle = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, &pi, 0, WSA_FLAG_OVERLAPPED | WSA_FLAG_NO_HANDLE_INHERIT);
|
||||
handle = WSASocketW(AF_INET, SOCK_STREAM, IPPROTO_TCP, &pi, 0, WSA_FLAG_OVERLAPPED | WSA_FLAG_NO_HANDLE_INHERIT);
|
||||
if (handle == -1)
|
||||
return Error::from_windows_error();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ ErrorOr<void> MessageBuffer::append_file_descriptor(int handle)
|
|||
|
||||
// The handle will be duplicated and WSAPROTOCOL_INFO will be filled later in TransportSocketWindows::transfer.
|
||||
// It can't be duplicated here because it requires peer process pid, which only TransportSocketWindows knows about.
|
||||
WSAPROTOCOL_INFO pi = {};
|
||||
WSAPROTOCOL_INFOW pi = {};
|
||||
static_assert(sizeof(pi) >= sizeof(int));
|
||||
ByteReader::store(reinterpret_cast<u8*>(&pi), handle);
|
||||
TRY(m_data.try_append(reinterpret_cast<u8*>(&pi), sizeof(pi)));
|
||||
|
|
|
|||
|
|
@ -80,15 +80,15 @@ ErrorOr<void> TransportSocketWindows::duplicate_handles(Bytes bytes, Vector<size
|
|||
span = span.slice(sizeof(HandleType));
|
||||
|
||||
if (type == HandleType::Socket) {
|
||||
if (span.size() < sizeof(WSAPROTOCOL_INFO))
|
||||
if (span.size() < sizeof(WSAPROTOCOL_INFOW))
|
||||
return Error::from_string_literal("Not enough bytes for socket handle");
|
||||
|
||||
// We stashed the bytes of this process's version of the handle at the offset location
|
||||
int handle = -1;
|
||||
ByteReader::load(span.data(), handle);
|
||||
|
||||
auto* pi = reinterpret_cast<WSAPROTOCOL_INFO*>(span.data());
|
||||
if (WSADuplicateSocket(handle, m_peer_pid, pi))
|
||||
auto* pi = reinterpret_cast<WSAPROTOCOL_INFOW*>(span.data());
|
||||
if (WSADuplicateSocketW(handle, m_peer_pid, pi))
|
||||
return Error::from_windows_error();
|
||||
} else {
|
||||
if (span.size() < sizeof(int))
|
||||
|
|
|
|||
|
|
@ -151,8 +151,6 @@ elseif (MSVC)
|
|||
add_cxx_compile_options(-Wno-unqualified-std-cast-call)
|
||||
add_cxx_compile_options(-Wno-c23-extensions)
|
||||
add_cxx_compile_options(-Wno-microsoft-unqualified-friend) # MSVC doesn't support unqualified friends
|
||||
# FIXME: Stop using deprecated winsock functions
|
||||
add_cxx_compile_definitions(_WINSOCK_DEPRECATED_NO_WARNINGS)
|
||||
add_cxx_compile_definitions(_CRT_SECURE_NO_WARNINGS) # _s replacements not desired (or implemented on any other platform other than VxWorks)
|
||||
add_cxx_compile_definitions(_CRT_NONSTDC_NO_WARNINGS) # POSIX names are just fine, thanks
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue