From: Zbigniew Jędrzejewski-Szmek Date: Tue, 8 Jun 2021 14:46:35 +0000 (+0200) Subject: core/serialization: shorten code, treat all oom error the same X-Git-Tag: v249-rc1~39^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cbc165d17ef571d9b7f2b768603abef84e726bb9;p=thirdparty%2Fsystemd.git core/serialization: shorten code, treat all oom error the same --- diff --git a/src/core/execute.c b/src/core/execute.c index 5c30d0bcbe6..8450bb05552 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -6371,38 +6371,24 @@ int exec_runtime_deserialize_compat(Unit *u, const char *key, const char *value, return 0; } - r = hashmap_ensure_allocated(&u->manager->exec_runtime_by_id, &string_hash_ops); - if (r < 0) { - log_unit_debug_errno(u, r, "Failed to allocate storage for runtime parameter: %m"); - return 0; - } + if (hashmap_ensure_allocated(&u->manager->exec_runtime_by_id, &string_hash_ops) < 0) + return log_oom(); rt = hashmap_get(u->manager->exec_runtime_by_id, u->id); if (!rt) { - r = exec_runtime_allocate(&rt_create, u->id); - if (r < 0) + if (exec_runtime_allocate(&rt_create, u->id) < 0) return log_oom(); rt = rt_create; } if (streq(key, "tmp-dir")) { - char *copy; - - copy = strdup(value); - if (!copy) - return log_oom(); - - free_and_replace(rt->tmp_dir, copy); + if (free_and_strdup_warn(&rt->tmp_dir, value) < 0) + return -ENOMEM; } else if (streq(key, "var-tmp-dir")) { - char *copy; - - copy = strdup(value); - if (!copy) - return log_oom(); - - free_and_replace(rt->var_tmp_dir, copy); + if (free_and_strdup_warn(&rt->var_tmp_dir, value) < 0) + return -ENOMEM; } else if (streq(key, "netns-socket-0")) { int fd;