From 9b2f9d64c04ed967d8c1780b435b0d200d444fa5 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 3 May 2024 23:05:40 +0200 Subject: [PATCH] libdm: ensure suffixes list elements are const This was rather API mistake - the internal of libdm do handle suffixes list as const string, just the API was only using 'const char **'. So the user may pass safely casted 'const char * const`. --- device_mapper/libdm-deptree.c | 4 ++-- libdm/libdm-deptree.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/device_mapper/libdm-deptree.c b/device_mapper/libdm-deptree.c index 448d6f418..5e0ddba5e 100644 --- a/device_mapper/libdm-deptree.c +++ b/device_mapper/libdm-deptree.c @@ -348,7 +348,7 @@ struct dm_tree { int retry_remove; /* 1 retries remove if not successful */ uint32_t cookie; char buf[DM_NAME_LEN + 32]; /* print buffer for device_name (major:minor) */ - const char **optional_uuid_suffixes; /* uuid suffixes ignored when matching */ + const char * const *optional_uuid_suffixes; /* uuid suffixes ignored when matching */ }; /* @@ -600,7 +600,7 @@ static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree, const char *suffix, *suffix_position; char uuid_without_suffix[DM_UUID_LEN + 1]; unsigned i = 0; - const char **suffix_list = dtree->optional_uuid_suffixes; + const char * const *suffix_list = dtree->optional_uuid_suffixes; if ((node = dm_hash_lookup(dtree->uuids, uuid))) { log_debug_activation("Matched uuid %s %s in deptree.", uuid, _node_name(node)); diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c index 4ed1d7467..ca526e6f6 100644 --- a/libdm/libdm-deptree.c +++ b/libdm/libdm-deptree.c @@ -308,7 +308,7 @@ struct dm_tree { int retry_remove; /* 1 retries remove if not successful */ uint32_t cookie; char buf[DM_NAME_LEN + 32]; /* print buffer for device_name (major:minor) */ - const char **optional_uuid_suffixes; /* uuid suffixes ignored when matching */ + const char * const *optional_uuid_suffixes; /* uuid suffixes ignored when matching */ }; /* @@ -560,7 +560,7 @@ static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree, const char *suffix, *suffix_position; char uuid_without_suffix[DM_UUID_LEN + 1]; unsigned i = 0; - const char **suffix_list = dtree->optional_uuid_suffixes; + const char * const *suffix_list = dtree->optional_uuid_suffixes; if ((node = dm_hash_lookup(dtree->uuids, uuid))) { log_debug_activation("Matched uuid %s %s in deptree.", uuid, _node_name(node));