mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 23:23:52 +01:00
ratbagd: remove ratbagd_device_list()
This is no longer needed. Use the device-iterator in ratbagd.c directly and then drop ratbagd_device_list(). Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
This commit is contained in:
@@ -366,32 +366,3 @@ struct ratbagd_device *ratbagd_device_next(struct ratbagd_device *device)
|
||||
node = rbnode_next(&device->node);
|
||||
return node ? ratbagd_device_from_node(node) : NULL;
|
||||
}
|
||||
|
||||
int ratbagd_device_list(struct ratbagd *ctx, char ***paths)
|
||||
{
|
||||
struct ratbagd_device *device;
|
||||
char **devices, **pos;
|
||||
|
||||
devices = calloc(ctx->n_devices + 1, sizeof(char *));
|
||||
if (!devices)
|
||||
return -ENOMEM;
|
||||
|
||||
pos = devices;
|
||||
|
||||
RATBAGD_DEVICE_FOREACH(device, ctx) {
|
||||
*pos = strdup(device->path);
|
||||
if (!*pos)
|
||||
goto error;
|
||||
++pos;
|
||||
}
|
||||
|
||||
*pos = NULL;
|
||||
*paths = devices;
|
||||
return 1;
|
||||
|
||||
error:
|
||||
for (pos = devices; *pos; ++pos)
|
||||
free(*pos);
|
||||
free(devices);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
@@ -67,10 +67,31 @@ static int ratbagd_list_devices(sd_bus *bus,
|
||||
sd_bus_error *error)
|
||||
{
|
||||
struct ratbagd *ctx = userdata;
|
||||
int r;
|
||||
struct ratbagd_device *device;
|
||||
char **devices, **pos;
|
||||
|
||||
r = ratbagd_device_list(ctx, paths);
|
||||
return r < 0 ? r : 1;
|
||||
devices = calloc(ctx->n_devices + 1, sizeof(char *));
|
||||
if (!devices)
|
||||
return -ENOMEM;
|
||||
|
||||
pos = devices;
|
||||
|
||||
RATBAGD_DEVICE_FOREACH(device, ctx) {
|
||||
*pos = strdup(ratbagd_device_get_path(device));
|
||||
if (!*pos)
|
||||
goto error;
|
||||
++pos;
|
||||
}
|
||||
|
||||
*pos = NULL;
|
||||
*paths = devices;
|
||||
return 1;
|
||||
|
||||
error:
|
||||
for (pos = devices; *pos; ++pos)
|
||||
free(*pos);
|
||||
free(devices);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
static void ratbagd_process_device(struct ratbagd *ctx,
|
||||
|
||||
@@ -76,7 +76,6 @@ struct ratbagd_device *ratbagd_device_lookup(struct ratbagd *ctx,
|
||||
const char *name);
|
||||
struct ratbagd_device *ratbagd_device_first(struct ratbagd *ctx);
|
||||
struct ratbagd_device *ratbagd_device_next(struct ratbagd_device *device);
|
||||
int ratbagd_device_list(struct ratbagd *ctx, char ***paths);
|
||||
|
||||
#define RATBAGD_DEVICE_FOREACH(_device, _ctx) \
|
||||
for ((_device) = ratbagd_device_first(_ctx); \
|
||||
|
||||
Reference in New Issue
Block a user