summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/announce_multiplayer_session.cpp6
-rw-r--r--src/core/hle/service/nifm/nifm.cpp1
-rw-r--r--src/core/internal_network/network.cpp8
-rw-r--r--src/core/internal_network/socket_proxy.cpp10
-rw-r--r--src/core/internal_network/socket_proxy.h3
-rw-r--r--src/core/internal_network/sockets.h6
6 files changed, 16 insertions, 18 deletions
diff --git a/src/core/announce_multiplayer_session.cpp b/src/core/announce_multiplayer_session.cpp
index d73a488cf..6737ce85a 100644
--- a/src/core/announce_multiplayer_session.cpp
+++ b/src/core/announce_multiplayer_session.cpp
@@ -31,7 +31,7 @@ AnnounceMultiplayerSession::AnnounceMultiplayerSession(Network::RoomNetwork& roo
}
WebService::WebResult AnnounceMultiplayerSession::Register() {
- std::shared_ptr<Network::Room> room = room_network.GetRoom().lock();
+ auto room = room_network.GetRoom().lock();
if (!room) {
return WebService::WebResult{WebService::WebResult::Code::LibError,
"Network is not initialized", ""};
@@ -102,7 +102,7 @@ void AnnounceMultiplayerSession::UpdateBackendData(std::shared_ptr<Network::Room
void AnnounceMultiplayerSession::AnnounceMultiplayerLoop() {
// Invokes all current bound error callbacks.
const auto ErrorCallback = [this](WebService::WebResult result) {
- std::lock_guard<std::mutex> lock(callback_mutex);
+ std::lock_guard lock(callback_mutex);
for (auto callback : error_callbacks) {
(*callback)(result);
}
@@ -120,7 +120,7 @@ void AnnounceMultiplayerSession::AnnounceMultiplayerLoop() {
std::future<WebService::WebResult> future;
while (!shutdown_event.WaitUntil(update_time)) {
update_time += announce_time_interval;
- std::shared_ptr<Network::Room> room = room_network.GetRoom().lock();
+ auto room = room_network.GetRoom().lock();
if (!room) {
break;
}
diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp
index 42ed17187..e3ef06481 100644
--- a/src/core/hle/service/nifm/nifm.cpp
+++ b/src/core/hle/service/nifm/nifm.cpp
@@ -381,6 +381,7 @@ void IGeneralService::GetCurrentIpAddress(Kernel::HLERequestContext& ctx) {
rb.Push(ResultSuccess);
rb.PushRaw(*ipv4);
}
+
void IGeneralService::CreateTemporaryNetworkProfile(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_NIFM, "called");
diff --git a/src/core/internal_network/network.cpp b/src/core/internal_network/network.cpp
index 160cc83e4..3b6906f7d 100644
--- a/src/core/internal_network/network.cpp
+++ b/src/core/internal_network/network.cpp
@@ -352,8 +352,8 @@ std::optional<IPv4Address> GetHostIPv4Address() {
return {};
}
- char ip_addr[16] = {};
- ASSERT(inet_ntop(AF_INET, &interface->ip_address, ip_addr, sizeof(ip_addr)) != nullptr);
+ std::array<char, 16> ip_addr = {};
+ ASSERT(inet_ntop(AF_INET, &interface->ip_address, ip_addr.data(), sizeof(ip_addr)) != nullptr);
return TranslateIPv4(interface->ip_address);
}
@@ -402,9 +402,9 @@ Socket::Socket(Socket&& rhs) noexcept {
}
template <typename T>
-Errno Socket::SetSockOpt(SOCKET _fd, int option, T value) {
+Errno Socket::SetSockOpt(SOCKET fd_, int option, T value) {
const int result =
- setsockopt(_fd, SOL_SOCKET, option, reinterpret_cast<const char*>(&value), sizeof(value));
+ setsockopt(fd_, SOL_SOCKET, option, reinterpret_cast<const char*>(&value), sizeof(value));
if (result != SOCKET_ERROR) {
return Errno::SUCCESS;
}
diff --git a/src/core/internal_network/socket_proxy.cpp b/src/core/internal_network/socket_proxy.cpp
index b9c50430e..216893ba1 100644
--- a/src/core/internal_network/socket_proxy.cpp
+++ b/src/core/internal_network/socket_proxy.cpp
@@ -30,19 +30,19 @@ void ProxySocket::HandleProxyPacket(const ProxyPacket& packet) {
closed) {
return;
}
- std::lock_guard<std::mutex> guard(packets_mutex);
+ std::lock_guard guard(packets_mutex);
received_packets.push(packet);
}
template <typename T>
-Errno ProxySocket::SetSockOpt(SOCKET _fd, int option, T value) {
+Errno ProxySocket::SetSockOpt(SOCKET fd_, int option, T value) {
socket_options[option] = reinterpret_cast<const char*>(&value);
return Errno::SUCCESS;
}
Errno ProxySocket::Initialize(Domain domain, Type type, Protocol socket_protocol) {
protocol = socket_protocol;
- socket_options[0x1008] = reinterpret_cast<const char*>(&type);
+ SetSockOpt(fd, SO_TYPE, type);
return Errno::SUCCESS;
}
@@ -101,7 +101,7 @@ std::pair<s32, Errno> ProxySocket::RecvFrom(int flags, std::vector<u8>& message,
ASSERT(message.size() < static_cast<size_t>(std::numeric_limits<int>::max()));
{
- std::lock_guard<std::mutex> guard(packets_mutex);
+ std::lock_guard guard(packets_mutex);
if (received_packets.size() > 0) {
return ReceivePacket(flags, message, addr, message.size());
}
@@ -115,7 +115,7 @@ std::pair<s32, Errno> ProxySocket::RecvFrom(int flags, std::vector<u8>& message,
return {-1, Errno::AGAIN};
}
- std::lock_guard<std::mutex> guard(packets_mutex);
+ std::lock_guard guard(packets_mutex);
if (received_packets.size() > 0) {
return ReceivePacket(flags, message, addr, message.size());
}
diff --git a/src/core/internal_network/socket_proxy.h b/src/core/internal_network/socket_proxy.h
index c9155f1af..ad917cac3 100644
--- a/src/core/internal_network/socket_proxy.h
+++ b/src/core/internal_network/socket_proxy.h
@@ -14,7 +14,7 @@ namespace Network {
class ProxySocket : public SocketBase {
public:
- ProxySocket(RoomNetwork& room_network_) noexcept;
+ explicit ProxySocket(RoomNetwork& room_network_) noexcept;
~ProxySocket() override;
ProxySocket(const ProxySocket&) = delete;
@@ -82,6 +82,7 @@ public:
bool IsOpened() const override;
+private:
bool broadcast = false;
bool closed = false;
u32 send_timeout = 0;
diff --git a/src/core/internal_network/sockets.h b/src/core/internal_network/sockets.h
index 92dc49993..a70429b19 100644
--- a/src/core/internal_network/sockets.h
+++ b/src/core/internal_network/sockets.h
@@ -32,7 +32,7 @@ public:
std::unique_ptr<SocketBase> socket;
SockAddrIn sockaddr_in;
};
- virtual ~SocketBase() {}
+ virtual ~SocketBase() = default;
virtual SocketBase& operator=(const SocketBase&) = delete;
@@ -89,11 +89,7 @@ public:
virtual void HandleProxyPacket(const ProxyPacket& packet) = 0;
-#if defined(_WIN32)
SOCKET fd = INVALID_SOCKET;
-#elif YUZU_UNIX
- int fd = -1;
-#endif
};
class Socket : public SocketBase {