]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
machine: Use hashmap_ensure_put
authorSusant Sahani <ssahani@vmware.com>
Wed, 20 Jan 2021 11:53:15 +0000 (12:53 +0100)
committerSusant Sahani <ssahani@vmware.com>
Wed, 20 Jan 2021 14:09:09 +0000 (15:09 +0100)
src/machine/image-dbus.c

index 4c4f900527addc12fb78d4b4e26bb7d860b79d5d..f74cabd7fb753a85ae4d1bdf247f9d73a0eeb7de 100644 (file)
@@ -390,10 +390,6 @@ static int image_object_find(sd_bus *bus, const char *path, const char *interfac
                 return 1;
         }
 
-        r = hashmap_ensure_allocated(&m->image_cache, &image_hash_ops);
-        if (r < 0)
-                return r;
-
         if (!m->image_cache_defer_event) {
                 r = sd_event_add_defer(m->event, &m->image_cache_defer_event, image_flush_cache, m);
                 if (r < 0)
@@ -416,7 +412,7 @@ static int image_object_find(sd_bus *bus, const char *path, const char *interfac
 
         image->userdata = m;
 
-        r = hashmap_put(m->image_cache, image->name, image);
+        r = hashmap_ensure_put(&m->image_cache, &image_hash_ops, image->name, image);
         if (r < 0) {
                 image_unref(image);
                 return r;