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.
This commit is contained in:
Yu Watanabe 2024-04-10 04:03:46 +09:00 committed by Luca Boccassi
parent 6dfaa0edaf
commit 8e91738fe9
4 changed files with 8 additions and 4 deletions

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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;
}