From: Yu Watanabe Date: Thu, 19 Oct 2023 14:57:44 +0000 (+0900) Subject: sd-dhcp-client: simplify the condition in sd_dhcp_client_get_lease() X-Git-Tag: v255-rc1~161^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a43f92252600599045c2309b8e839ebf0c39a614;p=thirdparty%2Fsystemd.git sd-dhcp-client: simplify the condition in sd_dhcp_client_get_lease() The condition was outdated, e.g. SELECTING state does not have a lease. See client_handle_offer() and client_enter_requesting(). The condition based on the state may become much complex in the future. Let's use simpler condition. --- diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c index bc73e87b95b..6c08d289622 100644 --- a/src/libsystemd-network/sd-dhcp-client.c +++ b/src/libsystemd-network/sd-dhcp-client.c @@ -709,7 +709,7 @@ int sd_dhcp_client_add_vendor_option(sd_dhcp_client *client, sd_dhcp_option *v) int sd_dhcp_client_get_lease(sd_dhcp_client *client, sd_dhcp_lease **ret) { assert_return(client, -EINVAL); - if (!IN_SET(client->state, DHCP_STATE_SELECTING, DHCP_STATE_BOUND, DHCP_STATE_RENEWING, DHCP_STATE_REBINDING)) + if (!client->lease) return -EADDRNOTAVAIL; if (ret)