summaryrefslogtreecommitdiff
path: root/tools/toollib.c
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2022-11-07 11:38:46 -0600
committerDavid Teigland <teigland@redhat.com>2022-11-07 11:38:46 -0600
commitc98617c593a84e32ff8ee32ecf2382d4e1369c16 (patch)
treed80a5cbc669aa87690015fbf28405cd9d6d1a579 /tools/toollib.c
parent761b922178c8522fd9abb207ba31bd27f9fa9dc4 (diff)
downloadlvm2-c98617c593a84e32ff8ee32ecf2382d4e1369c16.tar.gz
devices: factor common list functions
which were duplicated in various places
Diffstat (limited to 'tools/toollib.c')
-rw-r--r--tools/toollib.c34
1 files changed, 4 insertions, 30 deletions
diff --git a/tools/toollib.c b/tools/toollib.c
index 5305e811b..ae6f311ba 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -4133,32 +4133,6 @@ static int _get_arg_devices(struct cmd_context *cmd,
return ret_max;
}
-static int _device_list_remove(struct dm_list *devices, struct device *dev)
-{
- struct device_id_list *dil;
-
- dm_list_iterate_items(dil, devices) {
- if (dil->dev == dev) {
- dm_list_del(&dil->list);
- return 1;
- }
- }
-
- return 0;
-}
-
-static struct device_id_list *_device_list_find_dev(struct dm_list *devices, struct device *dev)
-{
- struct device_id_list *dil;
-
- dm_list_iterate_items(dil, devices) {
- if (dil->dev == dev)
- return dil;
- }
-
- return NULL;
-}
-
/* Process devices that are not PVs. */
static int _process_other_devices(struct cmd_context *cmd,
@@ -4263,8 +4237,8 @@ static int _process_duplicate_pvs(struct cmd_context *cmd,
dm_list_iterate_items(devl, &unused_duplicate_devs) {
/* Duplicates are displayed if -a is used or the dev is named as an arg. */
- if ((dil = _device_list_find_dev(arg_devices, devl->dev)))
- _device_list_remove(arg_devices, devl->dev);
+ if ((dil = device_id_list_find_dev(arg_devices, devl->dev)))
+ device_id_list_remove(arg_devices, devl->dev);
if (!process_other_devices && !dil)
continue;
@@ -4384,8 +4358,8 @@ static int _process_pvs_in_vg(struct cmd_context *cmd,
/* Remove each arg_devices entry as it is processed. */
if (arg_devices && !dm_list_empty(arg_devices)) {
- if ((dil = _device_list_find_dev(arg_devices, pv->dev)))
- _device_list_remove(arg_devices, dil->dev);
+ if ((dil = device_id_list_find_dev(arg_devices, pv->dev)))
+ device_id_list_remove(arg_devices, dil->dev);
}
if (!process_pv && dil)