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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user