From 3ccbe657b152144bf9a9c867b4bf29be89399c8d Mon Sep 17 00:00:00 2001 From: PabloMK7 Date: Wed, 4 Oct 2023 22:31:14 +0200 Subject: [PATCH] Create and use ctx.CommandID() --- src/core/hle/kernel/hle_ipc.h | 5 +++++ src/core/hle/service/http/http_c.cpp | 13 +++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index f8c4a31a70..480c8920c7 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h @@ -213,6 +213,11 @@ public: return {cmd_buf[0]}; } + /// Returns the command ID from the IPC command buffer. + u16 CommandID() const { + return static_cast(CommandHeader().command_id.Value()); + } + /** * Returns the session through which this request was made. This can be used as a map key to * access per-client data on services. diff --git a/src/core/hle/service/http/http_c.cpp b/src/core/hle/service/http/http_c.cpp index b389dc8529..d0dbf410ba 100644 --- a/src/core/hle/service/http/http_c.cpp +++ b/src/core/hle/service/http/http_c.cpp @@ -490,8 +490,7 @@ void HTTP_C::ReceiveDataImpl(Kernel::HLERequestContext& ctx, bool timeout) { return 1'000'000; }, [async_data](Kernel::HLERequestContext& ctx) { - IPC::RequestBuilder rb(ctx, static_cast(ctx.CommandHeader().command_id.Value()), 1, - 0); + IPC::RequestBuilder rb(ctx, ctx.CommandID(), 1, 0); if (async_data->async_res != RESULT_SUCCESS) { rb.Push(async_data->async_res); return; @@ -820,13 +819,13 @@ void HTTP_C::GetResponseHeader(Kernel::HLERequestContext& ctx) { async_data->value_buffer->Write(header_value.data(), 0, header_value.size()); } else { LOG_DEBUG(Service_HTTP, "header={} not found", header_name_str); - IPC::RequestBuilder rb(ctx, 0x001E, 1, 2); + IPC::RequestBuilder rb(ctx, ctx.CommandID(), 1, 2); rb.Push(ERROR_HEADER_NOT_FOUND); rb.PushMappedBuffer(*async_data->value_buffer); return; } - IPC::RequestBuilder rb(ctx, 0x001E, 2, 2); + IPC::RequestBuilder rb(ctx, ctx.CommandID(), 2, 2); rb.Push(RESULT_SUCCESS); rb.Push(copied_size); rb.PushMappedBuffer(*async_data->value_buffer); @@ -890,8 +889,7 @@ void HTTP_C::GetResponseStatusCodeImpl(Kernel::HLERequestContext& ctx, bool time }, [async_data](Kernel::HLERequestContext& ctx) { if (async_data->async_res != RESULT_SUCCESS) { - IPC::RequestBuilder rb( - ctx, static_cast(ctx.CommandHeader().command_id.Value()), 1, 0); + IPC::RequestBuilder rb(ctx, ctx.CommandID(), 1, 0); rb.Push(async_data->async_res); return; } @@ -901,8 +899,7 @@ void HTTP_C::GetResponseStatusCodeImpl(Kernel::HLERequestContext& ctx, bool time const u32 response_code = http_context.response.status; LOG_DEBUG(Service_HTTP, "Status code: {}, response_code={}", "good", response_code); - IPC::RequestBuilder rb(ctx, static_cast(ctx.CommandHeader().command_id.Value()), 2, - 0); + IPC::RequestBuilder rb(ctx, ctx.CommandID(), 2, 0); rb.Push(RESULT_SUCCESS); rb.Push(response_code); });