diff --git a/src/core/hle/kernel/client_port.cpp b/src/core/hle/kernel/client_port.cpp index a80e51968..4cbe174ac 100644 --- a/src/core/hle/kernel/client_port.cpp +++ b/src/core/hle/kernel/client_port.cpp @@ -20,7 +20,7 @@ namespace Kernel { ClientPort::ClientPort(KernelSystem& kernel) : Object(kernel), kernel(kernel) {} ClientPort::~ClientPort() = default; -Result ClientPort::Connect(std::shared_ptr& client_session) { +Result ClientPort::Connect(std::shared_ptr* out_client_session) { // Note: Threads do not wait for the server endpoint to call // AcceptSession before returning from this call. @@ -39,7 +39,7 @@ Result ClientPort::Connect(std::shared_ptr& client_session) { // Wake the threads waiting on the ServerPort server_port->WakeupAllWaitingThreads(); - client_session = client; + *out_client_session = client; return ResultSuccess; } diff --git a/src/core/hle/kernel/client_port.h b/src/core/hle/kernel/client_port.h index 9d8e0af65..94381a8b0 100644 --- a/src/core/hle/kernel/client_port.h +++ b/src/core/hle/kernel/client_port.h @@ -46,7 +46,7 @@ public: * waiting on it to awake. * @returns ClientSession The client endpoint of the created Session pair, or error code. */ - Result Connect(std::shared_ptr& client_session); + Result Connect(std::shared_ptr* out_client_session); /** * Signifies that a previously active connection has been closed, diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp index e5bda2b3c..b6510ea4f 100644 --- a/src/core/hle/kernel/handle_table.cpp +++ b/src/core/hle/kernel/handle_table.cpp @@ -50,10 +50,10 @@ Result HandleTable::Create(Handle* out_handle, std::shared_ptr obj) { return ResultSuccess; } -Result HandleTable::Duplicate(Handle* out, Handle handle) { +Result HandleTable::Duplicate(Handle* out_handle, Handle handle) { std::shared_ptr object = GetGeneric(handle); R_UNLESS(object, ResultInvalidHandle); - return Create(out, std::move(object)); + return Create(out_handle, std::move(object)); } Result HandleTable::Close(Handle handle) { diff --git a/src/core/hle/kernel/handle_table.h b/src/core/hle/kernel/handle_table.h index c49da1c09..1dc032082 100644 --- a/src/core/hle/kernel/handle_table.h +++ b/src/core/hle/kernel/handle_table.h @@ -61,7 +61,7 @@ public: * - `ResultInvalidHandle`: an invalid handle was passed in. * - Any errors returned by `Create()`. */ - Result Duplicate(Handle* out, Handle handle); + Result Duplicate(Handle* out_handle, Handle handle); /** * Closes a handle, removing it from the table and decreasing the object's ref-count. diff --git a/src/core/hle/kernel/semaphore.cpp b/src/core/hle/kernel/semaphore.cpp index d131bea6a..b8c2e0514 100644 --- a/src/core/hle/kernel/semaphore.cpp +++ b/src/core/hle/kernel/semaphore.cpp @@ -48,10 +48,10 @@ void Semaphore::Acquire(Thread* thread) { --available_count; } -Result Semaphore::Release(s32* count, s32 release_count) { +Result Semaphore::Release(s32* out_count, s32 release_count) { R_UNLESS(max_count >= release_count + available_count, ResultOutOfRangeKernel); - *count = available_count; + *out_count = available_count; available_count += release_count; WakeupAllWaitingThreads(); diff --git a/src/core/hle/kernel/semaphore.h b/src/core/hle/kernel/semaphore.h index a1a61e83d..1c3a008e1 100644 --- a/src/core/hle/kernel/semaphore.h +++ b/src/core/hle/kernel/semaphore.h @@ -47,7 +47,7 @@ public: * @param release_count The number of slots to release * @return The number of free slots the semaphore had before this call */ - Result Release(s32* count, s32 release_count); + Result Release(s32* out_count, s32 release_count); private: friend class boost::serialization::access; diff --git a/src/core/hle/kernel/server_port.cpp b/src/core/hle/kernel/server_port.cpp index 2c8d971db..f3ac13f7d 100644 --- a/src/core/hle/kernel/server_port.cpp +++ b/src/core/hle/kernel/server_port.cpp @@ -24,10 +24,10 @@ namespace Kernel { ServerPort::ServerPort(KernelSystem& kernel) : WaitObject(kernel) {} ServerPort::~ServerPort() {} -Result ServerPort::Accept(std::shared_ptr& session) { +Result ServerPort::Accept(std::shared_ptr* out_server_session) { R_UNLESS(!pending_sessions.empty(), ResultNoPendingSessions); - session = std::move(pending_sessions.back()); + *out_server_session = std::move(pending_sessions.back()); pending_sessions.pop_back(); return ResultSuccess; } diff --git a/src/core/hle/kernel/server_port.h b/src/core/hle/kernel/server_port.h index 7ad32bfaa..7f1b0c262 100644 --- a/src/core/hle/kernel/server_port.h +++ b/src/core/hle/kernel/server_port.h @@ -41,7 +41,7 @@ public: * Accepts a pending incoming connection on this port. If there are no pending sessions, will * return ResultNoPendingSessions. */ - Result Accept(std::shared_ptr& session); + Result Accept(std::shared_ptr* out_server_session); /** * Sets the HLE handler template for the port. ServerSessions crated by connecting to this port diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index fbe366e7d..78fe5f143 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -590,7 +590,7 @@ Result SVC::ConnectToPort(Handle* out_handle, VAddr port_name_address) { auto client_port = it->second; std::shared_ptr client_session; - R_TRY(client_port->Connect(client_session)); + R_TRY(client_port->Connect(std::addressof(client_session))); // Return the client session return kernel.GetCurrentProcess()->handle_table.Create(out_handle, client_session); @@ -1659,7 +1659,7 @@ Result SVC::CreateSessionToPort(Handle* out_client_session, Handle client_port_h R_UNLESS(client_port, ResultInvalidHandle); std::shared_ptr session; - R_TRY(client_port->Connect(session)); + R_TRY(client_port->Connect(std::addressof(session))); return current_process->handle_table.Create(out_client_session, std::move(session)); } @@ -1681,7 +1681,7 @@ Result SVC::AcceptSession(Handle* out_server_session, Handle server_port_handle) R_UNLESS(server_port, ResultInvalidHandle); std::shared_ptr session; - R_TRY(server_port->Accept(session)); + R_TRY(server_port->Accept(std::addressof(session))); return current_process->handle_table.Create(out_server_session, std::move(session)); } diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index daa3bef4b..118ea32dd 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -131,7 +131,7 @@ ServiceFrameworkBase::~ServiceFrameworkBase() = default; void ServiceFrameworkBase::InstallAsService(SM::ServiceManager& service_manager) { std::shared_ptr port; - R_ASSERT(service_manager.RegisterService(port, service_name, max_sessions)); + R_ASSERT(service_manager.RegisterService(std::addressof(port), service_name, max_sessions)); port->SetHleHandler(shared_from_this()); } diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index c1737f8e0..3fb87adb3 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -28,35 +28,35 @@ void ServiceManager::InstallInterfaces(Core::System& system) { system.ServiceManager().srv_interface = srv; } -Result ServiceManager::RegisterService(std::shared_ptr& server_port, +Result ServiceManager::RegisterService(std::shared_ptr* out_server_port, std::string name, u32 max_sessions) { R_TRY(ValidateServiceName(name)); R_UNLESS(registered_services.find(name) == registered_services.end(), ResultAlreadyRegistered); - std::shared_ptr client_port; - std::tie(server_port, client_port) = system.Kernel().CreatePortPair(max_sessions, name); + const auto [server_port, client_port] = system.Kernel().CreatePortPair(max_sessions, name); registered_services_inverse.emplace(client_port->GetObjectId(), name); registered_services.emplace(std::move(name), std::move(client_port)); + *out_server_port = server_port; return ResultSuccess; } -Result ServiceManager::GetServicePort(std::shared_ptr& out_port, +Result ServiceManager::GetServicePort(std::shared_ptr* out_client_port, const std::string& name) { R_TRY(ValidateServiceName(name)); auto it = registered_services.find(name); R_UNLESS(it != registered_services.end(), ResultServiceNotRegistered); - out_port = it->second; + *out_client_port = it->second; return ResultSuccess; } -Result ServiceManager::ConnectToService(std::shared_ptr& session, +Result ServiceManager::ConnectToService(std::shared_ptr* out_client_session, const std::string& name) { std::shared_ptr client_port; - R_TRY(GetServicePort(client_port, name)); - return client_port->Connect(session); + R_TRY(GetServicePort(std::addressof(client_port), name)); + return client_port->Connect(out_client_session); } std::string ServiceManager::GetServiceNameByPortId(u32 port) const { diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index 63e656434..fd86ff198 100644 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h @@ -51,10 +51,11 @@ public: explicit ServiceManager(Core::System& system); - Result RegisterService(std::shared_ptr& out_port, std::string name, + Result RegisterService(std::shared_ptr* out_server_port, std::string name, u32 max_sessions); - Result GetServicePort(std::shared_ptr& out_port, const std::string& name); - Result ConnectToService(std::shared_ptr& out_session, + Result GetServicePort(std::shared_ptr* out_client_port, + const std::string& name); + Result ConnectToService(std::shared_ptr* out_client_session, const std::string& name); // For IPC Recorder std::string GetServiceNameByPortId(u32 port) const; diff --git a/src/core/hle/service/sm/srv.cpp b/src/core/hle/service/sm/srv.cpp index 72021827b..f42c5cb1a 100644 --- a/src/core/hle/service/sm/srv.cpp +++ b/src/core/hle/service/sm/srv.cpp @@ -95,10 +95,10 @@ public: Kernel::ThreadWakeupReason reason) { LOG_ERROR(Service_SRV, "called service={} wakeup", name); std::shared_ptr client_port; - R_ASSERT(system.ServiceManager().GetServicePort(client_port, name)); + R_ASSERT(system.ServiceManager().GetServicePort(std::addressof(client_port), name)); std::shared_ptr session; - auto result = client_port->Connect(session); + auto result = client_port->Connect(std::addressof(session)); if (result.IsSuccess()) { LOG_DEBUG(Service_SRV, "called service={} -> session={}", name, session->GetObjectId()); IPC::RequestBuilder rb(ctx, 0x5, 1, 2); @@ -160,7 +160,7 @@ void SRV::GetServiceHandle(Kernel::HLERequestContext& ctx) { auto get_handle = std::make_shared(system, name); std::shared_ptr client_port; - auto result = system.ServiceManager().GetServicePort(client_port, name); + auto result = system.ServiceManager().GetServicePort(std::addressof(client_port), name); if (result.IsError()) { if (wait_until_available && result == ResultServiceNotRegistered) { LOG_INFO(Service_SRV, "called service={} delayed", name); @@ -177,7 +177,7 @@ void SRV::GetServiceHandle(Kernel::HLERequestContext& ctx) { } std::shared_ptr session; - result = client_port->Connect(session); + result = client_port->Connect(std::addressof(session)); if (result.IsSuccess()) { LOG_DEBUG(Service_SRV, "called service={} -> session={}", name, session->GetObjectId()); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); @@ -269,7 +269,7 @@ void SRV::RegisterService(Kernel::HLERequestContext& ctx) { std::string name(name_buf.data(), std::min(name_len, name_buf.size())); std::shared_ptr port; - auto result = system.ServiceManager().RegisterService(port, name, max_sessions); + auto result = system.ServiceManager().RegisterService(std::addressof(port), name, max_sessions); if (result.IsError()) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);