]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-dhcp-lease: drop ret_ prefixes from the parsers
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 15 Nov 2025 21:09:25 +0000 (06:09 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 16 Nov 2025 01:49:59 +0000 (10:49 +0900)
src/libsystemd-network/sd-dhcp-lease.c

index fcf732bec447b302f34d9acf034295ba1a202726..e811ab7506a7dc16143d491863a380b7409875e0 100644 (file)
@@ -475,18 +475,18 @@ static int lease_parse_be32(const uint8_t *option, size_t len, be32_t *ret) {
         return 0;
 }
 
-static int lease_parse_domain(const uint8_t *option, size_t len, char **ret) {
+static int lease_parse_domain(const uint8_t *option, size_t len, char **domain) {
         _cleanup_free_ char *name = NULL, *normalized = NULL;
         int r;
 
         assert(option);
-        assert(ret);
+        assert(domain);
 
         r = dhcp_option_parse_string(option, len, &name);
         if (r < 0)
                 return r;
         if (!name) {
-                *ret = mfree(*ret);
+                *domain = mfree(*domain);
                 return 0;
         }
 
@@ -500,17 +500,15 @@ static int lease_parse_domain(const uint8_t *option, size_t len, char **ret) {
         if (dns_name_is_root(normalized))
                 return -EINVAL;
 
-        free_and_replace(*ret, normalized);
-
-        return 0;
+        return free_and_replace(*domain, normalized);
 }
 
-static int lease_parse_fqdn(const uint8_t *option, size_t len, char **hostname) {
+static int lease_parse_fqdn(const uint8_t *option, size_t len, char **fqdn) {
         _cleanup_free_ char *name = NULL, *normalized = NULL;
         int r;
 
         assert(option);
-        assert(hostname);
+        assert(fqdn);
 
         /* RFC 4702 Section 2
          *
@@ -540,7 +538,7 @@ static int lease_parse_fqdn(const uint8_t *option, size_t len, char **hostname)
         }
 
         if (!name) {
-                *hostname = mfree(*hostname);
+                *fqdn = mfree(*fqdn);
                 return 0;
         }
 
@@ -554,59 +552,52 @@ static int lease_parse_fqdn(const uint8_t *option, size_t len, char **hostname)
         if (dns_name_is_root(normalized))
                 return -EINVAL;
 
-        free_and_replace(*hostname, normalized);
-
-        return 0;
+        return free_and_replace(*fqdn, normalized);
 }
 
-static int lease_parse_captive_portal(const uint8_t *option, size_t len, char **ret) {
-        _cleanup_free_ char *uri = NULL;
+static int lease_parse_captive_portal(const uint8_t *option, size_t len, char **uri) {
+        _cleanup_free_ char *s = NULL;
         int r;
 
         assert(option);
-        assert(ret);
+        assert(uri);
 
-        r = dhcp_option_parse_string(option, len, &uri);
+        r = dhcp_option_parse_string(option, len, &s);
         if (r < 0)
                 return r;
-        if (uri && !in_charset(uri, URI_VALID))
+        if (s && !in_charset(s, URI_VALID))
                 return -EINVAL;
 
-        return free_and_replace(*ret, uri);
+        return free_and_replace(*uri, s);
 }
 
-static int lease_parse_in_addrs(const uint8_t *option, size_t len, struct in_addr **ret, size_t *n_ret) {
+static int lease_parse_in_addrs(const uint8_t *option, size_t len, struct in_addr **addresses, size_t *n_addresses) {
         assert(option || len == 0);
-        assert(ret);
-        assert(n_ret);
+        assert(addresses);
+        assert(n_addresses);
 
         if (len <= 0) {
-                *ret = mfree(*ret);
-                *n_ret = 0;
-        } else {
-                size_t n_addresses;
-                struct in_addr *addresses;
-
-                if (len % 4 != 0)
-                        return -EINVAL;
-
-                n_addresses = len / 4;
+                *n_addresses = 0;
+                *addresses = mfree(*addresses);
+                return 0;
+        }
 
-                addresses = newdup(struct in_addr, option, n_addresses);
-                if (!addresses)
-                        return -ENOMEM;
+        if (len % 4 != 0)
+                return -EINVAL;
 
-                free_and_replace(*ret, addresses);
-                *n_ret = n_addresses;
-        }
+        size_t n = len / 4;
+        struct in_addr *a = newdup(struct in_addr, option, n);
+        if (!a)
+                return -ENOMEM;
 
-        return 0;
+        *n_addresses = n;
+        return free_and_replace(*addresses, a);
 }
 
-static int lease_parse_sip_server(const uint8_t *option, size_t len, struct in_addr **ret, size_t *n_ret) {
+static int lease_parse_sip_server(const uint8_t *option, size_t len, struct in_addr **sips, size_t *n_sips) {
         assert(option || len == 0);
-        assert(ret);
-        assert(n_ret);
+        assert(sips);
+        assert(n_sips);
 
         if (len <= 0)
                 return -EINVAL;
@@ -616,12 +607,12 @@ static int lease_parse_sip_server(const uint8_t *option, size_t len, struct in_a
          * the other fields */
 
         if (option[0] != 1) { /* We only support IP address encoding for now */
-                *ret = mfree(*ret);
-                *n_ret = 0;
+                *sips = mfree(*sips);
+                *n_sips = 0;
                 return 0;
         }
 
-        return lease_parse_in_addrs(option + 1, len - 1, ret, n_ret);
+        return lease_parse_in_addrs(option + 1, len - 1, sips, n_sips);
 }
 
 static int lease_parse_dns_name(const uint8_t *optval, size_t optlen, char **ret) {
@@ -641,14 +632,15 @@ static int lease_parse_dns_name(const uint8_t *optval, size_t optlen, char **ret
         return r;
 }
 
-static int lease_parse_dnr(const uint8_t *option, size_t len, sd_dns_resolver **ret_dnr, size_t *ret_n_dnr) {
+static int lease_parse_dnr(const uint8_t *option, size_t len, sd_dns_resolver **dnr, size_t *n_dnr) {
         int r;
         sd_dns_resolver *res_list = NULL;
         size_t n_resolvers = 0;
         CLEANUP_ARRAY(res_list, n_resolvers, dns_resolver_done_many);
 
         assert(option || len == 0);
-        assert(ret_dnr);
+        assert(dnr);
+        assert(n_dnr);
 
         _cleanup_(sd_dns_resolver_done) sd_dns_resolver res = {};
 
@@ -747,11 +739,11 @@ static int lease_parse_dnr(const uint8_t *option, size_t len, sd_dns_resolver **
                 res_list[n_resolvers++] = TAKE_STRUCT(res);
         }
 
-        typesafe_qsort(*ret_dnr, *ret_n_dnr, dns_resolver_prio_compare);
+        typesafe_qsort(res_list, n_resolvers, dns_resolver_prio_compare);
 
-        dns_resolver_done_many(*ret_dnr, *ret_n_dnr);
-        *ret_dnr = TAKE_PTR(res_list);
-        *ret_n_dnr = n_resolvers;
+        dns_resolver_done_many(*dnr, *n_dnr);
+        *dnr = TAKE_PTR(res_list);
+        *n_dnr = n_resolvers;
 
         return n_resolvers;
 }