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.
This commit is contained in:
Lennart Poettering
2022-03-09 16:24:10 +01:00
parent a5a316e7a7
commit 6800876608
+4 -2
View File
@@ -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;