]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/network/networkd-ndisc.c
tree-wide: use set_ensure_put()
[thirdparty/systemd.git] / src / network / networkd-ndisc.c
index 19a655b2d7af1398792ce5827f00136878e75587..beeb34375669a4b5190d28e1bc6fe112b1771765 100644 (file)
@@ -591,10 +591,6 @@ static int ndisc_router_process_rdnss(Link *link, sd_ndisc_router *rt) {
                         continue;
                 }
 
-                r = set_ensure_allocated(&link->ndisc_rdnss, &ndisc_rdnss_hash_ops);
-                if (r < 0)
-                        return log_oom();
-
                 x = new(NDiscRDNSS, 1);
                 if (!x)
                         return log_oom();
@@ -604,10 +600,9 @@ static int ndisc_router_process_rdnss(Link *link, sd_ndisc_router *rt) {
                         .valid_until = time_now + lifetime * USEC_PER_SEC,
                 };
 
-                r = set_put(link->ndisc_rdnss, x);
+                r = set_ensure_put(&link->ndisc_rdnss, &ndisc_rdnss_hash_ops, x);
                 if (r < 0)
                         return log_oom();
-
                 TAKE_PTR(x);
 
                 assert(r > 0);
@@ -686,22 +681,16 @@ static void ndisc_router_process_dnssl(Link *link, sd_ndisc_router *rt) {
                         continue;
                 }
 
-                r = set_ensure_allocated(&link->ndisc_dnssl, &ndisc_dnssl_hash_ops);
-                if (r < 0) {
-                        log_oom();
-                        return;
-                }
-
                 s->valid_until = time_now + lifetime * USEC_PER_SEC;
 
-                r = set_put(link->ndisc_dnssl, s);
+                r = set_ensure_put(&link->ndisc_dnssl, &ndisc_dnssl_hash_ops, s);
                 if (r < 0) {
                         log_oom();
                         return;
                 }
-
-                s = NULL;
+                TAKE_PTR(s);
                 assert(r > 0);
+
                 link_dirty(link);
         }
 }
@@ -979,21 +968,16 @@ int config_parse_ndisc_black_listed_prefix(
                 if (set_contains(network->ndisc_black_listed_prefix, &ip.in6))
                         continue;
 
-                r = set_ensure_allocated(&network->ndisc_black_listed_prefix, &in6_addr_hash_ops);
-                if (r < 0)
-                        return log_oom();
-
                 a = newdup(struct in6_addr, &ip.in6, 1);
                 if (!a)
                         return log_oom();
 
-                r = set_put(network->ndisc_black_listed_prefix, a);
+                r = set_ensure_put(&network->ndisc_black_listed_prefix, &in6_addr_hash_ops, a);
                 if (r < 0) {
                         log_syntax(unit, LOG_ERR, filename, line, r,
                                    "Failed to store NDISC black listed prefix '%s', ignoring assignment: %m", n);
                         continue;
                 }
-
                 TAKE_PTR(a);
         }