]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
libudev: use hashmap_ensure_put()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 1 Feb 2021 17:16:42 +0000 (02:16 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 1 Feb 2021 17:22:35 +0000 (02:22 +0900)
src/libudev/libudev-list.c

index 3b2a2cdee4b3337db0ec543f14fa09d90b073388..514927bc8fa53262f4c02287f10de445bdd94963 100644 (file)
@@ -70,7 +70,6 @@ struct udev_list *udev_list_new(bool unique) {
 struct udev_list_entry *udev_list_entry_add(struct udev_list *list, const char *_name, const char *_value) {
         _cleanup_(udev_list_entry_freep) struct udev_list_entry *entry = NULL;
         _cleanup_free_ char *name = NULL, *value = NULL;
-        int r;
 
         assert(list);
 
@@ -95,14 +94,9 @@ struct udev_list_entry *udev_list_entry_add(struct udev_list *list, const char *
         };
 
         if (list->unique) {
-                r = hashmap_ensure_allocated(&list->unique_entries, &string_hash_ops);
-                if (r < 0)
-                        return NULL;
-
                 udev_list_entry_free(hashmap_get(list->unique_entries, entry->name));
 
-                r = hashmap_put(list->unique_entries, entry->name, entry);
-                if (r < 0)
+                if (hashmap_ensure_put(&list->unique_entries, &string_hash_ops, entry->name, entry) < 0)
                         return NULL;
 
                 list->uptodate = false;