tree-wide: Remove strv_from_stdarg_alloca()

It's trivial to replace all uses of this function with STRV_MAKE()
and strv_new_ap() so let's get rid of this variant.
This commit is contained in:
Daan De Meyer
2025-05-06 17:40:01 +02:00
parent c0239e5f11
commit 38c9ca5380
26 changed files with 89 additions and 147 deletions
+3 -6
View File
@@ -72,9 +72,8 @@ static int property_get_leases(
return sd_bus_message_close_container(reply);
}
static int dhcp_server_emit_changed(Link *link, const char *property, ...) {
static int dhcp_server_emit_changed_strv(Link *link, char **properties) {
_cleanup_free_ char *path = NULL;
char **l;
assert(link);
@@ -85,20 +84,18 @@ static int dhcp_server_emit_changed(Link *link, const char *property, ...) {
if (!path)
return log_oom();
l = strv_from_stdarg_alloca(property);
return sd_bus_emit_properties_changed_strv(
link->manager->bus,
path,
"org.freedesktop.network1.DHCPServer",
l);
properties);
}
void dhcp_server_callback(sd_dhcp_server *s, uint64_t event, void *data) {
Link *l = ASSERT_PTR(data);
if (event & SD_DHCP_SERVER_EVENT_LEASE_CHANGED)
(void) dhcp_server_emit_changed(l, "Leases", NULL);
(void) dhcp_server_emit_changed_strv(l, STRV_MAKE("Leases"));
}
static const sd_bus_vtable dhcp_server_vtable[] = {
+3 -6
View File
@@ -33,9 +33,8 @@ static int property_get_dhcp_client_state(
return sd_bus_message_append(reply, "s", dhcp_state_to_string(dhcp_client_get_state(c)));
}
static int dhcp_client_emit_changed(Link *link, const char *property, ...) {
static int dhcp_client_emit_changed(Link *link, char **properties) {
_cleanup_free_ char *path = NULL;
char **l;
assert(link);
@@ -46,19 +45,17 @@ static int dhcp_client_emit_changed(Link *link, const char *property, ...) {
if (!path)
return log_oom();
l = strv_from_stdarg_alloca(property);
return sd_bus_emit_properties_changed_strv(
link->manager->bus,
path,
"org.freedesktop.network1.DHCPv4Client",
l);
properties);
}
int dhcp_client_callback_bus(sd_dhcp_client *c, int event, void *userdata) {
Link *l = ASSERT_PTR(userdata);
return dhcp_client_emit_changed(l, "State", NULL);
return dhcp_client_emit_changed(l, STRV_MAKE("State"));
}
static const sd_bus_vtable dhcp_client_vtable[] = {
+3 -6
View File
@@ -32,9 +32,8 @@ static int property_get_dhcp6_client_state(
return sd_bus_message_append(reply, "s", dhcp6_state_to_string(dhcp6_client_get_state(c)));
}
static int dhcp6_client_emit_changed(Link *link, const char *property, ...) {
static int dhcp6_client_emit_changed_strv(Link *link, char **properties) {
_cleanup_free_ char *path = NULL;
char **l;
assert(link);
@@ -45,19 +44,17 @@ static int dhcp6_client_emit_changed(Link *link, const char *property, ...) {
if (!path)
return log_oom();
l = strv_from_stdarg_alloca(property);
return sd_bus_emit_properties_changed_strv(
link->manager->bus,
path,
"org.freedesktop.network1.DHCPv6Client",
l);
properties);
}
void dhcp6_client_callback_bus(sd_dhcp6_client *c, int event, void *userdata) {
Link *l = ASSERT_PTR(userdata);
dhcp6_client_emit_changed(l, "State", NULL);
dhcp6_client_emit_changed_strv(l, STRV_MAKE("State"));
}
static const sd_bus_vtable dhcp6_client_vtable[] = {
-8
View File
@@ -902,14 +902,6 @@ int link_send_changed_strv(Link *link, char **properties) {
properties);
}
int link_send_changed(Link *link, const char *property, ...) {
char **properties;
properties = strv_from_stdarg_alloca(property);
return link_send_changed_strv(link, properties);
}
const BusObjectImplementation link_object = {
"/org/freedesktop/network1/link",
"org.freedesktop.network1.Link",
+1 -1
View File
@@ -14,7 +14,7 @@ char* link_bus_path(Link *link);
int link_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error);
int link_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error);
int link_send_changed_strv(Link *link, char **properties);
int link_send_changed(Link *link, const char *property, ...) _sentinel_;
#define link_send_changed(link, ...) link_send_changed_strv(link, STRV_MAKE(__VA_ARGS__));
int property_get_operational_state(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
int property_get_carrier_state(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
+1 -1
View File
@@ -381,7 +381,7 @@ void link_set_state(Link *link, LinkState state) {
link->state = state;
link_send_changed(link, "AdministrativeState", NULL);
link_send_changed(link, "AdministrativeState");
link_dirty(link);
}