mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-26 12:12:13 +03:00
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:
committed by
Brian Behlendorf
parent
50f6934b9c
commit
d1807f168e
@@ -134,7 +134,7 @@ nvlist_print_json(FILE *fp, nvlist_t *nvl)
|
||||
|
||||
switch (type) {
|
||||
case DATA_TYPE_STRING: {
|
||||
char *string = fnvpair_value_string(curr);
|
||||
const char *string = fnvpair_value_string(curr);
|
||||
if (nvlist_print_json_string(fp, string) == -1)
|
||||
return (-1);
|
||||
break;
|
||||
@@ -220,7 +220,7 @@ nvlist_print_json(FILE *fp, nvlist_t *nvl)
|
||||
}
|
||||
|
||||
case DATA_TYPE_STRING_ARRAY: {
|
||||
char **val;
|
||||
const char **val;
|
||||
uint_t valsz, i;
|
||||
VERIFY0(nvpair_value_string_array(curr, &val, &valsz));
|
||||
FPRINTF(fp, "[");
|
||||
|
||||
Reference in New Issue
Block a user