From 3f70f938a05e609d56bde1939473fb3ab4a4e6ec Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Mon, 18 Jan 2021 13:09:23 +0100 Subject: [PATCH] network: wait-online - use hashmap_ensure_put --- src/network/wait-online/link.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/network/wait-online/link.c b/src/network/wait-online/link.c index 529fc9f22a..d0f3347617 100644 --- a/src/network/wait-online/link.c +++ b/src/network/wait-online/link.c @@ -16,14 +16,6 @@ int link_new(Manager *m, Link **ret, int ifindex, const char *ifname) { assert(m); assert(ifindex > 0); - r = hashmap_ensure_allocated(&m->links, NULL); - if (r < 0) - return r; - - r = hashmap_ensure_allocated(&m->links_by_name, &string_hash_ops); - if (r < 0) - return r; - n = strdup(ifname); if (!n) return -ENOMEM; @@ -39,11 +31,11 @@ int link_new(Manager *m, Link **ret, int ifindex, const char *ifname) { .required_operstate = LINK_OPERSTATE_RANGE_DEFAULT, }; - r = hashmap_put(m->links_by_name, l->ifname, l); + r = hashmap_ensure_put(&m->links, NULL, INT_TO_PTR(ifindex), l); if (r < 0) return r; - r = hashmap_put(m->links, INT_TO_PTR(ifindex), l); + r = hashmap_ensure_put(&m->links_by_name, &string_hash_ops, l->ifname, l); if (r < 0) return r;