mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +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
+5
-4
@@ -65,7 +65,7 @@ show_vdev_stats(const char *desc, const char *ctype, nvlist_t *nv, int indent)
|
||||
|
||||
if (desc != NULL) {
|
||||
const char *suffix = "";
|
||||
char *bias = NULL;
|
||||
const char *bias = NULL;
|
||||
char bias_suffix[32];
|
||||
|
||||
(void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_IS_LOG, &is_log);
|
||||
@@ -113,12 +113,13 @@ show_vdev_stats(const char *desc, const char *ctype, nvlist_t *nv, int indent)
|
||||
|
||||
for (c = 0; c < children; c++) {
|
||||
nvlist_t *cnv = child[c];
|
||||
char *cname = NULL, *tname;
|
||||
const char *cname = NULL;
|
||||
char *tname;
|
||||
uint64_t np;
|
||||
int len;
|
||||
if (nvlist_lookup_string(cnv, ZPOOL_CONFIG_PATH, &cname) &&
|
||||
nvlist_lookup_string(cnv, ZPOOL_CONFIG_TYPE, &cname))
|
||||
cname = (char *)"<unknown>";
|
||||
cname = "<unknown>";
|
||||
len = strlen(cname) + 2;
|
||||
tname = umem_zalloc(len, UMEM_NOFAIL);
|
||||
(void) strlcpy(tname, cname, len);
|
||||
@@ -133,7 +134,7 @@ void
|
||||
show_pool_stats(spa_t *spa)
|
||||
{
|
||||
nvlist_t *config, *nvroot;
|
||||
char *name;
|
||||
const char *name;
|
||||
|
||||
VERIFY(spa_get_stats(spa_name(spa), &config, NULL, 0) == 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user