From: Yu Watanabe Date: Mon, 1 Feb 2021 17:16:42 +0000 (+0900) Subject: libudev: use hashmap_ensure_put() X-Git-Tag: v248-rc1~224^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eaef130d3fcb3c6a4d2feb50248ab3ac26f3e05b;p=thirdparty%2Fsystemd.git libudev: use hashmap_ensure_put() --- diff --git a/src/libudev/libudev-list.c b/src/libudev/libudev-list.c index 3b2a2cdee4b..514927bc8fa 100644 --- a/src/libudev/libudev-list.c +++ b/src/libudev/libudev-list.c @@ -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;