From 4bbe559b5c06387a56cb765076790a4bd47d0e82 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 30 Nov 2022 10:22:39 +0900 Subject: [PATCH] network: address: use ASSERT_PTR() --- src/network/networkd-address.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index e6db72f4f46..eae374323e9 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -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"); -- 2.47.3