]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/network/networkd-radv.c
tree-wide: use TAKE_PTR() and TAKE_FD() macros
[thirdparty/systemd.git] / src / network / networkd-radv.c
index 5fdab89f2d0c9d0b8949f350d3f239a5d2c4457a..f7e14c9655a289e2c5be40a2339111ea9398459b 100644 (file)
 #include "sd-radv.h"
 #include "string-util.h"
 
-int config_parse_router_prefix_delegation(const char *unit,
-                                          const char *filename,
-                                          unsigned line,
-                                          const char *section,
-                                          unsigned section_line,
-                                         const char *lvalue,
-                                          int ltype,
-                                          const char *rvalue,
-                                          void *data,
-                                          void *userdata) {
+int config_parse_router_prefix_delegation(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
+
         Network *network = userdata;
         int d;
 
@@ -124,8 +126,7 @@ int prefix_new(Prefix **ret) {
         if (sd_radv_prefix_new(&prefix->radv_prefix) < 0)
                 return -ENOMEM;
 
-        *ret = prefix;
-        prefix = NULL;
+        *ret = TAKE_PTR(prefix);
 
         return 0;
 }
@@ -148,8 +149,7 @@ int prefix_new_static(Network *network, const char *filename,
                 if (section_line) {
                         prefix = hashmap_get(network->prefixes_by_section, n);
                         if (prefix) {
-                                *ret = prefix;
-                                prefix = NULL;
+                                *ret = TAKE_PTR(prefix);
 
                                 return 0;
                         }
@@ -161,8 +161,7 @@ int prefix_new_static(Network *network, const char *filename,
                 return r;
 
         if (filename) {
-                prefix->section = n;
-                n = NULL;
+                prefix->section = TAKE_PTR(n);
 
                 r = hashmap_put(network->prefixes_by_section, prefix->section,
                                 prefix);
@@ -174,8 +173,7 @@ int prefix_new_static(Network *network, const char *filename,
         LIST_APPEND(prefixes, network->static_prefixes, prefix);
         network->n_static_prefixes++;
 
-        *ret = prefix;
-        prefix = NULL;
+        *ret = TAKE_PTR(prefix);
 
         return 0;
 }
@@ -342,8 +340,7 @@ static int radv_get_ip6dns(Network *network, struct in6_addr **dns,
         }
 
         if (addresses) {
-                *dns = addresses;
-                addresses = NULL;
+                *dns = TAKE_PTR(addresses);
 
                 *n_dns = n_addresses;
         }