summaryrefslogtreecommitdiff
path: root/src/libudev
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-02-02 02:16:42 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-02-02 02:22:35 +0900
commiteaef130d3fcb3c6a4d2feb50248ab3ac26f3e05b (patch)
treebebe59a60c8cabd431445e734acbf76abb5283f4 /src/libudev
parent77591e97327d6fc47f27599ba1937629afb6dd13 (diff)
downloadsystemd-eaef130d3fcb3c6a4d2feb50248ab3ac26f3e05b.tar.gz
libudev: use hashmap_ensure_put()
Diffstat (limited to 'src/libudev')
-rw-r--r--src/libudev/libudev-list.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/src/libudev/libudev-list.c b/src/libudev/libudev-list.c
index 3b2a2cdee4..514927bc8f 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;