diff options
author | Richard Yao <[email protected]> | 2023-03-11 13:39:24 -0500 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2023-03-14 15:25:50 -0700 |
commit | d1807f168edd09ca26a5a0c6b570686b982808ad (patch) | |
tree | db5bfd360991fa3528fe688247eb289ef1d8b859 /include/libnvpair.h | |
parent | 50f6934b9c1f4aa583592e8a969b934440a44c64 (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 'include/libnvpair.h')
-rw-r--r-- | include/libnvpair.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/include/libnvpair.h b/include/libnvpair.h index 738afaec7..09b224b4d 100644 --- a/include/libnvpair.h +++ b/include/libnvpair.h @@ -42,9 +42,10 @@ extern "C" { * are all imported from <sys/nvpair.h> included above. */ -_LIBNVPAIR_H int nvpair_value_match(nvpair_t *, int, char *, char **); -_LIBNVPAIR_H int nvpair_value_match_regex(nvpair_t *, int, char *, regex_t *, - char **); +_LIBNVPAIR_H int nvpair_value_match(nvpair_t *, int, const char *, + const char **); +_LIBNVPAIR_H int nvpair_value_match_regex(nvpair_t *, int, const char *, + regex_t *, const char **); _LIBNVPAIR_H void nvlist_print(FILE *, nvlist_t *); _LIBNVPAIR_H int nvlist_print_json(FILE *, nvlist_t *); @@ -156,7 +157,7 @@ NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_uint32, uint32_t); NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_int64, int64_t); NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_uint64, uint64_t); NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_double, double); -NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_string, char *); +NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_string, const char *); NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_hrtime, hrtime_t); NVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_nvlist, nvlist_t *); @@ -185,7 +186,7 @@ NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_int32_array, int32_t *); NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_uint32_array, uint32_t *); NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_int64_array, int64_t *); NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_uint64_array, uint64_t *); -NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_string_array, char **); +NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_string_array, const char **); NVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_nvlist_array, nvlist_t **); #undef NVLIST_PRINTCTL_AVDECL /* was just for "clarity" above */ |