From 0cb7654d6017e945abf45af63f5bd5da07d3c093 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 6 Dec 2018 01:29:17 -0500 Subject: [PATCH 1/3] hle/service, hle/sm: Use structured bindings where applicable Gets rid of the need to keep the variables separate from their actual initialization spots. --- src/core/hle/service/service.cpp | 4 +--- src/core/hle/service/sm/sm.cpp | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index b065208d3..a4b7e6514 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -143,9 +143,7 @@ void ServiceFrameworkBase::InstallAsService(SM::ServiceManager& service_manager) void ServiceFrameworkBase::InstallAsNamedPort(Kernel::KernelSystem& kernel) { ASSERT(port == nullptr); - SharedPtr server_port; - SharedPtr client_port; - std::tie(server_port, client_port) = kernel.CreatePortPair(max_sessions, service_name); + auto [server_port, client_port] = kernel.CreatePortPair(max_sessions, service_name); server_port->SetHleHandler(shared_from_this()); kernel.AddNamedPort(service_name, std::move(client_port)); } diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index 81819c9bd..c2c5a3319 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -40,9 +40,7 @@ ResultVal> ServiceManager::RegisterService if (registered_services.find(name) != registered_services.end()) return ERR_ALREADY_REGISTERED; - Kernel::SharedPtr server_port; - Kernel::SharedPtr client_port; - std::tie(server_port, client_port) = system.Kernel().CreatePortPair(max_sessions, name); + auto [server_port, client_port] = system.Kernel().CreatePortPair(max_sessions, name); registered_services.emplace(std::move(name), std::move(client_port)); return MakeResult>(std::move(server_port)); From a32725540ce9ae4c310d0884dd97f0f45d61c221 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 6 Dec 2018 01:33:19 -0500 Subject: [PATCH 2/3] hle/service, hle/sm: Use structured bindings where applicable Gets rid of the need to keep the variables separate from their actual initialization spots. --- src/core/hle/service/sm/sm.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index c2c5a3319..9520be4ad 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -43,7 +43,7 @@ ResultVal> ServiceManager::RegisterService auto [server_port, client_port] = system.Kernel().CreatePortPair(max_sessions, name); registered_services.emplace(std::move(name), std::move(client_port)); - return MakeResult>(std::move(server_port)); + return MakeResult(std::move(server_port)); } ResultVal> ServiceManager::GetServicePort( @@ -55,7 +55,7 @@ ResultVal> ServiceManager::GetServicePort( return ERR_SERVICE_NOT_REGISTERED; } - return MakeResult>(it->second); + return MakeResult(it->second); } ResultVal> ServiceManager::ConnectToService( From dd2cbca3f4330cc9f807f9c9d2af86e50f447094 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 6 Dec 2018 01:37:39 -0500 Subject: [PATCH 3/3] hle/service: Remove unnecessary using declarations Only one usage of the specified objects made use of the lack of namespacing. Given the low usage, we can just remove these. --- src/core/hle/service/service.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index a4b7e6514..d88ce203f 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -54,11 +54,6 @@ #include "core/hle/service/ssl_c.h" #include "core/hle/service/y2r_u.h" -using Kernel::ClientPort; -using Kernel::ServerPort; -using Kernel::ServerSession; -using Kernel::SharedPtr; - namespace Service { const std::array service_module_map{ @@ -174,7 +169,8 @@ void ServiceFrameworkBase::ReportUnimplementedFunction(u32* cmd_buf, const Funct cmd_buf[1] = 0; } -void ServiceFrameworkBase::HandleSyncRequest(SharedPtr server_session) { +void ServiceFrameworkBase::HandleSyncRequest( + Kernel::SharedPtr server_session) { Kernel::KernelSystem& kernel = Core::System::GetInstance().Kernel(); auto thread = kernel.GetThreadManager().GetCurrentThread(); // TODO(wwylele): avoid GetPointer @@ -222,7 +218,7 @@ static bool AttemptLLE(const ServiceModuleInfo& service_module) { service_module.name); return false; } - SharedPtr process; + Kernel::SharedPtr process; loader->Load(process); LOG_DEBUG(Service, "Service module \"{}\" has been successfully loaded.", service_module.name); return true;