aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRichard Yao <[email protected]>2023-03-11 13:39:24 -0500
committerBrian Behlendorf <[email protected]>2023-03-14 15:25:50 -0700
commitd1807f168edd09ca26a5a0c6b570686b982808ad (patch)
treedb5bfd360991fa3528fe688247eb289ef1d8b859 /tests
parent50f6934b9c1f4aa583592e8a969b934440a44c64 (diff)
nvpair: Constify string functions
After addressing coverity complaints involving `nvpair_name()`, the compiler started complaining about dropping const. This lead to a rabbit hole where not only `nvpair_name()` needed to be constified, but also `nvpair_value_string()`, `fnvpair_value_string()` and a few other static functions, plus variable pointers throughout the code. The result became a fairly big change, so it has been split out into its own patch. Reviewed-by: Tino Reichardt <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Richard Yao <[email protected]> Closes #14612
Diffstat (limited to 'tests')
-rw-r--r--tests/zfs-tests/cmd/draid.c2
-rw-r--r--tests/zfs-tests/cmd/ereports.c4
-rw-r--r--tests/zfs-tests/cmd/nvlist_to_lua.c2
3 files changed, 4 insertions, 4 deletions
diff --git a/tests/zfs-tests/cmd/draid.c b/tests/zfs-tests/cmd/draid.c
index 3e5ff59f7..fdcec7bc6 100644
--- a/tests/zfs-tests/cmd/draid.c
+++ b/tests/zfs-tests/cmd/draid.c
@@ -1267,7 +1267,7 @@ draid_merge_impl(nvlist_t *allcfgs, const char *srcfilename, int *mergedp)
uint64_t nv_worst_ratio;
uint64_t allcfg_worst_ratio;
nvlist_t *cfg, *allcfg;
- char *key;
+ const char *key;
switch (nvpair_type(elem)) {
case DATA_TYPE_NVLIST:
diff --git a/tests/zfs-tests/cmd/ereports.c b/tests/zfs-tests/cmd/ereports.c
index 392f5952d..42168997c 100644
--- a/tests/zfs-tests/cmd/ereports.c
+++ b/tests/zfs-tests/cmd/ereports.c
@@ -62,7 +62,7 @@ static const char *const criteria_name[] = {
static void
print_ereport_line(nvlist_t *nvl)
{
- char *class;
+ const char *class;
int last = CRITERIA_NAMES_COUNT - 1;
/*
@@ -81,7 +81,7 @@ print_ereport_line(nvlist_t *nvl)
nvpair_t *nvp;
uint32_t i32 = 0;
uint64_t i64 = 0;
- char *str = NULL;
+ const char *str = NULL;
if (nvlist_lookup_nvpair(nvl, criteria_name[i], &nvp) != 0) {
/* print a proxy for optional criteria */
diff --git a/tests/zfs-tests/cmd/nvlist_to_lua.c b/tests/zfs-tests/cmd/nvlist_to_lua.c
index 3da69397a..57a8f51e1 100644
--- a/tests/zfs-tests/cmd/nvlist_to_lua.c
+++ b/tests/zfs-tests/cmd/nvlist_to_lua.c
@@ -39,7 +39,7 @@ nvlist_equal(nvlist_t *nvla, nvlist_t *nvlb)
*/
for (nvpair_t *pair = nvlist_next_nvpair(nvla, NULL);
pair != NULL; pair = nvlist_next_nvpair(nvla, pair)) {
- char *key = nvpair_name(pair);
+ const char *key = nvpair_name(pair);
if (!nvlist_exists(nvlb, key))
return (B_FALSE);