From 51184c7eadc688d3193b7783ff04de3db3dc25a7 Mon Sep 17 00:00:00 2001 From: patrick96 Date: Mon, 28 Oct 2019 09:57:02 +0100 Subject: [PATCH] ipc: Remove unused global setting None of the payload fields seem to be used. They were the only place where EVENT_SIZE was used and why it had to be a macro (no variable length arrays). --- include/components/ipc.hpp | 15 +++------------ include/modules/ipc.hpp | 2 -- include/settings.hpp.cmake | 2 -- src/components/ipc.cpp | 12 ++++++------ 4 files changed, 9 insertions(+), 22 deletions(-) diff --git a/include/components/ipc.hpp b/include/components/ipc.hpp index 3984926e..6b09882a 100644 --- a/include/components/ipc.hpp +++ b/include/components/ipc.hpp @@ -13,18 +13,9 @@ class signal_emitter; /** * Message types */ -struct ipc_command { - static constexpr const char* prefix{"cmd:"}; - char payload[EVENT_SIZE]{'\0'}; -}; -struct ipc_hook { - static constexpr const char* prefix{"hook:"}; - char payload[EVENT_SIZE]{'\0'}; -}; -struct ipc_action { - static constexpr const char* prefix{"action:"}; - char payload[EVENT_SIZE]{'\0'}; -}; +static constexpr const char* ipc_command_prefix{"cmd:"}; +static constexpr const char* ipc_hook_prefix{"hook:"}; +static constexpr const char* ipc_action_prefix{"action:"}; /** * Component used for inter-process communication. diff --git a/include/modules/ipc.hpp b/include/modules/ipc.hpp index 21b1c9b8..bb681a62 100644 --- a/include/modules/ipc.hpp +++ b/include/modules/ipc.hpp @@ -5,8 +5,6 @@ POLYBAR_NS -struct ipc_hook; // fwd - namespace modules { /** * Module that allow users to configure hooks on diff --git a/include/settings.hpp.cmake b/include/settings.hpp.cmake index ed3c0d55..2099ad5a 100644 --- a/include/settings.hpp.cmake +++ b/include/settings.hpp.cmake @@ -45,8 +45,6 @@ extern const char* const APP_VERSION; #cmakedefine DEBUG_FONTCONFIG #endif -static const size_t EVENT_SIZE = 64; - static const int SIGN_PRIORITY_CONTROLLER{1}; static const int SIGN_PRIORITY_SCREEN{2}; static const int SIGN_PRIORITY_BAR{3}; diff --git a/src/components/ipc.cpp b/src/components/ipc.cpp index 4e918ce9..d51ea580 100644 --- a/src/components/ipc.cpp +++ b/src/components/ipc.cpp @@ -61,12 +61,12 @@ void ipc::receive_message() { } else if (bytes_read > 0) { string payload{string_util::trim(string{buffer}, '\n')}; - if (payload.find(ipc_command::prefix) == 0) { - m_sig.emit(signals::ipc::command{payload.substr(strlen(ipc_command::prefix))}); - } else if (payload.find(ipc_hook::prefix) == 0) { - m_sig.emit(signals::ipc::hook{payload.substr(strlen(ipc_hook::prefix))}); - } else if (payload.find(ipc_action::prefix) == 0) { - m_sig.emit(signals::ipc::action{payload.substr(strlen(ipc_action::prefix))}); + if (payload.find(ipc_command_prefix) == 0) { + m_sig.emit(signals::ipc::command{payload.substr(strlen(ipc_command_prefix))}); + } else if (payload.find(ipc_hook_prefix) == 0) { + m_sig.emit(signals::ipc::hook{payload.substr(strlen(ipc_hook_prefix))}); + } else if (payload.find(ipc_action_prefix) == 0) { + m_sig.emit(signals::ipc::action{payload.substr(strlen(ipc_action_prefix))}); } else if (!payload.empty()) { m_log.warn("Received unknown ipc message: (payload=%s)", payload); }