diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 33d0ab5add..6e6d606854 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -3050,9 +3050,7 @@ int unit_check_oom(Unit *u) { if (!crt || !crt->cgroup_path) return 0; - CGroupContext *ctx = unit_get_cgroup_context(u); - if (!ctx) - return 0; + CGroupContext *ctx = ASSERT_PTR(unit_get_cgroup_context(u)); /* If memory.oom.group=1, then look up the oom_group_kill field, which reports how many times the * kernel killed every process recursively in this cgroup and its descendants, similar to diff --git a/src/core/unit.c b/src/core/unit.c index 7161c1cb6c..4287179903 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -5141,12 +5141,11 @@ int unit_setup_exec_runtime(Unit *u) { return r; } -CGroupRuntime *unit_setup_cgroup_runtime(Unit *u) { - size_t offset; - +CGroupRuntime* unit_setup_cgroup_runtime(Unit *u) { assert(u); + assert(UNIT_HAS_CGROUP_CONTEXT(u)); - offset = UNIT_VTABLE(u)->cgroup_runtime_offset; + size_t offset = UNIT_VTABLE(u)->cgroup_runtime_offset; assert(offset > 0); CGroupRuntime **rt = (CGroupRuntime**) ((uint8_t*) u + offset);