From a43f92252600599045c2309b8e839ebf0c39a614 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 19 Oct 2023 23:57:44 +0900 Subject: 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. --- src/libsystemd-network/sd-dhcp-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libsystemd-network/sd-dhcp-client.c') diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c index bc73e87b95..6c08d28962 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) -- cgit v1.2.3