sd-dhcp-client: avoid taking and dropping a reference
The helper would create a new ref, even though we had one handy and didn't need to create a new ref. So change the helper to take an existing reference.
This commit is contained in:
@@ -97,5 +97,5 @@ void dhcp_lease_set_timestamp(sd_dhcp_lease *lease, const triple_timestamp *time
|
||||
int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease);
|
||||
int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const sd_dhcp_client_id *client_id);
|
||||
|
||||
#define dhcp_lease_unref_and_replace_new_ref(a, b) \
|
||||
unref_and_replace_new_ref(a, b, sd_dhcp_lease_ref, sd_dhcp_lease_unref)
|
||||
#define dhcp_lease_unref_and_replace(a, b) \
|
||||
free_and_replace_full(a, b, sd_dhcp_lease_unref)
|
||||
|
||||
@@ -1594,7 +1594,7 @@ static int client_handle_offer_or_rapid_ack(sd_dhcp_client *client, DHCPMessage
|
||||
|
||||
dhcp_lease_set_timestamp(lease, timestamp);
|
||||
|
||||
dhcp_lease_unref_and_replace_new_ref(client->lease, lease);
|
||||
dhcp_lease_unref_and_replace(client->lease, lease);
|
||||
|
||||
if (client->lease->rapid_commit) {
|
||||
log_dhcp_client(client, "ACK");
|
||||
@@ -1678,7 +1678,7 @@ static int client_handle_ack(sd_dhcp_client *client, DHCPMessage *message, size_
|
||||
else
|
||||
r = SD_DHCP_CLIENT_EVENT_IP_CHANGE;
|
||||
|
||||
dhcp_lease_unref_and_replace_new_ref(client->lease, lease);
|
||||
dhcp_lease_unref_and_replace(client->lease, lease);
|
||||
|
||||
log_dhcp_client(client, "ACK");
|
||||
return r;
|
||||
|
||||
Reference in New Issue
Block a user