network: sd-dhcp6-client - use ordered_hashmap_ensure_put
authorSusant Sahani <ssahani@vmware.com>
Mon, 18 Jan 2021 17:33:40 +0000 (18:33 +0100)
committerSusant Sahani <ssahani@vmware.com>
Mon, 18 Jan 2021 20:53:19 +0000 (21:53 +0100)
src/libsystemd-network/sd-dhcp6-client.c

index 788f2e1d42c6ce585ab5a722f69475ad32b36006..f362770c4fe5741bca54e0cfef49967f82690a7e 100644 (file)
@@ -234,11 +234,7 @@ int sd_dhcp6_client_add_vendor_option(sd_dhcp6_client *client, sd_dhcp6_option *
         assert_return(client, -EINVAL);
         assert_return(v, -EINVAL);
 
-        r = ordered_hashmap_ensure_allocated(&client->vendor_options, &dhcp6_option_hash_ops);
-        if (r < 0)
-                return r;
-
-        r = ordered_hashmap_put(client->vendor_options, v, v);
+        r = ordered_hashmap_ensure_put(&client->vendor_options, &dhcp6_option_hash_ops, v, v);
         if (r < 0)
                 return r;
 
@@ -567,11 +563,7 @@ int sd_dhcp6_client_add_option(sd_dhcp6_client *client, sd_dhcp6_option *v) {
         assert_return(client, -EINVAL);
         assert_return(v, -EINVAL);
 
-        r = ordered_hashmap_ensure_allocated(&client->extra_options, &dhcp6_option_hash_ops);
-        if (r < 0)
-                return r;
-
-        r = ordered_hashmap_put(client->extra_options, UINT_TO_PTR(v->option), v);
+        r = ordered_hashmap_ensure_put(&client->extra_options, &dhcp6_option_hash_ops, UINT_TO_PTR(v->option), v);
         if (r < 0)
                 return r;