From 2326a92c6258a3f9e3c481a2982c75014359bf1a Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 8 Mar 2020 18:33:01 +0100 Subject: [PATCH] Improve event passing clarity --- src/common/communication.cpp | 6 +++--- src/common/communication.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/communication.cpp b/src/common/communication.cpp index 947ade34..8508e191 100644 --- a/src/common/communication.cpp +++ b/src/common/communication.cpp @@ -37,14 +37,14 @@ intptr_t send_event(boost::asio::local::stream_protocol::socket& socket, response.data); } if (response.data.has_value()) { - char* char_data = static_cast(data); + char* output = static_cast(data); // For correctness we will copy the entire buffer and add a terminating // null byte ourselves. In practice `response.data` will only ever // contain C-style strings, but this would work with any other data // format that can contain null bytes. - std::copy(response.data->begin(), response.data->end(), char_data); - char_data[response.data->size()] = 0; + std::copy(response.data->begin(), response.data->end(), output); + output[response.data->size()] = 0; } return response.return_value; diff --git a/src/common/communication.h b/src/common/communication.h index 19e7ca46..6966428b 100644 --- a/src/common/communication.h +++ b/src/common/communication.h @@ -183,7 +183,7 @@ void passthrough_event(boost::asio::local::stream_protocol::socket& socket, const auto response_data = std::holds_alternative>( event.payload) - ? std::make_optional(static_cast(data)) + ? std::optional(std::string(static_cast(data))) : std::nullopt; if (logging.has_value()) {