Merge pull request #4634 from lioncash/blocking
bsd: Resolve a few warnings
This commit is contained in:
commit
ec634b6a88
|
@ -29,7 +29,7 @@ namespace Service::Sockets {
|
||||||
* Worker abstraction to execute blocking calls on host without blocking the guest thread
|
* Worker abstraction to execute blocking calls on host without blocking the guest thread
|
||||||
*
|
*
|
||||||
* @tparam Service Service where the work is executed
|
* @tparam Service Service where the work is executed
|
||||||
* @tparam ...Types Types of work to execute
|
* @tparam Types Types of work to execute
|
||||||
*/
|
*/
|
||||||
template <class Service, class... Types>
|
template <class Service, class... Types>
|
||||||
class BlockingWorker {
|
class BlockingWorker {
|
||||||
|
@ -109,9 +109,8 @@ private:
|
||||||
while (keep_running) {
|
while (keep_running) {
|
||||||
work_event.Wait();
|
work_event.Wait();
|
||||||
|
|
||||||
const auto visit_fn = [service, &keep_running](auto&& w) {
|
const auto visit_fn = [service, &keep_running]<typename T>(T&& w) {
|
||||||
using T = std::decay_t<decltype(w)>;
|
if constexpr (std::is_same_v<std::decay_t<T>, std::monostate>) {
|
||||||
if constexpr (std::is_same_v<T, std::monostate>) {
|
|
||||||
keep_running = false;
|
keep_running = false;
|
||||||
} else {
|
} else {
|
||||||
w.Execute(service);
|
w.Execute(service);
|
||||||
|
|
|
@ -491,7 +491,7 @@ std::pair<s32, Errno> BSD::PollImpl(std::vector<u8>& write_buffer, std::vector<u
|
||||||
for (PollFD& pollfd : fds) {
|
for (PollFD& pollfd : fds) {
|
||||||
ASSERT(pollfd.revents == 0);
|
ASSERT(pollfd.revents == 0);
|
||||||
|
|
||||||
if (pollfd.fd > MAX_FD || pollfd.fd < 0) {
|
if (pollfd.fd > static_cast<s32>(MAX_FD) || pollfd.fd < 0) {
|
||||||
LOG_ERROR(Service, "File descriptor handle={} is invalid", pollfd.fd);
|
LOG_ERROR(Service, "File descriptor handle={} is invalid", pollfd.fd);
|
||||||
pollfd.revents = 0;
|
pollfd.revents = 0;
|
||||||
return {0, Errno::SUCCESS};
|
return {0, Errno::SUCCESS};
|
||||||
|
@ -764,6 +764,7 @@ std::pair<s32, Errno> BSD::SendToImpl(s32 fd, u32 flags, const std::vector<u8>&
|
||||||
SockAddrIn guest_addr_in;
|
SockAddrIn guest_addr_in;
|
||||||
std::memcpy(&guest_addr_in, addr.data(), sizeof(guest_addr_in));
|
std::memcpy(&guest_addr_in, addr.data(), sizeof(guest_addr_in));
|
||||||
addr_in = Translate(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));
|
return Translate(file_descriptors[fd]->socket->SendTo(flags, message, p_addr_in));
|
||||||
|
@ -795,7 +796,7 @@ s32 BSD::FindFreeFileDescriptorHandle() noexcept {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BSD::IsFileDescriptorValid(s32 fd) const noexcept {
|
bool BSD::IsFileDescriptorValid(s32 fd) const noexcept {
|
||||||
if (fd > MAX_FD || fd < 0) {
|
if (fd > static_cast<s32>(MAX_FD) || fd < 0) {
|
||||||
LOG_ERROR(Service, "Invalid file descriptor handle={}", fd);
|
LOG_ERROR(Service, "Invalid file descriptor handle={}", fd);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -809,7 +810,7 @@ bool BSD::IsFileDescriptorValid(s32 fd) const noexcept {
|
||||||
bool BSD::IsBlockingSocket(s32 fd) const noexcept {
|
bool BSD::IsBlockingSocket(s32 fd) const noexcept {
|
||||||
// Inform invalid sockets as non-blocking
|
// Inform invalid sockets as non-blocking
|
||||||
// This way we avoid using a worker thread as it will fail without blocking host
|
// 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<s32>(MAX_FD) || fd < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!file_descriptors[fd]) {
|
if (!file_descriptors[fd]) {
|
||||||
|
|
|
@ -131,21 +131,21 @@ u16 TranslatePollEventsToGuest(u16 flags) {
|
||||||
Network::SockAddrIn Translate(SockAddrIn value) {
|
Network::SockAddrIn Translate(SockAddrIn value) {
|
||||||
ASSERT(value.len == 0 || value.len == sizeof(value));
|
ASSERT(value.len == 0 || value.len == sizeof(value));
|
||||||
|
|
||||||
Network::SockAddrIn result;
|
return {
|
||||||
result.family = Translate(static_cast<Domain>(value.family));
|
.family = Translate(static_cast<Domain>(value.family)),
|
||||||
result.ip = value.ip;
|
.ip = value.ip,
|
||||||
result.portno = value.portno >> 8 | value.portno << 8;
|
.portno = static_cast<u16>(value.portno >> 8 | value.portno << 8),
|
||||||
return result;
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
SockAddrIn Translate(Network::SockAddrIn value) {
|
SockAddrIn Translate(Network::SockAddrIn value) {
|
||||||
SockAddrIn result;
|
return {
|
||||||
result.len = sizeof(result);
|
.len = sizeof(SockAddrIn),
|
||||||
result.family = static_cast<u8>(Translate(value.family));
|
.family = static_cast<u8>(Translate(value.family)),
|
||||||
result.portno = value.portno >> 8 | value.portno << 8;
|
.portno = static_cast<u16>(value.portno >> 8 | value.portno << 8),
|
||||||
result.ip = value.ip;
|
.ip = value.ip,
|
||||||
result.zeroes = {};
|
.zeroes = {},
|
||||||
return result;
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Network::ShutdownHow Translate(ShutdownHow how) {
|
Network::ShutdownHow Translate(ShutdownHow how) {
|
||||||
|
|
Reference in New Issue