]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: job - use hashmap_ensure_put
authorSusant Sahani <ssahani@vmware.com>
Sun, 17 Jan 2021 13:24:36 +0000 (14:24 +0100)
committerSusant Sahani <ssahani@vmware.com>
Sun, 17 Jan 2021 13:24:36 +0000 (14:24 +0100)
src/core/job.c

index f3c1a0283167532758525c8d20a094d7db2df7fe..e857f15b4b7843cc4e9832691906a62b948f926f 100644 (file)
@@ -263,11 +263,7 @@ int job_install_deserialized(Job *j) {
                 return log_unit_debug_errno(j->unit, SYNTHETIC_ERRNO(EEXIST),
                                             "Unit already has a job installed. Not installing deserialized job.");
 
-        r = hashmap_ensure_allocated(&j->manager->jobs, NULL);
-        if (r < 0)
-                return r;
-
-        r = hashmap_put(j->manager->jobs, UINT32_TO_PTR(j->id), j);
+        r = hashmap_ensure_put(&j->manager->jobs, NULL, UINT32_TO_PTR(j->id), j);
         if (r == -EEXIST)
                 return log_unit_debug_errno(j->unit, r, "Job ID %" PRIu32 " already used, cannot deserialize job.", j->id);
         if (r < 0)