mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 03:08:51 +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
+18
-19
@@ -727,11 +727,11 @@ vdev_alloc(spa_t *spa, vdev_t **vdp, nvlist_t *nv, vdev_t *parent, uint_t id,
|
||||
int alloctype)
|
||||
{
|
||||
vdev_ops_t *ops;
|
||||
char *type;
|
||||
const char *type;
|
||||
uint64_t guid = 0, islog;
|
||||
vdev_t *vd;
|
||||
vdev_indirect_config_t *vic;
|
||||
char *tmp = NULL;
|
||||
const char *tmp = NULL;
|
||||
int rc;
|
||||
vdev_alloc_bias_t alloc_bias = VDEV_BIAS_NONE;
|
||||
boolean_t top_level = (parent && !parent->vdev_parent);
|
||||
@@ -786,7 +786,7 @@ vdev_alloc(spa_t *spa, vdev_t **vdp, nvlist_t *nv, vdev_t *parent, uint_t id,
|
||||
return (SET_ERROR(ENOTSUP));
|
||||
|
||||
if (top_level && alloctype == VDEV_ALLOC_ADD) {
|
||||
char *bias;
|
||||
const char *bias;
|
||||
|
||||
/*
|
||||
* If creating a top-level vdev, check for allocation
|
||||
@@ -832,8 +832,8 @@ vdev_alloc(spa_t *spa, vdev_t **vdp, nvlist_t *nv, vdev_t *parent, uint_t id,
|
||||
if (top_level && alloc_bias != VDEV_BIAS_NONE)
|
||||
vd->vdev_alloc_bias = alloc_bias;
|
||||
|
||||
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &vd->vdev_path) == 0)
|
||||
vd->vdev_path = spa_strdup(vd->vdev_path);
|
||||
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &tmp) == 0)
|
||||
vd->vdev_path = spa_strdup(tmp);
|
||||
|
||||
/*
|
||||
* ZPOOL_CONFIG_AUX_STATE = "external" means we previously forced a
|
||||
@@ -847,18 +847,17 @@ vdev_alloc(spa_t *spa, vdev_t **vdp, nvlist_t *nv, vdev_t *parent, uint_t id,
|
||||
vd->vdev_label_aux = VDEV_AUX_EXTERNAL;
|
||||
}
|
||||
|
||||
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_DEVID, &vd->vdev_devid) == 0)
|
||||
vd->vdev_devid = spa_strdup(vd->vdev_devid);
|
||||
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PHYS_PATH,
|
||||
&vd->vdev_physpath) == 0)
|
||||
vd->vdev_physpath = spa_strdup(vd->vdev_physpath);
|
||||
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_DEVID, &tmp) == 0)
|
||||
vd->vdev_devid = spa_strdup(tmp);
|
||||
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PHYS_PATH, &tmp) == 0)
|
||||
vd->vdev_physpath = spa_strdup(tmp);
|
||||
|
||||
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH,
|
||||
&vd->vdev_enc_sysfs_path) == 0)
|
||||
vd->vdev_enc_sysfs_path = spa_strdup(vd->vdev_enc_sysfs_path);
|
||||
&tmp) == 0)
|
||||
vd->vdev_enc_sysfs_path = spa_strdup(tmp);
|
||||
|
||||
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_FRU, &vd->vdev_fru) == 0)
|
||||
vd->vdev_fru = spa_strdup(vd->vdev_fru);
|
||||
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_FRU, &tmp) == 0)
|
||||
vd->vdev_fru = spa_strdup(tmp);
|
||||
|
||||
/*
|
||||
* Set the whole_disk property. If it's not specified, leave the value
|
||||
@@ -989,7 +988,7 @@ vdev_alloc(spa_t *spa, vdev_t **vdp, nvlist_t *nv, vdev_t *parent, uint_t id,
|
||||
&vd->vdev_removed);
|
||||
|
||||
if (vd->vdev_faulted || vd->vdev_degraded) {
|
||||
char *aux;
|
||||
const char *aux;
|
||||
|
||||
vd->vdev_label_aux =
|
||||
VDEV_AUX_ERR_EXCEEDED;
|
||||
@@ -5624,7 +5623,7 @@ vdev_replace_in_progress(vdev_t *vdev)
|
||||
* Add a (source=src, propname=propval) list to an nvlist.
|
||||
*/
|
||||
static void
|
||||
vdev_prop_add_list(nvlist_t *nvl, const char *propname, char *strval,
|
||||
vdev_prop_add_list(nvlist_t *nvl, const char *propname, const char *strval,
|
||||
uint64_t intval, zprop_source_t src)
|
||||
{
|
||||
nvlist_t *propval;
|
||||
@@ -5664,7 +5663,7 @@ vdev_props_set_sync(void *arg, dmu_tx_t *tx)
|
||||
|
||||
while ((elem = nvlist_next_nvpair(nvprops, elem)) != NULL) {
|
||||
uint64_t intval, objid = 0;
|
||||
char *strval;
|
||||
const char *strval;
|
||||
vdev_prop_t prop;
|
||||
const char *propname = nvpair_name(elem);
|
||||
zprop_type_t proptype;
|
||||
@@ -5760,10 +5759,10 @@ vdev_prop_set(vdev_t *vd, nvlist_t *innvl, nvlist_t *outnvl)
|
||||
return (SET_ERROR(EINVAL));
|
||||
|
||||
while ((elem = nvlist_next_nvpair(nvprops, elem)) != NULL) {
|
||||
char *propname = nvpair_name(elem);
|
||||
const char *propname = nvpair_name(elem);
|
||||
vdev_prop_t prop = vdev_name_to_prop(propname);
|
||||
uint64_t intval = 0;
|
||||
char *strval = NULL;
|
||||
const char *strval = NULL;
|
||||
|
||||
if (prop == VDEV_PROP_USERPROP && !vdev_prop_user(propname)) {
|
||||
error = EINVAL;
|
||||
|
||||
Reference in New Issue
Block a user