]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/address: use config_parse_in_addr_non_null() at one more place 34749/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 13 Oct 2024 06:17:07 +0000 (15:17 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 13 Oct 2024 23:10:35 +0000 (08:10 +0900)
No functional change, just refactoring.

src/network/networkd-address.c

index 228cb93fc823ea561d61fa44b497410ecab31136..0e06149f33c1f6f1a96f5b9536e9117a59c10475 100644 (file)
@@ -2030,7 +2030,6 @@ static int config_parse_broadcast(
                 void *userdata) {
 
         Address *address = ASSERT_PTR(userdata);
-        union in_addr_union u;
         int r;
 
         /* Do not check or set address->family here. It will be checked later in
@@ -2052,16 +2051,13 @@ static int config_parse_broadcast(
                 return 1;
         }
 
-        r = in_addr_from_string(AF_INET, rvalue, &u);
-        if (r < 0)
-                return log_syntax_parse_error(unit, filename, line, r, lvalue, rvalue);
-        if (in4_addr_is_null(&u.in)) {
-                log_syntax(unit, LOG_WARNING, filename, line, 0,
-                           "Broadcast cannot be ANY address, ignoring assignment: %s", rvalue);
-                return 0;
-        }
+        r = config_parse_in_addr_non_null(
+                        unit, filename, line, section, section_line,
+                        lvalue, /* ltype = */ AF_INET, rvalue,
+                        &address->broadcast, /* userdata = */ NULL);
+        if (r <= 0)
+                return r;
 
-        address->broadcast = u.in;
         address->set_broadcast = true;
         return 1;
 }