From: Lennart Poettering Date: Tue, 22 Feb 2022 12:05:16 +0000 (+0100) Subject: logind: replace handle_action_valid() macro by inline function X-Git-Tag: v251-rc1~179^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6800876608f906e862f75d926e0fb2f380b138fc;p=thirdparty%2Fsystemd.git logind: replace handle_action_valid() macro by inline function The old macro will double evaluation and has no protection against operator precedence issues. Let's fix that by using an inline func instead, which also gives us typesafety. --- diff --git a/src/login/logind-action.h b/src/login/logind-action.h index 4dcf719488d..dc073fe951b 100644 --- a/src/login/logind-action.h +++ b/src/login/logind-action.h @@ -21,12 +21,14 @@ typedef enum HandleAction { typedef struct ActionTableItem ActionTableItem; -#define handle_action_valid(x) (x >= 0 && x < _HANDLE_ACTION_MAX) - #include "logind-inhibit.h" #include "logind.h" #include "sleep-config.h" +static inline bool handle_action_valid(HandleAction a) { + return a >= 0 && a < _HANDLE_ACTION_MAX; +} + struct ActionTableItem { HandleAction handle; const char *target;