From: Mike Yuan Date: Sun, 4 Feb 2024 10:48:31 +0000 (+0800) Subject: core/unit: use ASSERT_PTR and strdup_or_null more X-Git-Tag: v256-rc1~968^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5801e9714636ec22a922520e045efd6e20249a6;p=thirdparty%2Fsystemd.git core/unit: use ASSERT_PTR and strdup_or_null more --- diff --git a/src/core/unit.c b/src/core/unit.c index 0c48e5fa606..6dc13bcc9ad 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -4959,8 +4959,7 @@ int unit_setup_exec_runtime(Unit *u) { if (*rt) return 0; - ec = unit_get_exec_context(u); - assert(ec); + ec = ASSERT_PTR(unit_get_exec_context(u)); r = unit_get_transitive_dependency_set(u, UNIT_ATOM_JOINS_NAMESPACE_OF, &units); if (r < 0) @@ -5319,7 +5318,6 @@ int unit_acquire_invocation_id(Unit *u) { } int unit_set_exec_params(Unit *u, ExecParameters *p) { - const char *confirm_spawn; int r; assert(u); @@ -5332,12 +5330,9 @@ int unit_set_exec_params(Unit *u, ExecParameters *p) { p->runtime_scope = u->manager->runtime_scope; - confirm_spawn = manager_get_confirm_spawn(u->manager); - if (confirm_spawn) { - p->confirm_spawn = strdup(confirm_spawn); - if (!p->confirm_spawn) - return -ENOMEM; - } + r = strdup_or_null(manager_get_confirm_spawn(u->manager), &p->confirm_spawn); + if (r < 0) + return r; p->cgroup_supported = u->manager->cgroup_supported; p->prefix = u->manager->prefix;