From d870cc5ad710b04fae15baee85e0fa0f4df1e8a0 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 10 Mar 2019 18:23:39 -0400 Subject: [PATCH 1/4] core/hle/result: Relocate IPC error code to ipc_helpers Relocates the error code to where it's most related, similar to how all the other error codes are. Previously we were including a non-generic error in the main result code header. --- src/core/hle/ipc_helpers.h | 3 +++ src/core/hle/result.h | 1 - src/core/hle/service/service.cpp | 3 +-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index 0792838309..fc997c3b76 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h @@ -19,9 +19,12 @@ #include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/object.h" #include "core/hle/kernel/server_session.h" +#include "core/hle/result.h" namespace IPC { +constexpr ResultCode ERR_REMOTE_PROCESS_DEAD{ErrorModule::HIPC, 301}; + class RequestHelperBase { protected: Kernel::HLERequestContext* context = nullptr; diff --git a/src/core/hle/result.h b/src/core/hle/result.h index 1ed144481f..9f6ac39e61 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -17,7 +17,6 @@ */ enum class ErrorDescription : u32 { Success = 0, - RemoteProcessDead = 301, }; /** diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 117f87a457..bd56cc7bf6 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -11,7 +11,6 @@ #include "core/hle/ipc.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/client_port.h" -#include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/process.h" #include "core/hle/kernel/server_port.h" @@ -169,7 +168,7 @@ ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext& co case IPC::CommandType::Close: { IPC::ResponseBuilder rb{context, 2}; rb.Push(RESULT_SUCCESS); - return ResultCode(ErrorModule::HIPC, ErrorDescription::RemoteProcessDead); + return IPC::ERR_REMOTE_PROCESS_DEAD; } case IPC::CommandType::ControlWithContext: case IPC::CommandType::Control: { From f7ec0bcfc2e638530af3254386917e2d39a25e9c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 10 Mar 2019 18:26:09 -0400 Subject: [PATCH 2/4] core/hle/result: Remove now-unused constructor for ResultCode Now that the final stray ErrorDescription member was relocated, we can finally remove it and its relevant constructor in the ResultCode union. --- src/core/hle/result.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/core/hle/result.h b/src/core/hle/result.h index 9f6ac39e61..fca07532e3 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -12,13 +12,6 @@ // All the constants in this file come from http://switchbrew.org/index.php?title=Error_codes -/** - * Detailed description of the error. Code 0 always means success. - */ -enum class ErrorDescription : u32 { - Success = 0, -}; - /** * Identifies the module which caused the error. Error codes can be propagated through a call * chain, meaning that this doesn't always correspond to the module where the API call made is @@ -132,9 +125,6 @@ union ResultCode { constexpr explicit ResultCode(u32 raw) : raw(raw) {} - constexpr ResultCode(ErrorModule module, ErrorDescription description) - : ResultCode(module, static_cast(description)) {} - constexpr ResultCode(ErrorModule module_, u32 description_) : raw(module.FormatValue(module_) | description.FormatValue(description_)) {} From 3f602dde0f0ad719e1b229cebe6d0888e102fd76 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 10 Mar 2019 18:29:28 -0400 Subject: [PATCH 3/4] core/hle/result: Amend error in comment description for ResultCode Gets rid of another holdover from Citra, and describes the OS on the Switch instead. --- src/core/hle/result.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/hle/result.h b/src/core/hle/result.h index fca07532e3..46116c40a9 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -112,7 +112,7 @@ enum class ErrorModule : u32 { ShopN = 811, }; -/// Encapsulates a CTR-OS error code, allowing it to be separated into its constituent fields. +/// Encapsulates a Horizon OS error code, allowing it to be separated into its constituent fields. union ResultCode { u32 raw; From 0c28ab92e66146bb8d4190ff76cd7f5512ee1d3a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 10 Mar 2019 18:34:17 -0400 Subject: [PATCH 4/4] core/hle/result: Remove now-unnecessary manually defined copy assignment operator Previously this was required, as BitField wasn't trivially copyable. BitField has since been made trivially copyable, so now this isn't required anymore. --- src/core/hle/result.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/core/hle/result.h b/src/core/hle/result.h index 46116c40a9..ab84f5ddc0 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -128,11 +128,6 @@ union ResultCode { constexpr ResultCode(ErrorModule module_, u32 description_) : raw(module.FormatValue(module_) | description.FormatValue(description_)) {} - constexpr ResultCode& operator=(const ResultCode& o) { - raw = o.raw; - return *this; - } - constexpr bool IsSuccess() const { return raw == 0; }