From 9652973db2c4e60e38afb19e66efc6e30e266600 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 7 Sep 2020 00:45:53 -0400 Subject: blocking_worker: Resolve -Wdocumentation warning --- src/core/hle/service/sockets/blocking_worker.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/hle/service/sockets/blocking_worker.h b/src/core/hle/service/sockets/blocking_worker.h index 31ef6b821..f2be6ce5c 100644 --- a/src/core/hle/service/sockets/blocking_worker.h +++ b/src/core/hle/service/sockets/blocking_worker.h @@ -29,7 +29,7 @@ namespace Service::Sockets { * Worker abstraction to execute blocking calls on host without blocking the guest thread * * @tparam Service Service where the work is executed - * @tparam ...Types Types of work to execute + * @tparam Types Types of work to execute */ template class BlockingWorker { -- cgit v1.2.3 From 188a3cf74cba3ad8a19157614d556c134b5ebf47 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 7 Sep 2020 00:47:43 -0400 Subject: blocking_worker: Make use of templated lambda We can simplify this a little by explicitly specifying the typename for the lambda function. --- src/core/hle/service/sockets/blocking_worker.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/hle/service/sockets/blocking_worker.h b/src/core/hle/service/sockets/blocking_worker.h index f2be6ce5c..2d53e52b6 100644 --- a/src/core/hle/service/sockets/blocking_worker.h +++ b/src/core/hle/service/sockets/blocking_worker.h @@ -109,9 +109,8 @@ private: while (keep_running) { work_event.Wait(); - const auto visit_fn = [service, &keep_running](auto&& w) { - using T = std::decay_t; - if constexpr (std::is_same_v) { + const auto visit_fn = [service, &keep_running](T&& w) { + if constexpr (std::is_same_v, std::monostate>) { keep_running = false; } else { w.Execute(service); -- cgit v1.2.3 From 180fa6859fcb0a4e1ef1b24d6bcbf051b6c0b286 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 7 Sep 2020 00:53:08 -0400 Subject: sockets_translate: Make use of designated initializers Same behavior, less typing. --- src/core/hle/service/sockets/sockets_translate.cpp | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/core') diff --git a/src/core/hle/service/sockets/sockets_translate.cpp b/src/core/hle/service/sockets/sockets_translate.cpp index 2be8f642d..139743e1d 100644 --- a/src/core/hle/service/sockets/sockets_translate.cpp +++ b/src/core/hle/service/sockets/sockets_translate.cpp @@ -131,21 +131,21 @@ u16 TranslatePollEventsToGuest(u16 flags) { Network::SockAddrIn Translate(SockAddrIn value) { ASSERT(value.len == 0 || value.len == sizeof(value)); - Network::SockAddrIn result; - result.family = Translate(static_cast(value.family)); - result.ip = value.ip; - result.portno = value.portno >> 8 | value.portno << 8; - return result; + return { + .family = Translate(static_cast(value.family)), + .ip = value.ip, + .portno = static_cast(value.portno >> 8 | value.portno << 8), + }; } SockAddrIn Translate(Network::SockAddrIn value) { - SockAddrIn result; - result.len = sizeof(result); - result.family = static_cast(Translate(value.family)); - result.portno = value.portno >> 8 | value.portno << 8; - result.ip = value.ip; - result.zeroes = {}; - return result; + return { + .len = sizeof(SockAddrIn), + .family = static_cast(Translate(value.family)), + .portno = static_cast(value.portno >> 8 | value.portno << 8), + .ip = value.ip, + .zeroes = {}, + }; } Network::ShutdownHow Translate(ShutdownHow how) { -- cgit v1.2.3 From cd643ab5c9f090f708c04f3b1db3c011e68415f8 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 7 Sep 2020 00:57:39 -0400 Subject: bsd: Resolve sign comparison warnings --- src/core/hle/service/sockets/bsd.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp index 803505452..de6b150f7 100644 --- a/src/core/hle/service/sockets/bsd.cpp +++ b/src/core/hle/service/sockets/bsd.cpp @@ -491,7 +491,7 @@ std::pair BSD::PollImpl(std::vector& write_buffer, std::vector MAX_FD || pollfd.fd < 0) { + if (pollfd.fd > static_cast(MAX_FD) || pollfd.fd < 0) { LOG_ERROR(Service, "File descriptor handle={} is invalid", pollfd.fd); pollfd.revents = 0; return {0, Errno::SUCCESS}; @@ -795,7 +795,7 @@ s32 BSD::FindFreeFileDescriptorHandle() noexcept { } bool BSD::IsFileDescriptorValid(s32 fd) const noexcept { - if (fd > MAX_FD || fd < 0) { + if (fd > static_cast(MAX_FD) || fd < 0) { LOG_ERROR(Service, "Invalid file descriptor handle={}", fd); return false; } @@ -809,7 +809,7 @@ bool BSD::IsFileDescriptorValid(s32 fd) const noexcept { bool BSD::IsBlockingSocket(s32 fd) const noexcept { // Inform invalid sockets as non-blocking // This way we avoid using a worker thread as it will fail without blocking host - if (fd > MAX_FD || fd < 0) { + if (fd > static_cast(MAX_FD) || fd < 0) { return false; } if (!file_descriptors[fd]) { -- cgit v1.2.3 From 40968e39937e3af3da399f66e7024f754ba1236b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 7 Sep 2020 01:04:36 -0400 Subject: bsd: Resolve unused value within SendToImpl Previously the address provided to SendToImpl would never be propagated to SendTo(). This fixes that. --- src/core/hle/service/sockets/bsd.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core') diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp index de6b150f7..7b9dd42d8 100644 --- a/src/core/hle/service/sockets/bsd.cpp +++ b/src/core/hle/service/sockets/bsd.cpp @@ -764,6 +764,7 @@ std::pair BSD::SendToImpl(s32 fd, u32 flags, const std::vector& SockAddrIn guest_addr_in; std::memcpy(&guest_addr_in, addr.data(), sizeof(guest_addr_in)); addr_in = Translate(guest_addr_in); + p_addr_in = &addr_in; } return Translate(file_descriptors[fd]->socket->SendTo(flags, message, p_addr_in)); -- cgit v1.2.3