]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: routing policy rule - Use hashmap_ensure_put
authorSusant Sahani <ssahani@vmware.com>
Thu, 14 Jan 2021 06:05:49 +0000 (07:05 +0100)
committerSusant Sahani <ssahani@gmail.com>
Fri, 15 Jan 2021 13:29:42 +0000 (14:29 +0100)
src/network/networkd-routing-policy-rule.c

index 722e4158301348048ceb97744c3617ad6416aff3..eafd810044109561508db7ea9c0c502eab07de2b 100644 (file)
@@ -100,11 +100,7 @@ static int routing_policy_rule_new_static(Network *network, const char *filename
         rule->section = TAKE_PTR(n);
         rule->protocol = RTPROT_STATIC;
 
-        r = hashmap_ensure_allocated(&network->rules_by_section, &network_config_hash_ops);
-        if (r < 0)
-                return r;
-
-        r = hashmap_put(network->rules_by_section, rule->section, rule);
+        r = hashmap_ensure_put(&network->rules_by_section, &network_config_hash_ops, rule->section, rule);
         if (r < 0)
                 return r;