summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-11-08 12:27:39 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-11-08 13:55:25 +0100
commit6529ccfa20c53c63e4ed99a9119a2de267c746d5 (patch)
treec891ac6c1cec85a45ca7eee3f0e9faf4cb87261c /src
parentabdcb688a8a82807cb5f864babdba91c859ac5f8 (diff)
downloadsystemd-6529ccfa20c53c63e4ed99a9119a2de267c746d5.tar.gz
systemd-6529ccfa20c53c63e4ed99a9119a2de267c746d5.tar.bz2
systemd-6529ccfa20c53c63e4ed99a9119a2de267c746d5.zip
unit: replace three non-type-safe macros by type-safe inline functions
Behaviour is prett ymuch the same, but there's some additional type checking done on the input parameters. (In the case of UNIT_WRITE_FLAGS_NOOP() the C compiler won't actually do the type checking necessarily, but static chckers at least could)
Diffstat (limited to 'src')
-rw-r--r--src/core/unit.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/core/unit.h b/src/core/unit.h
index c91fb49c60..c6ee1dfc3b 100644
--- a/src/core/unit.h
+++ b/src/core/unit.h
@@ -382,7 +382,9 @@ typedef enum UnitWriteFlags {
} UnitWriteFlags;
/* Returns true if neither persistent, nor runtime storage is requested, i.e. this is a check invocation only */
-#define UNIT_WRITE_FLAGS_NOOP(flags) (((flags) & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0)
+static inline bool UNIT_WRITE_FLAGS_NOOP(UnitWriteFlags flags) {
+ return (flags & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0;
+}
#include "kill.h"
@@ -570,7 +572,9 @@ typedef struct UnitVTable {
extern const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX];
-#define UNIT_VTABLE(u) unit_vtable[(u)->type]
+static inline const UnitVTable* UNIT_VTABLE(Unit *u) {
+ return unit_vtable[u->type];
+}
/* For casting a unit into the various unit types */
#define DEFINE_CAST(UPPERCASE, MixedCase) \
@@ -593,7 +597,9 @@ extern const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX];
#define UNIT_HAS_CGROUP_CONTEXT(u) (UNIT_VTABLE(u)->cgroup_context_offset > 0)
#define UNIT_HAS_KILL_CONTEXT(u) (UNIT_VTABLE(u)->kill_context_offset > 0)
-#define UNIT_TRIGGER(u) ((Unit*) hashmap_first_key((u)->dependencies[UNIT_TRIGGERS]))
+static inline Unit* UNIT_TRIGGER(Unit *u) {
+ return hashmap_first_key(u->dependencies[UNIT_TRIGGERS]);
+}
Unit *unit_new(Manager *m, size_t size);
void unit_free(Unit *u);