From 3ef63c317481c2b3f1fe39e1b0f130aac3544522 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 18 Sep 2012 11:40:01 +0200 Subject: unit-printf: before resolving exec context specifiers check whether the object actually has an exec context --- src/core/unit.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/core/unit.c') diff --git a/src/core/unit.c b/src/core/unit.c index 4eea5b57ae..1e33936346 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -2684,6 +2684,17 @@ int unit_exec_context_defaults(Unit *u, ExecContext *c) { return 0; } +ExecContext *unit_get_exec_context(Unit *u) { + size_t offset; + assert(u); + + offset = UNIT_VTABLE(u)->exec_context_offset; + if (offset <= 0) + return NULL; + + return (ExecContext*) ((uint8_t*) u + offset); +} + static const char* const unit_active_state_table[_UNIT_ACTIVE_STATE_MAX] = { [UNIT_ACTIVE] = "active", [UNIT_RELOADING] = "reloading", -- cgit v1.2.3-54-g00ecf