From 81fae0d1a674df2414da0d438a85432d2ce0cc44 Mon Sep 17 00:00:00 2001 From: TSRBerry <20988865+TSRBerry@users.noreply.github.com> Date: Sat, 7 Jan 2023 00:57:21 +0100 Subject: [PATCH] [hipc] Fix 'Unexpected result code Success returned' in Reply() (#4215) * horizon: Add AbortOnFailureUnless() * hipc: Replace AbortUnless() with AbortOnFailureUnless() in Reply() --- Ryujinx.Horizon.Common/Result.cs | 10 +++++++++- Ryujinx.Horizon/Sdk/Sf/Hipc/Api.cs | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Ryujinx.Horizon.Common/Result.cs b/Ryujinx.Horizon.Common/Result.cs index 04281199d0..ac8436888e 100644 --- a/Ryujinx.Horizon.Common/Result.cs +++ b/Ryujinx.Horizon.Common/Result.cs @@ -100,6 +100,14 @@ namespace Ryujinx.Horizon.Common } } + public void AbortOnFailureUnless(Result result, Result result2) + { + if (this != Success && this != result && this != result2) + { + ThrowInvalidResult(); + } + } + private void ThrowInvalidResult() { throw new InvalidResultException(this); @@ -115,4 +123,4 @@ namespace Ryujinx.Horizon.Common return PrintableResult; } } -} +} \ No newline at end of file diff --git a/Ryujinx.Horizon/Sdk/Sf/Hipc/Api.cs b/Ryujinx.Horizon/Sdk/Sf/Hipc/Api.cs index deac524c72..822a4b4a6b 100644 --- a/Ryujinx.Horizon/Sdk/Sf/Hipc/Api.cs +++ b/Ryujinx.Horizon/Sdk/Sf/Hipc/Api.cs @@ -51,7 +51,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc { Result result = ReplyImpl(sessionHandle, messageBuffer); - result.AbortUnless(KernelResult.TimedOut, KernelResult.PortRemoteClosed); + result.AbortOnFailureUnless(KernelResult.TimedOut, KernelResult.PortRemoteClosed); return Result.Success; } @@ -86,4 +86,4 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc return result; } } -} +} \ No newline at end of file