From 719d8031b7fc53d089557783270eaa6c9663b765 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 21 Aug 2023 17:28:47 +0900 Subject: [PATCH] plugin-api: deviced: Replace macro MATCH() with strncmp() The macro MATCH() has come from the deviced, and has been working well as it is, currently, always built with that macro definition within the deviced. Fix it not to be associated with the deviced so that it is able to be built alone. Change-Id: I21fe6f33f14ad6037592af12c6e1404f8ef128d1 Signed-off-by: Youngjae Cho --- .../syscommon-plugin-deviced-power-interface.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h b/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h index 71f0b89..c28b7e8 100644 --- a/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h +++ b/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h @@ -25,6 +25,8 @@ #ifndef __SYSCOMMON_PLUGIN_DEVICED_POWER_INTERFACE_H__ #define __SYSCOMMON_PLUGIN_DEVICED_POWER_INTERFACE_H__ +#include + #ifdef __cplusplus extern "C" { #endif @@ -82,19 +84,19 @@ struct syscommon_plugin_deviced_power_trans_info { static inline u_int64_t syscommon_plugin_deviced_power_convert_to_power_state(const char *str) { - if (MATCH(str, "start")) + if (strncmp(str, "start", sizeof("start")) == 0) return DEVICED_POWER_STATE_START; - else if (MATCH(str, "sleep")) + else if (strncmp(str, "sleep", sizeof("sleep")) == 0) return DEVICED_POWER_STATE_SLEEP; - else if (MATCH(str, "normal")) + else if (strncmp(str, "normal", sizeof("normal")) == 0) return DEVICED_POWER_STATE_NORMAL; - else if (MATCH(str, "poweroff")) + else if (strncmp(str, "poweroff", sizeof("poweroff")) == 0) return DEVICED_POWER_STATE_POWEROFF; - else if (MATCH(str, "reboot")) + else if (strncmp(str, "reboot", sizeof("reboot")) == 0) return DEVICED_POWER_STATE_REBOOT; - else if (MATCH(str, "exit")) + else if (strncmp(str, "exit", sizeof("exit")) == 0) return DEVICED_POWER_STATE_EXIT; - else if (MATCH(str, "current")) + else if (strncmp(str, "current", sizeof("current")) == 0) return DEVICED_POWER_STATE_ALL; return DEVICED_POWER_STATE_UNDEFINED; -- 2.34.1