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 <milky-zfs@mcmilk.de>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14612
This commit is contained in:
Richard Yao
2023-03-11 13:39:24 -05:00
committed by Brian Behlendorf
parent 50f6934b9c
commit d1807f168e
72 changed files with 442 additions and 402 deletions
+6 -6
View File
@@ -402,10 +402,10 @@ fnvlist_lookup_uint64(const nvlist_t *nvl, const char *name)
return (rv);
}
char *
fnvlist_lookup_string(nvlist_t *nvl, const char *name)
const char *
fnvlist_lookup_string(const nvlist_t *nvl, const char *name)
{
char *rv;
const char *rv;
VERIFY0(nvlist_lookup_string(nvl, name, &rv));
return (rv);
}
@@ -577,10 +577,10 @@ fnvpair_value_uint64(const nvpair_t *nvp)
return (rv);
}
char *
fnvpair_value_string(nvpair_t *nvp)
const char *
fnvpair_value_string(const nvpair_t *nvp)
{
char *rv;
const char *rv;
VERIFY0(nvpair_value_string(nvp, &rv));
return (rv);
}