core: job - use hashmap_ensure_put

This commit is contained in:
Susant Sahani
2021-01-17 14:24:36 +01:00
parent cf55fe4a4c
commit 53dba3ef07
+1 -5
View 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)