From a8269fdae345690f28742c5c39470fb9d40ca7cf Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 6 Dec 2018 01:29:17 -0500 Subject: 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 | 8 ++------ src/core/hle/service/sm/sm.cpp | 4 +--- 2 files changed, 3 insertions(+), 9 deletions(-) (limited to 'src/core/hle') diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 1ec340466..7de2c5a40 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -110,9 +110,7 @@ void ServiceFrameworkBase::InstallAsNamedPort() { ASSERT(port == nullptr); auto& kernel = Core::System::GetInstance().Kernel(); - SharedPtr server_port; - SharedPtr client_port; - std::tie(server_port, client_port) = + auto [server_port, client_port] = ServerPort::CreatePortPair(kernel, max_sessions, service_name); server_port->SetHleHandler(shared_from_this()); kernel.AddNamedPort(service_name, std::move(client_port)); @@ -122,9 +120,7 @@ Kernel::SharedPtr ServiceFrameworkBase::CreatePort() { ASSERT(port == nullptr); auto& kernel = Core::System::GetInstance().Kernel(); - Kernel::SharedPtr server_port; - Kernel::SharedPtr client_port; - std::tie(server_port, client_port) = + auto [server_port, client_port] = Kernel::ServerPort::CreatePortPair(kernel, max_sessions, service_name); port = MakeResult>(std::move(server_port)).Unwrap(); port->SetHleHandler(shared_from_this()); diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index 0d0f63a78..d0e35b4d6 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -54,9 +54,7 @@ ResultVal> ServiceManager::RegisterService return ERR_ALREADY_REGISTERED; auto& kernel = Core::System::GetInstance().Kernel(); - Kernel::SharedPtr server_port; - Kernel::SharedPtr client_port; - std::tie(server_port, client_port) = + auto [server_port, client_port] = Kernel::ServerPort::CreatePortPair(kernel, max_sessions, name); registered_services.emplace(std::move(name), std::move(client_port)); -- cgit v1.2.3 From d8625f5544dd0caba80d9ba0be51d0ba96414ae2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 6 Dec 2018 01:33:19 -0500 Subject: hle/service, hle/sm: Compress usages of MakeResult() These auto-deduce the result based off its arguments, so there's no need to do that work for the compiler, plus, the function return value itself already indicates what we're returning. --- src/core/hle/service/service.cpp | 2 +- src/core/hle/service/sm/sm.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/core/hle') diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 7de2c5a40..0ca234d50 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -122,7 +122,7 @@ Kernel::SharedPtr ServiceFrameworkBase::CreatePort() { auto& kernel = Core::System::GetInstance().Kernel(); auto [server_port, client_port] = Kernel::ServerPort::CreatePortPair(kernel, max_sessions, service_name); - port = MakeResult>(std::move(server_port)).Unwrap(); + port = MakeResult(std::move(server_port)).Unwrap(); port->SetHleHandler(shared_from_this()); return client_port; } diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index d0e35b4d6..d73530086 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -58,7 +58,7 @@ ResultVal> ServiceManager::RegisterService Kernel::ServerPort::CreatePortPair(kernel, 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)); } ResultCode ServiceManager::UnregisterService(const std::string& name) { @@ -81,7 +81,7 @@ ResultVal> ServiceManager::GetServicePort( return ERR_SERVICE_NOT_REGISTERED; } - return MakeResult>(it->second); + return MakeResult(it->second); } ResultVal> ServiceManager::ConnectToService( -- cgit v1.2.3 From 9f56477539cd3eabb9f06eb4827158c313d85712 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 6 Dec 2018 01:37:39 -0500 Subject: 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 | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/core/hle') diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 0ca234d50..f061947f2 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -70,10 +70,6 @@ #include "core/hle/service/vi/vi.h" #include "core/hle/service/wlan/wlan.h" -using Kernel::ClientPort; -using Kernel::ServerPort; -using Kernel::SharedPtr; - namespace Service { /** @@ -111,7 +107,7 @@ void ServiceFrameworkBase::InstallAsNamedPort() { auto& kernel = Core::System::GetInstance().Kernel(); auto [server_port, client_port] = - ServerPort::CreatePortPair(kernel, max_sessions, service_name); + Kernel::ServerPort::CreatePortPair(kernel, max_sessions, service_name); server_port->SetHleHandler(shared_from_this()); kernel.AddNamedPort(service_name, std::move(client_port)); } -- cgit v1.2.3 From 24f051d7234bf18bc3dd770f3707c1a140688c3f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 6 Dec 2018 01:40:21 -0500 Subject: hle/service: Replace log + UNIMPLEMENTED with UNIMPLEMENTED_MSG Combines the two into one, shortening the amount of code here. --- src/core/hle/service/service.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/core/hle') diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index f061947f2..d41df3732 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -144,8 +144,7 @@ void ServiceFrameworkBase::ReportUnimplementedFunction(Kernel::HLERequestContext } buf.push_back('}'); - LOG_ERROR(Service, "unknown / unimplemented {}", fmt::to_string(buf)); - UNIMPLEMENTED(); + UNIMPLEMENTED_MSG("Unknown / unimplemented {}", fmt::to_string(buf)); } void ServiceFrameworkBase::InvokeRequest(Kernel::HLERequestContext& ctx) { -- cgit v1.2.3