From: Yu Watanabe Date: Tue, 9 Apr 2024 19:03:46 +0000 (+0900) Subject: libsystemd-network: do not trigger assertion by sd_*_is_running() with NULL X-Git-Tag: v256-rc1~234 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e91738fe9816e41ffc4da1231557d9db1be6e93;p=thirdparty%2Fsystemd.git libsystemd-network: do not trigger assertion by sd_*_is_running() with NULL If systemd is built with developer mode, previously they trigger hard assertions. Even built with release mode, we should not log about that. Let's silently accept NULL and return false. Prompted by https://github.com/systemd/systemd/pull/32166#issuecomment-2044710151. --- diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c index 5a26102e232..229ceef7836 100644 --- a/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/libsystemd-network/sd-dhcp6-client.c @@ -1417,7 +1417,8 @@ int sd_dhcp6_client_stop(sd_dhcp6_client *client) { } int sd_dhcp6_client_is_running(sd_dhcp6_client *client) { - assert_return(client, -EINVAL); + if (!client) + return false; return client->state != DHCP6_STATE_STOPPED; } diff --git a/src/libsystemd-network/sd-ipv4acd.c b/src/libsystemd-network/sd-ipv4acd.c index 1a9a8f10ab6..51d2b2219dd 100644 --- a/src/libsystemd-network/sd-ipv4acd.c +++ b/src/libsystemd-network/sd-ipv4acd.c @@ -564,7 +564,8 @@ int sd_ipv4acd_get_address(sd_ipv4acd *acd, struct in_addr *address) { } int sd_ipv4acd_is_running(sd_ipv4acd *acd) { - assert_return(acd, false); + if (!acd) + return false; return acd->state != IPV4ACD_STATE_INIT; } diff --git a/src/libsystemd-network/sd-ipv4ll.c b/src/libsystemd-network/sd-ipv4ll.c index a29279e6afc..5bf98332a9f 100644 --- a/src/libsystemd-network/sd-ipv4ll.c +++ b/src/libsystemd-network/sd-ipv4ll.c @@ -206,7 +206,8 @@ int sd_ipv4ll_set_address_seed(sd_ipv4ll *ll, uint64_t seed) { } int sd_ipv4ll_is_running(sd_ipv4ll *ll) { - assert_return(ll, false); + if (!ll) + return false; return sd_ipv4acd_is_running(ll->acd); } diff --git a/src/libsystemd-network/sd-radv.c b/src/libsystemd-network/sd-radv.c index 71e7a718970..cde45388b7c 100644 --- a/src/libsystemd-network/sd-radv.c +++ b/src/libsystemd-network/sd-radv.c @@ -81,7 +81,8 @@ sd_event *sd_radv_get_event(sd_radv *ra) { } int sd_radv_is_running(sd_radv *ra) { - assert_return(ra, false); + if (!ra) + return false; return ra->state != RADV_STATE_IDLE; }