From 097c25b164ba830b8d4a89926a3e90d297d06d8f Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 6 Mar 2023 20:34:25 -0500 Subject: kernel: convert KPort, KSession --- src/core/hle/kernel/svc/svc_session.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core/hle/kernel/svc/svc_session.cpp') diff --git a/src/core/hle/kernel/svc/svc_session.cpp b/src/core/hle/kernel/svc/svc_session.cpp index 6dd242dcf..90d680540 100644 --- a/src/core/hle/kernel/svc/svc_session.cpp +++ b/src/core/hle/kernel/svc/svc_session.cpp @@ -12,7 +12,7 @@ namespace Kernel::Svc { namespace { template -Result CreateSession(Core::System& system, Handle* out_server, Handle* out_client, u64 name) { +Result CreateSession(Core::System& system, Handle* out_server, Handle* out_client, uint64_t name) { auto& process = GetCurrentProcess(system.Kernel()); auto& handle_table = process.GetHandleTable(); @@ -59,7 +59,7 @@ Result CreateSession(Core::System& system, Handle* out_server, Handle* out_clien R_UNLESS(session != nullptr, ResultOutOfResource); // Initialize the session. - session->Initialize(nullptr, fmt::format("{}", name)); + session->Initialize(nullptr, name); // Commit the session reservation. session_reservation.Commit(); -- cgit v1.2.3 From 91fd4e30f2a12868201b08e73de299db1c3d116a Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 7 Mar 2023 00:13:05 -0500 Subject: kernel/svc: convert to new style --- src/core/hle/kernel/svc/svc_session.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/core/hle/kernel/svc/svc_session.cpp') diff --git a/src/core/hle/kernel/svc/svc_session.cpp b/src/core/hle/kernel/svc/svc_session.cpp index 90d680540..d5a3d0120 100644 --- a/src/core/hle/kernel/svc/svc_session.cpp +++ b/src/core/hle/kernel/svc/svc_session.cpp @@ -25,7 +25,7 @@ Result CreateSession(Core::System& system, Handle* out_server, Handle* out_clien if (session_reservation.Succeeded()) { session = T::Create(system.Kernel()); } else { - return ResultLimitReached; + R_THROW(ResultLimitReached); // // We couldn't reserve a session. Check that we support dynamically expanding the // // resource limit. @@ -77,15 +77,13 @@ Result CreateSession(Core::System& system, Handle* out_server, Handle* out_clien // Add the server session to the handle table. R_TRY(handle_table.Add(out_server, &session->GetServerSession())); - // Add the client session to the handle table. - const auto result = handle_table.Add(out_client, &session->GetClientSession()); - - if (!R_SUCCEEDED(result)) { - // Ensure that we maintain a clean handle state on exit. + // Ensure that we maintain a clean handle state on exit. + ON_RESULT_FAILURE { handle_table.Remove(*out_server); - } + }; - return result; + // Add the client session to the handle table. + R_RETURN(handle_table.Add(out_client, &session->GetClientSession())); } } // namespace @@ -94,9 +92,9 @@ Result CreateSession(Core::System& system, Handle* out_server, Handle* out_clien u64 name) { if (is_light) { // return CreateSession(system, out_server, out_client, name); - return ResultNotImplemented; + R_THROW(ResultNotImplemented); } else { - return CreateSession(system, out_server, out_client, name); + R_RETURN(CreateSession(system, out_server, out_client, name)); } } -- cgit v1.2.3 From ac6cbb7134d71134e4beae91361a78fa68202c22 Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 7 Mar 2023 12:01:07 -0500 Subject: kernel: prefer std::addressof --- src/core/hle/kernel/svc/svc_session.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/core/hle/kernel/svc/svc_session.cpp') diff --git a/src/core/hle/kernel/svc/svc_session.cpp b/src/core/hle/kernel/svc/svc_session.cpp index d5a3d0120..01b8a52ad 100644 --- a/src/core/hle/kernel/svc/svc_session.cpp +++ b/src/core/hle/kernel/svc/svc_session.cpp @@ -21,7 +21,8 @@ Result CreateSession(Core::System& system, Handle* out_server, Handle* out_clien // Reserve a new session from the process resource limit. // FIXME: LimitableResource_SessionCountMax - KScopedResourceReservation session_reservation(&process, LimitableResource::SessionCountMax); + KScopedResourceReservation session_reservation(std::addressof(process), + LimitableResource::SessionCountMax); if (session_reservation.Succeeded()) { session = T::Create(system.Kernel()); } else { @@ -30,7 +31,7 @@ Result CreateSession(Core::System& system, Handle* out_server, Handle* out_clien // // We couldn't reserve a session. Check that we support dynamically expanding the // // resource limit. // R_UNLESS(process.GetResourceLimit() == - // &system.Kernel().GetSystemResourceLimit(), ResultLimitReached); + // std::addressof(system.Kernel().GetSystemResourceLimit()), ResultLimitReached); // R_UNLESS(KTargetSystem::IsDynamicResourceLimitsEnabled(), ResultLimitReached()); // // Try to allocate a session from unused slab memory. @@ -75,7 +76,7 @@ Result CreateSession(Core::System& system, Handle* out_server, Handle* out_clien T::Register(system.Kernel(), session); // Add the server session to the handle table. - R_TRY(handle_table.Add(out_server, &session->GetServerSession())); + R_TRY(handle_table.Add(out_server, std::addressof(session->GetServerSession()))); // Ensure that we maintain a clean handle state on exit. ON_RESULT_FAILURE { @@ -83,7 +84,7 @@ Result CreateSession(Core::System& system, Handle* out_server, Handle* out_clien }; // Add the client session to the handle table. - R_RETURN(handle_table.Add(out_client, &session->GetClientSession())); + R_RETURN(handle_table.Add(out_client, std::addressof(session->GetClientSession()))); } } // namespace -- cgit v1.2.3