logind: Use hashmap_ensure_put

This commit is contained in:
Susant Sahani
2021-01-20 15:09:03 +01:00
parent 8231485bc5
commit 9a8d1b455b
+4 -5
View File
@@ -217,10 +217,6 @@ int manager_write_brightness(
return 0;
}
r = hashmap_ensure_allocated(&m->brightness_writers, &brightness_writer_hash_ops);
if (r < 0)
return log_oom();
w = new(BrightnessWriter, 1);
if (!w)
return log_oom();
@@ -234,9 +230,12 @@ int manager_write_brightness(
if (!w->path)
return log_oom();
r = hashmap_put(m->brightness_writers, w->path, w);
r = hashmap_ensure_put(&m->brightness_writers, &brightness_writer_hash_ops, w->path, w);
if (r == -ENOMEM)
return log_oom();
if (r < 0)
return log_error_errno(r, "Failed to add brightness writer to hashmap: %m");
w->manager = m;
r = set_add_message(&w->current_messages, message);