summaryrefslogtreecommitdiff
path: root/src/unit.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-06-19 16:57:29 +0200
committerLennart Poettering <lennart@poettering.net>2010-06-19 16:57:29 +0200
commit399ab2b1ac07be5afa9708b3280d4e1a4cceb5b8 (patch)
treef5d89000a155cbf8c4703cfffe05b9cc9e8a51c4 /src/unit.h
parent0ca3f374f9d7c166ac5b391ec7208f6de7274e7f (diff)
unit: make unit casts typesafe
Diffstat (limited to 'src/unit.h')
-rw-r--r--src/unit.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/unit.h b/src/unit.h
index c5be858923..fb158d511d 100644
--- a/src/unit.h
+++ b/src/unit.h
@@ -336,14 +336,14 @@ extern const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX];
/* For casting a unit into the various unit types */
#define DEFINE_CAST(UPPERCASE, MixedCase) \
static inline MixedCase* UPPERCASE(Unit *u) { \
- if (!u || u->meta.type != UNIT_##UPPERCASE) \
+ if (_unlikely_(!u || u->meta.type != UNIT_##UPPERCASE)) \
return NULL; \
\
return (MixedCase*) u; \
}
/* For casting the various unit types into a unit */
-#define UNIT(u) ((Unit*) (u))
+#define UNIT(u) ((Unit*) (&(u)->meta))
DEFINE_CAST(SOCKET, Socket);
DEFINE_CAST(TIMER, Timer);