From 1afc2c72d6b55f09ccbf88f1c98c114b5a36c8d1 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 6 Apr 2019 01:36:50 -0400 Subject: [PATCH] kernel/server_port: Return a std::pair from CreatePortPair() Returns the same type that the function name describes. --- src/core/hle/kernel/kernel.h | 5 +++-- src/core/hle/kernel/server_port.cpp | 6 ++---- src/core/hle/kernel/svc.cpp | 8 +++----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 9c32d90602..752c22d555 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -83,6 +83,8 @@ public: std::function prepare_reschedule_callback, u32 system_mode); ~KernelSystem(); + using PortPair = std::tuple, std::shared_ptr>; + /** * Creates an address arbiter. * @@ -150,8 +152,7 @@ public: * @param name Optional name of the ports * @return The created port tuple */ - std::tuple, std::shared_ptr> CreatePortPair( - u32 max_sessions, std::string name = "UnknownPort"); + PortPair CreatePortPair(u32 max_sessions, std::string name = "UnknownPort"); /** * Creates a pair of ServerSession and an associated ClientSession. diff --git a/src/core/hle/kernel/server_port.cpp b/src/core/hle/kernel/server_port.cpp index f4b54451c9..0e08b79e8a 100644 --- a/src/core/hle/kernel/server_port.cpp +++ b/src/core/hle/kernel/server_port.cpp @@ -35,9 +35,7 @@ void ServerPort::Acquire(Thread* thread) { ASSERT_MSG(!ShouldWait(thread), "object unavailable!"); } -std::tuple, std::shared_ptr> KernelSystem::CreatePortPair( - u32 max_sessions, std::string name) { - +KernelSystem::PortPair KernelSystem::CreatePortPair(u32 max_sessions, std::string name) { auto server_port{std::make_shared(*this)}; auto client_port{std::make_shared(*this)}; @@ -47,7 +45,7 @@ std::tuple, std::shared_ptr> KernelSyste client_port->max_sessions = max_sessions; client_port->active_sessions = 0; - return std::make_tuple(std::move(server_port), std::move(client_port)); + return std::make_pair(std::move(server_port), std::move(client_port)); } } // namespace Kernel diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index e8c8c32ec6..ea4d364c08 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -1292,13 +1292,11 @@ ResultCode SVC::CreatePort(Handle* server_port, Handle* client_port, VAddr name_ std::shared_ptr current_process = kernel.GetCurrentProcess(); - auto ports = kernel.CreatePortPair(max_sessions); - CASCADE_RESULT(*client_port, current_process->handle_table.Create( - std::move(std::get>(ports)))); + auto [server, client] = kernel.CreatePortPair(max_sessions); + CASCADE_RESULT(*client_port, current_process->handle_table.Create(std::move(client))); // Note: The 3DS kernel also leaks the client port handle if the server port handle fails to be // created. - CASCADE_RESULT(*server_port, current_process->handle_table.Create( - std::move(std::get>(ports)))); + CASCADE_RESULT(*server_port, current_process->handle_table.Create(std::move(server))); LOG_TRACE(Kernel_SVC, "called max_sessions={}", max_sessions); return RESULT_SUCCESS;