From 801029047206b514807ea1d64388d049ecee065f Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 19 Apr 2021 18:04:02 -0700 Subject: [PATCH] kern: tweak KHandleTable codegen --- .../include/mesosphere/kern_k_handle_table.hpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_handle_table.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_handle_table.hpp index 25a2d7901..61fda2ec9 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_handle_table.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_handle_table.hpp @@ -131,11 +131,15 @@ namespace ams::kern { /* Handle pseudo-handles. */ if constexpr (std::derived_from) { if (handle == ams::svc::PseudoHandle::CurrentProcess) { - return GetCurrentProcessPointer(); + auto * const cur_process = GetCurrentProcessPointer(); + AMS_ASSUME(cur_process != nullptr); + return cur_process; } } else if constexpr (std::derived_from) { if (handle == ams::svc::PseudoHandle::CurrentThread) { - return GetCurrentThreadPointer(); + auto * const cur_thread = GetCurrentThreadPointer(); + AMS_ASSUME(cur_thread != nullptr); + return cur_thread; } } @@ -159,8 +163,11 @@ namespace ams::kern { ALWAYS_INLINE KScopedAutoObject GetObjectForIpc(ams::svc::Handle handle, KThread *cur_thread) const { /* Handle pseudo-handles. */ + AMS_ASSUME(cur_thread != nullptr); if (handle == ams::svc::PseudoHandle::CurrentProcess) { - return static_cast(static_cast(cur_thread->GetOwnerProcess())); + auto * const cur_process = static_cast(static_cast(cur_thread->GetOwnerProcess())); + AMS_ASSUME(cur_process != nullptr); + return cur_process; } if (handle == ams::svc::PseudoHandle::CurrentThread) { return static_cast(cur_thread);