diff options
author | Lioncash <mathew1800@gmail.com> | 2020-10-13 14:10:50 +0200 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2020-10-13 19:16:49 +0200 |
commit | 39c8d18feba8eafcd43fbb55e73ae150a1947aad (patch) | |
tree | 9565ff464bbb9e5a0aa66e6e310098314e88d019 /src/core/network | |
parent | Merge pull request #3929 from FearlessTobi/ticket-keys (diff) | |
download | yuzu-39c8d18feba8eafcd43fbb55e73ae150a1947aad.tar yuzu-39c8d18feba8eafcd43fbb55e73ae150a1947aad.tar.gz yuzu-39c8d18feba8eafcd43fbb55e73ae150a1947aad.tar.bz2 yuzu-39c8d18feba8eafcd43fbb55e73ae150a1947aad.tar.lz yuzu-39c8d18feba8eafcd43fbb55e73ae150a1947aad.tar.xz yuzu-39c8d18feba8eafcd43fbb55e73ae150a1947aad.tar.zst yuzu-39c8d18feba8eafcd43fbb55e73ae150a1947aad.zip |
Diffstat (limited to 'src/core/network')
-rw-r--r-- | src/core/network/network.cpp | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/core/network/network.cpp b/src/core/network/network.cpp index 56d173b5e..4b3bb4366 100644 --- a/src/core/network/network.cpp +++ b/src/core/network/network.cpp @@ -238,14 +238,14 @@ SockAddrIn TranslateToSockAddrIn(sockaddr input_) { return result; } -u16 TranslatePollEvents(u16 events) { - u16 result = 0; +u16 TranslatePollEvents(u32 events) { + u32 result = 0; - if (events & POLL_IN) { + if ((events & POLL_IN) != 0) { events &= ~POLL_IN; result |= POLLIN; } - if (events & POLL_PRI) { + if ((events & POLL_PRI) != 0) { events &= ~POLL_PRI; #ifdef _WIN32 LOG_WARNING(Service, "Winsock doesn't support POLLPRI"); @@ -253,20 +253,20 @@ u16 TranslatePollEvents(u16 events) { result |= POLL_PRI; #endif } - if (events & POLL_OUT) { + if ((events & POLL_OUT) != 0) { events &= ~POLL_OUT; result |= POLLOUT; } UNIMPLEMENTED_IF_MSG(events != 0, "Unhandled guest events=0x{:x}", events); - return result; + return static_cast<u16>(result); } -u16 TranslatePollRevents(u16 revents) { - u16 result = 0; - const auto translate = [&result, &revents](int host, unsigned guest) { - if (revents & host) { +u16 TranslatePollRevents(u32 revents) { + u32 result = 0; + const auto translate = [&result, &revents](u32 host, u32 guest) { + if ((revents & host) != 0) { revents &= ~host; result |= guest; } @@ -280,7 +280,7 @@ u16 TranslatePollRevents(u16 revents) { UNIMPLEMENTED_IF_MSG(revents != 0, "Unhandled host revents=0x{:x}", revents); - return result; + return static_cast<u16>(result); } template <typename T> @@ -350,7 +350,7 @@ std::pair<s32, Errno> Poll(std::vector<PollFD>& pollfds, s32 timeout) { } for (size_t i = 0; i < num; ++i) { - pollfds[i].revents = TranslatePollRevents(host_pollfds[i].revents); + pollfds[i].revents = TranslatePollRevents(static_cast<u32>(host_pollfds[i].revents)); } if (result > 0) { @@ -408,7 +408,7 @@ std::pair<Socket::AcceptResult, Errno> Socket::Accept() { Errno Socket::Connect(SockAddrIn addr_in) { const sockaddr host_addr_in = TranslateFromSockAddrIn(addr_in); - if (connect(fd, &host_addr_in, sizeof(host_addr_in)) != INVALID_SOCKET) { + if (connect(fd, &host_addr_in, sizeof(host_addr_in)) != SOCKET_ERROR) { return Errno::SUCCESS; } @@ -503,10 +503,10 @@ std::pair<s32, Errno> Socket::Recv(int flags, std::vector<u8>& message) { ASSERT(flags == 0); ASSERT(message.size() < static_cast<size_t>(std::numeric_limits<int>::max())); - const int result = + const auto result = recv(fd, reinterpret_cast<char*>(message.data()), static_cast<int>(message.size()), 0); if (result != SOCKET_ERROR) { - return {result, Errno::SUCCESS}; + return {static_cast<s32>(result), Errno::SUCCESS}; } switch (const int ec = LastError()) { @@ -531,14 +531,14 @@ std::pair<s32, Errno> Socket::RecvFrom(int flags, std::vector<u8>& message, Sock socklen_t* const p_addrlen = addr ? &addrlen : nullptr; sockaddr* const p_addr_in = addr ? &addr_in : nullptr; - const int result = recvfrom(fd, reinterpret_cast<char*>(message.data()), - static_cast<int>(message.size()), 0, p_addr_in, p_addrlen); + const auto result = recvfrom(fd, reinterpret_cast<char*>(message.data()), + static_cast<int>(message.size()), 0, p_addr_in, p_addrlen); if (result != SOCKET_ERROR) { if (addr) { ASSERT(addrlen == sizeof(addr_in)); *addr = TranslateToSockAddrIn(addr_in); } - return {result, Errno::SUCCESS}; + return {static_cast<s32>(result), Errno::SUCCESS}; } switch (const int ec = LastError()) { @@ -558,10 +558,10 @@ std::pair<s32, Errno> Socket::Send(const std::vector<u8>& message, int flags) { ASSERT(message.size() < static_cast<size_t>(std::numeric_limits<int>::max())); ASSERT(flags == 0); - const int result = send(fd, reinterpret_cast<const char*>(message.data()), - static_cast<int>(message.size()), 0); + const auto result = send(fd, reinterpret_cast<const char*>(message.data()), + static_cast<int>(message.size()), 0); if (result != SOCKET_ERROR) { - return {result, Errno::SUCCESS}; + return {static_cast<s32>(result), Errno::SUCCESS}; } const int ec = LastError(); @@ -591,10 +591,10 @@ std::pair<s32, Errno> Socket::SendTo(u32 flags, const std::vector<u8>& message, to = &host_addr_in; } - const int result = sendto(fd, reinterpret_cast<const char*>(message.data()), - static_cast<int>(message.size()), 0, to, tolen); + const auto result = sendto(fd, reinterpret_cast<const char*>(message.data()), + static_cast<int>(message.size()), 0, to, tolen); if (result != SOCKET_ERROR) { - return {result, Errno::SUCCESS}; + return {static_cast<s32>(result), Errno::SUCCESS}; } const int ec = LastError(); |