tree-wide: rename unref_and_replace_full to unref_and_replace_new_ref

We have a number of *_unref_and_replace macros. One could think that
they are like the various free_and_replace variants, but they actually
create a new ref to the passed object. The free_and_replace variants
take ownership of the argument. This inconsistency is surprising. Rename
all those functions to have "_new_ref" at the end to make the difference
clear.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-05-08 11:14:13 +02:00
parent 174f6f3595
commit 62a489fbf9
10 changed files with 21 additions and 21 deletions
+1 -1
View File
@@ -364,7 +364,7 @@ static int dhcp6_lease_information_acquired(sd_dhcp6_client *client, Link *link)
if (r < 0)
return log_link_error_errno(link, r, "Failed to get DHCPv6 lease: %m");
unref_and_replace_full(link->dhcp6_lease, lease, sd_dhcp6_lease_ref, sd_dhcp6_lease_unref);
unref_and_replace_new_ref(link->dhcp6_lease, lease, sd_dhcp6_lease_ref, sd_dhcp6_lease_unref);
link_dirty(link);
return 0;
+1 -1
View File
@@ -1678,7 +1678,7 @@ static int link_initialized(Link *link, sd_device *device) {
/* Always replace with the new sd_device object. As the sysname (and possibly other properties
* or sysattrs) may be outdated. */
device_unref_and_replace(link->dev, device);
device_unref_and_replace_new_ref(link->dev, device);
r = link_managed_by_us(link);
if (r <= 0)
+2 -2
View File
@@ -469,7 +469,7 @@ int manager_udev_process_wiphy(Manager *m, sd_device *device, sd_device_action_t
return 0;
}
return device_unref_and_replace(w->dev, action == SD_DEVICE_REMOVE ? NULL : device);
return device_unref_and_replace_new_ref(w->dev, action == SD_DEVICE_REMOVE ? NULL : device);
}
int manager_udev_process_rfkill(Manager *m, sd_device *device, sd_device_action_t action) {
@@ -501,5 +501,5 @@ int manager_udev_process_rfkill(Manager *m, sd_device *device, sd_device_action_
return 0;
}
return device_unref_and_replace(w->rfkill, action == SD_DEVICE_REMOVE ? NULL : device);
return device_unref_and_replace_new_ref(w->rfkill, action == SD_DEVICE_REMOVE ? NULL : device);
}