X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Funit.h;h=fb158d511d398a7c36febc5fc67cf4c190f3f2d6;hb=b1fc29fb70de560fe9a7a744a20a67aaa4b68b5f;hp=c5be858923ceaa3f90b84da19ddfdb2ee5ff6d60;hpb=5e8d1c9a9f15b7453474dc4879bdb4021c3f50a1;p=elogind.git diff --git a/src/unit.h b/src/unit.h index c5be85892..fb158d511 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);