aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs/spa.c
diff options
context:
space:
mode:
authorRichard Yao <[email protected]>2023-03-11 13:39:24 -0500
committerBrian Behlendorf <[email protected]>2023-03-14 15:25:50 -0700
commitd1807f168edd09ca26a5a0c6b570686b982808ad (patch)
treedb5bfd360991fa3528fe688247eb289ef1d8b859 /module/zfs/spa.c
parent50f6934b9c1f4aa583592e8a969b934440a44c64 (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 'module/zfs/spa.c')
-rw-r--r--module/zfs/spa.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/module/zfs/spa.c b/module/zfs/spa.c
index 98a302237..95b38f098 100644
--- a/module/zfs/spa.c
+++ b/module/zfs/spa.c
@@ -550,7 +550,7 @@ spa_prop_validate(spa_t *spa, nvlist_t *props)
elem = NULL;
while ((elem = nvlist_next_nvpair(props, elem)) != NULL) {
uint64_t intval;
- char *strval, *slash, *check, *fname;
+ const char *strval, *slash, *check, *fname;
const char *propname = nvpair_name(elem);
zpool_prop_t prop = zpool_name_to_prop(propname);
@@ -752,7 +752,7 @@ spa_prop_validate(spa_t *spa, nvlist_t *props)
void
spa_configfile_set(spa_t *spa, nvlist_t *nvp, boolean_t need_sync)
{
- char *cachefile;
+ const char *cachefile;
spa_config_dirent_t *dp;
if (nvlist_lookup_string(nvp, zpool_prop_to_name(ZPOOL_PROP_CACHEFILE),
@@ -3351,7 +3351,7 @@ static int
spa_verify_host(spa_t *spa, nvlist_t *mos_config)
{
uint64_t hostid;
- char *hostname;
+ const char *hostname;
uint64_t myhostid = 0;
if (!spa_is_root(spa) && nvlist_lookup_uint64(mos_config,
@@ -3386,8 +3386,8 @@ spa_ld_parse_config(spa_t *spa, spa_import_type_t type)
int parse;
vdev_t *rvd;
uint64_t pool_guid;
- char *comment;
- char *compatibility;
+ const char *comment;
+ const char *compatibility;
/*
* Versioning wasn't explicitly added to the label until later, so if
@@ -5797,7 +5797,7 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
nvlist_t *zplprops, dsl_crypto_params_t *dcp)
{
spa_t *spa;
- char *altroot = NULL;
+ const char *altroot = NULL;
vdev_t *rvd;
dsl_pool_t *dp;
dmu_tx_t *tx;
@@ -5810,8 +5810,8 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
boolean_t has_encryption;
boolean_t has_allocclass;
spa_feature_t feat;
- char *feat_name;
- char *poolname;
+ const char *feat_name;
+ const char *poolname;
nvlist_t *nvl;
if (props == NULL ||
@@ -6110,7 +6110,7 @@ int
spa_import(char *pool, nvlist_t *config, nvlist_t *props, uint64_t flags)
{
spa_t *spa;
- char *altroot = NULL;
+ const char *altroot = NULL;
spa_load_state_t state = SPA_LOAD_IMPORT;
zpool_load_policy_t policy;
spa_mode_t mode = spa_mode_global;
@@ -6290,7 +6290,7 @@ nvlist_t *
spa_tryimport(nvlist_t *tryconfig)
{
nvlist_t *config = NULL;
- char *poolname, *cachefile;
+ const char *poolname, *cachefile;
spa_t *spa;
uint64_t state;
int error;
@@ -7563,7 +7563,7 @@ spa_vdev_split_mirror(spa_t *spa, const char *newname, nvlist_t *config,
uint_t c, children, lastlog;
nvlist_t **child, *nvl, *tmp;
dmu_tx_t *tx;
- char *altroot = NULL;
+ const char *altroot = NULL;
vdev_t *rvd, **vml = NULL; /* vdev modify list */
boolean_t activate_slog;
@@ -8783,7 +8783,7 @@ spa_sync_props(void *arg, dmu_tx_t *tx)
while ((elem = nvlist_next_nvpair(nvp, elem))) {
uint64_t intval;
- char *strval, *fname;
+ const char *strval, *fname;
zpool_prop_t prop;
const char *propname;
zprop_type_t proptype;