]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/serialization: shorten code, treat all oom error the same
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 8 Jun 2021 14:46:35 +0000 (16:46 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 10 Jun 2021 12:17:58 +0000 (14:17 +0200)
src/core/execute.c

index 5c30d0bcbe64453ecdc837b308b60366cd3f49f0..8450bb05552b0cb87165756642e9b6bda929bc27 100644 (file)
@@ -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;