]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: address: use ASSERT_PTR() 25568/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 30 Nov 2022 01:22:39 +0000 (10:22 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 30 Nov 2022 01:23:58 +0000 (10:23 +0900)
src/network/networkd-address.c

index e6db72f4f467557bea6bfa25257c3fcc24e97791..eae374323e9352e931ef556b7d832a70d571eb06 100644 (file)
@@ -462,14 +462,9 @@ static int address_add(Link *link, Address *address) {
 }
 
 static int address_update(Address *address) {
-        Link *link;
+        Link *link = ASSERT_PTR(ASSERT_PTR(address)->link);
         int r;
 
-        assert(address);
-        assert(address->link);
-
-        link = address->link;
-
         if (address_is_ready(address) &&
             address->family == AF_INET6 &&
             in6_addr_is_link_local(&address->in_addr.in6) &&
@@ -485,7 +480,7 @@ static int address_update(Address *address) {
         if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER))
                 return 0;
 
-        r = address_set_masquerade(address, true);
+        r = address_set_masquerade(address, /* add = */ true);
         if (r < 0)
                 return log_link_warning_errno(link, r, "Could not enable IP masquerading: %m");
 
@@ -497,21 +492,16 @@ static int address_update(Address *address) {
                         return r;
         }
 
-        link_update_operstate(link, true);
+        link_update_operstate(link, /* also_update_master = */ true);
         link_check_ready(link);
         return 0;
 }
 
 static int address_drop(Address *address) {
-        Link *link;
+        Link *link = ASSERT_PTR(ASSERT_PTR(address)->link);
         int r;
 
-        assert(address);
-        assert(address->link);
-
-        link = address->link;
-
-        r = address_set_masquerade(address, false);
+        r = address_set_masquerade(address, /* add = */ false);
         if (r < 0)
                 log_link_warning_errno(link, r, "Failed to disable IP masquerading, ignoring: %m");