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.
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;