1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-29 21:55:36 +03:00

network: wait-online - use hashmap_ensure_put

This commit is contained in:
Susant Sahani 2021-01-18 13:09:23 +01:00
parent b2cb2e82c8
commit 3f70f938a0

View File

@ -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;