From: Yu Watanabe Date: Wed, 14 Oct 2020 22:24:17 +0000 (+0900) Subject: libsystemd-network: do not request each daemon exist in sd_xxx_stop() X-Git-Tag: v247-rc1~28^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c8bae3637212daad992323d4b2a253c3949c9777;p=thirdparty%2Fsystemd.git libsystemd-network: do not request each daemon exist in sd_xxx_stop() --- diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c index 6eb3c1b7a0c..53c43508749 100644 --- a/src/libsystemd-network/sd-dhcp-client.c +++ b/src/libsystemd-network/sd-dhcp-client.c @@ -2135,9 +2135,10 @@ int sd_dhcp_client_send_decline(sd_dhcp_client *client) { } int sd_dhcp_client_stop(sd_dhcp_client *client) { - DHCP_CLIENT_DONT_DESTROY(client); + if (!client) + return 0; - assert_return(client, -EINVAL); + DHCP_CLIENT_DONT_DESTROY(client); client_stop(client, SD_DHCP_CLIENT_EVENT_STOP); client->state = DHCP_STATE_STOPPED; diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c index a34a55919e2..9022aefccb2 100644 --- a/src/libsystemd-network/sd-dhcp-server.c +++ b/src/libsystemd-network/sd-dhcp-server.c @@ -225,7 +225,8 @@ sd_event *sd_dhcp_server_get_event(sd_dhcp_server *server) { } int sd_dhcp_server_stop(sd_dhcp_server *server) { - assert_return(server, -EINVAL); + if (!server) + return 0; server->receive_message = sd_event_source_unref(server->receive_message); diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c index e1dbdaff4e7..6d27c4685ed 100644 --- a/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/libsystemd-network/sd-dhcp6-client.c @@ -1676,7 +1676,8 @@ static int client_start(sd_dhcp6_client *client, enum DHCP6State state) { } int sd_dhcp6_client_stop(sd_dhcp6_client *client) { - assert_return(client, -EINVAL); + if (!client) + return 0; client_stop(client, SD_DHCP6_CLIENT_EVENT_STOP); diff --git a/src/libsystemd-network/sd-ipv4acd.c b/src/libsystemd-network/sd-ipv4acd.c index ecd91cd927c..ff333914e90 100644 --- a/src/libsystemd-network/sd-ipv4acd.c +++ b/src/libsystemd-network/sd-ipv4acd.c @@ -144,7 +144,8 @@ static void ipv4acd_client_notify(sd_ipv4acd *acd, int event) { int sd_ipv4acd_stop(sd_ipv4acd *acd) { IPv4ACDState old_state; - assert_return(acd, -EINVAL); + if (!acd) + return 0; old_state = acd->state; diff --git a/src/libsystemd-network/sd-ipv4ll.c b/src/libsystemd-network/sd-ipv4ll.c index 4f4d9ebe877..293a4644a23 100644 --- a/src/libsystemd-network/sd-ipv4ll.c +++ b/src/libsystemd-network/sd-ipv4ll.c @@ -89,7 +89,8 @@ int sd_ipv4ll_new(sd_ipv4ll **ret) { } int sd_ipv4ll_stop(sd_ipv4ll *ll) { - assert_return(ll, -EINVAL); + if (!ll) + return 0; return sd_ipv4acd_stop(ll->acd); } diff --git a/src/libsystemd-network/sd-lldp.c b/src/libsystemd-network/sd-lldp.c index b0a11fe20b6..e536f90d194 100644 --- a/src/libsystemd-network/sd-lldp.c +++ b/src/libsystemd-network/sd-lldp.c @@ -276,7 +276,8 @@ fail: } _public_ int sd_lldp_stop(sd_lldp *lldp) { - assert_return(lldp, -EINVAL); + if (!lldp) + return 0; if (lldp->fd < 0) return 0; diff --git a/src/libsystemd-network/sd-ndisc.c b/src/libsystemd-network/sd-ndisc.c index 9922203ac4b..92e772d352f 100644 --- a/src/libsystemd-network/sd-ndisc.c +++ b/src/libsystemd-network/sd-ndisc.c @@ -321,7 +321,8 @@ static int ndisc_timeout_no_ra(sd_event_source *s, uint64_t usec, void *userdata } _public_ int sd_ndisc_stop(sd_ndisc *nd) { - assert_return(nd, -EINVAL); + if (!nd) + return 0; if (nd->fd < 0) return 0; diff --git a/src/libsystemd-network/sd-radv.c b/src/libsystemd-network/sd-radv.c index 016808667cf..9656d7c969c 100644 --- a/src/libsystemd-network/sd-radv.c +++ b/src/libsystemd-network/sd-radv.c @@ -353,7 +353,8 @@ fail: _public_ int sd_radv_stop(sd_radv *ra) { int r; - assert_return(ra, -EINVAL); + if (!ra) + return 0; if (ra->state == SD_RADV_STATE_IDLE) return 0;