mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-25 03:37:45 +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
+20
-14
@@ -2399,6 +2399,9 @@
|
||||
<array-type-def dimensions='1' type-id='a84c031d' size-in-bits='65536' id='163f6aa5'>
|
||||
<subrange length='8192' type-id='7359adad' id='c88f397d'/>
|
||||
</array-type-def>
|
||||
<array-type-def dimensions='1' type-id='a84c031d' size-in-bits='infinite' id='e84913bd'>
|
||||
<subrange length='infinite' type-id='7359adad' id='031f2035'/>
|
||||
</array-type-def>
|
||||
<array-type-def dimensions='1' type-id='9c313c2d' size-in-bits='128' id='c1c22e6c'>
|
||||
<subrange length='2' type-id='7359adad' id='52efc4ef'/>
|
||||
</array-type-def>
|
||||
@@ -2456,6 +2459,9 @@
|
||||
<data-member access='public' layout-offset-in-bits='96'>
|
||||
<var-decl name='nvp_type' type-id='8d0687d2' visibility='default'/>
|
||||
</data-member>
|
||||
<data-member access='public' layout-offset-in-bits='128'>
|
||||
<var-decl name='nvp_name' type-id='e84913bd' visibility='default'/>
|
||||
</data-member>
|
||||
</class-decl>
|
||||
<typedef-decl name='nvpair_t' type-id='1c34e459' id='57928edf'/>
|
||||
<class-decl name='drr_begin' size-in-bits='2432' is-struct='yes' visibility='default' id='09fcdc01'>
|
||||
@@ -2745,7 +2751,7 @@
|
||||
</function-decl>
|
||||
<function-decl name='nvpair_name' visibility='default' binding='global' size-in-bits='64'>
|
||||
<parameter type-id='dace003f'/>
|
||||
<return type-id='26a90f95'/>
|
||||
<return type-id='80f4b756'/>
|
||||
</function-decl>
|
||||
<function-decl name='fnvpair_value_nvlist' visibility='default' binding='global' size-in-bits='64'>
|
||||
<parameter type-id='3fa542f0'/>
|
||||
@@ -3239,6 +3245,7 @@
|
||||
<pointer-type-def type-id='79bd3751' size-in-bits='64' id='c65a1f29'/>
|
||||
<qualified-type-def type-id='9b23c9ad' restrict='yes' id='8c85230f'/>
|
||||
<qualified-type-def type-id='80f4b756' restrict='yes' id='9d26089a'/>
|
||||
<pointer-type-def type-id='80f4b756' size-in-bits='64' id='7d3cd834'/>
|
||||
<qualified-type-def type-id='aca3bac8' const='yes' id='2498fd78'/>
|
||||
<pointer-type-def type-id='2498fd78' size-in-bits='64' id='eed6c816'/>
|
||||
<qualified-type-def type-id='eed6c816' restrict='yes' id='a431a9da'/>
|
||||
@@ -3351,9 +3358,9 @@
|
||||
<return type-id='95e97e5e'/>
|
||||
</function-decl>
|
||||
<function-decl name='nvlist_lookup_string' visibility='default' binding='global' size-in-bits='64'>
|
||||
<parameter type-id='5ce45b60'/>
|
||||
<parameter type-id='22cce67b'/>
|
||||
<parameter type-id='80f4b756'/>
|
||||
<parameter type-id='9b23c9ad'/>
|
||||
<parameter type-id='7d3cd834'/>
|
||||
<return type-id='95e97e5e'/>
|
||||
</function-decl>
|
||||
<function-decl name='fnvlist_alloc' visibility='default' binding='global' size-in-bits='64'>
|
||||
@@ -3803,7 +3810,6 @@
|
||||
<pointer-type-def type-id='fba6cb51' size-in-bits='64' id='32adbf30'/>
|
||||
<pointer-type-def type-id='f20fbd51' size-in-bits='64' id='a3681dea'/>
|
||||
<qualified-type-def type-id='26a90f95' restrict='yes' id='266fe297'/>
|
||||
<pointer-type-def type-id='80f4b756' size-in-bits='64' id='7d3cd834'/>
|
||||
<qualified-type-def type-id='56fe4a37' const='yes' id='a75125ce'/>
|
||||
<pointer-type-def type-id='a75125ce' size-in-bits='64' id='48bea5ec'/>
|
||||
<qualified-type-def type-id='8afd6070' const='yes' id='1d853360'/>
|
||||
@@ -4166,8 +4172,8 @@
|
||||
<return type-id='95e97e5e'/>
|
||||
</function-decl>
|
||||
<function-decl name='nvpair_value_string' visibility='default' binding='global' size-in-bits='64'>
|
||||
<parameter type-id='3fa542f0'/>
|
||||
<parameter type-id='9b23c9ad'/>
|
||||
<parameter type-id='dace003f'/>
|
||||
<parameter type-id='7d3cd834'/>
|
||||
<return type-id='95e97e5e'/>
|
||||
</function-decl>
|
||||
<function-decl name='fnvlist_free' visibility='default' binding='global' size-in-bits='64'>
|
||||
@@ -4203,9 +4209,9 @@
|
||||
<return type-id='9c313c2d'/>
|
||||
</function-decl>
|
||||
<function-decl name='fnvlist_lookup_string' visibility='default' binding='global' size-in-bits='64'>
|
||||
<parameter type-id='5ce45b60'/>
|
||||
<parameter type-id='22cce67b'/>
|
||||
<parameter type-id='80f4b756'/>
|
||||
<return type-id='26a90f95'/>
|
||||
<return type-id='80f4b756'/>
|
||||
</function-decl>
|
||||
<function-decl name='fnvlist_lookup_nvlist' visibility='default' binding='global' size-in-bits='64'>
|
||||
<parameter type-id='5ce45b60'/>
|
||||
@@ -4418,7 +4424,7 @@
|
||||
<function-decl name='getprop_uint64' mangled-name='getprop_uint64' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='getprop_uint64'>
|
||||
<parameter type-id='9200a744' name='zhp'/>
|
||||
<parameter type-id='58603c44' name='prop'/>
|
||||
<parameter type-id='9b23c9ad' name='source'/>
|
||||
<parameter type-id='7d3cd834' name='source'/>
|
||||
<return type-id='9c313c2d'/>
|
||||
</function-decl>
|
||||
<function-decl name='zfs_prop_get_recvd' mangled-name='zfs_prop_get_recvd' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_prop_get_recvd'>
|
||||
@@ -4688,7 +4694,7 @@
|
||||
<parameter type-id='95e97e5e'/>
|
||||
<parameter type-id='2e45de5d'/>
|
||||
<parameter type-id='5ce45b60'/>
|
||||
<parameter type-id='9b23c9ad'/>
|
||||
<parameter type-id='7d3cd834'/>
|
||||
<parameter type-id='5d6479ae'/>
|
||||
<parameter type-id='80f4b756'/>
|
||||
<return type-id='95e97e5e'/>
|
||||
@@ -5993,8 +5999,8 @@
|
||||
<return type-id='9da381c4'/>
|
||||
</function-decl>
|
||||
<function-decl name='fnvpair_value_string' visibility='default' binding='global' size-in-bits='64'>
|
||||
<parameter type-id='3fa542f0'/>
|
||||
<return type-id='26a90f95'/>
|
||||
<parameter type-id='dace003f'/>
|
||||
<return type-id='80f4b756'/>
|
||||
</function-decl>
|
||||
<function-decl name='zfeature_is_supported' mangled-name='zfeature_is_supported' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfeature_is_supported'>
|
||||
<parameter type-id='80f4b756'/>
|
||||
@@ -8140,8 +8146,8 @@
|
||||
<function-decl name='label_paths' visibility='default' binding='global' size-in-bits='64'>
|
||||
<parameter type-id='5507783b'/>
|
||||
<parameter type-id='5ce45b60'/>
|
||||
<parameter type-id='9b23c9ad'/>
|
||||
<parameter type-id='9b23c9ad'/>
|
||||
<parameter type-id='7d3cd834'/>
|
||||
<parameter type-id='7d3cd834'/>
|
||||
<return type-id='95e97e5e'/>
|
||||
</function-decl>
|
||||
<function-decl name='zutil_alloc' visibility='default' binding='global' size-in-bits='64'>
|
||||
|
||||
@@ -942,7 +942,7 @@ proplist_has_encryption_props(nvlist_t *props)
|
||||
{
|
||||
int ret;
|
||||
uint64_t intval;
|
||||
char *strval;
|
||||
const char *strval;
|
||||
|
||||
ret = nvlist_lookup_uint64(props,
|
||||
zfs_prop_to_name(ZFS_PROP_ENCRYPTION), &intval);
|
||||
@@ -1007,7 +1007,7 @@ zfs_crypto_create(libzfs_handle_t *hdl, char *parent_name, nvlist_t *props,
|
||||
char errbuf[ERRBUFLEN];
|
||||
uint64_t crypt = ZIO_CRYPT_INHERIT, pcrypt = ZIO_CRYPT_INHERIT;
|
||||
uint64_t keyformat = ZFS_KEYFORMAT_NONE;
|
||||
char *keylocation = NULL;
|
||||
const char *keylocation = NULL;
|
||||
zfs_handle_t *pzhp = NULL;
|
||||
uint8_t *wkeydata = NULL;
|
||||
uint_t wkeylen = 0;
|
||||
@@ -1595,7 +1595,7 @@ zfs_crypto_rewrap(zfs_handle_t *zhp, nvlist_t *raw_props, boolean_t inheritkey)
|
||||
uint64_t crypt, pcrypt, keystatus, pkeystatus;
|
||||
uint64_t keyformat = ZFS_KEYFORMAT_NONE;
|
||||
zfs_handle_t *pzhp = NULL;
|
||||
char *keylocation = NULL;
|
||||
const char *keylocation = NULL;
|
||||
char origin_name[MAXNAMELEN];
|
||||
char prop_keylocation[MAXNAMELEN];
|
||||
char parent_name[ZFS_MAX_DATASET_NAME_LEN];
|
||||
@@ -1705,7 +1705,7 @@ zfs_crypto_rewrap(zfs_handle_t *zhp, nvlist_t *raw_props, boolean_t inheritkey)
|
||||
|
||||
/* default to prompt if no keylocation is specified */
|
||||
if (keylocation == NULL) {
|
||||
keylocation = (char *)"prompt";
|
||||
keylocation = "prompt";
|
||||
ret = nvlist_add_string(props,
|
||||
zfs_prop_to_name(ZFS_PROP_KEYLOCATION),
|
||||
keylocation);
|
||||
|
||||
+15
-15
@@ -1029,7 +1029,7 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
|
||||
{
|
||||
nvpair_t *elem;
|
||||
uint64_t intval;
|
||||
char *strval;
|
||||
const char *strval;
|
||||
zfs_prop_t prop;
|
||||
nvlist_t *ret;
|
||||
int chosen_normal = -1;
|
||||
@@ -2065,7 +2065,7 @@ error:
|
||||
* extract them appropriately.
|
||||
*/
|
||||
uint64_t
|
||||
getprop_uint64(zfs_handle_t *zhp, zfs_prop_t prop, char **source)
|
||||
getprop_uint64(zfs_handle_t *zhp, zfs_prop_t prop, const char **source)
|
||||
{
|
||||
nvlist_t *nv;
|
||||
uint64_t value;
|
||||
@@ -2079,14 +2079,14 @@ getprop_uint64(zfs_handle_t *zhp, zfs_prop_t prop, char **source)
|
||||
verify(!zhp->zfs_props_table ||
|
||||
zhp->zfs_props_table[prop] == B_TRUE);
|
||||
value = zfs_prop_default_numeric(prop);
|
||||
*source = (char *)"";
|
||||
*source = "";
|
||||
}
|
||||
|
||||
return (value);
|
||||
}
|
||||
|
||||
static const char *
|
||||
getprop_string(zfs_handle_t *zhp, zfs_prop_t prop, char **source)
|
||||
getprop_string(zfs_handle_t *zhp, zfs_prop_t prop, const char **source)
|
||||
{
|
||||
nvlist_t *nv;
|
||||
const char *value;
|
||||
@@ -2100,7 +2100,7 @@ getprop_string(zfs_handle_t *zhp, zfs_prop_t prop, char **source)
|
||||
verify(!zhp->zfs_props_table ||
|
||||
zhp->zfs_props_table[prop] == B_TRUE);
|
||||
value = zfs_prop_default_string(prop);
|
||||
*source = (char *)"";
|
||||
*source = "";
|
||||
}
|
||||
|
||||
return (value);
|
||||
@@ -2138,7 +2138,7 @@ zfs_unset_recvd_props_mode(zfs_handle_t *zhp, uintptr_t *cookie)
|
||||
*/
|
||||
static int
|
||||
get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
|
||||
char **source, uint64_t *val)
|
||||
const char **source, uint64_t *val)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
nvlist_t *zplprops = NULL;
|
||||
@@ -2370,7 +2370,7 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
|
||||
* Calculate the source type, given the raw source string.
|
||||
*/
|
||||
static void
|
||||
get_source(zfs_handle_t *zhp, zprop_source_t *srctype, char *source,
|
||||
get_source(zfs_handle_t *zhp, zprop_source_t *srctype, const char *source,
|
||||
char *statbuf, size_t statlen)
|
||||
{
|
||||
if (statbuf == NULL ||
|
||||
@@ -2418,7 +2418,7 @@ zfs_prop_get_recvd(zfs_handle_t *zhp, const char *propname, char *propbuf,
|
||||
zfs_unset_recvd_props_mode(zhp, &cookie);
|
||||
} else {
|
||||
nvlist_t *propval;
|
||||
char *recvdval;
|
||||
const char *recvdval;
|
||||
if (nvlist_lookup_nvlist(zhp->zfs_recvd_props,
|
||||
propname, &propval) != 0)
|
||||
return (-1);
|
||||
@@ -2620,7 +2620,7 @@ zcp_check(zfs_handle_t *zhp, zfs_prop_t prop, uint64_t intval,
|
||||
(u_longlong_t)intval, (u_longlong_t)ans);
|
||||
}
|
||||
} else {
|
||||
char *str_ans;
|
||||
const char *str_ans;
|
||||
error = nvlist_lookup_string(retnvl, "value", &str_ans);
|
||||
if (error != 0) {
|
||||
(void) fprintf(stderr, "%s: zcp check error: "
|
||||
@@ -2652,7 +2652,7 @@ int
|
||||
zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
|
||||
zprop_source_t *src, char *statbuf, size_t statlen, boolean_t literal)
|
||||
{
|
||||
char *source = NULL;
|
||||
const char *source = NULL;
|
||||
uint64_t val;
|
||||
const char *str;
|
||||
const char *strval;
|
||||
@@ -3053,7 +3053,7 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
|
||||
uint64_t
|
||||
zfs_prop_get_int(zfs_handle_t *zhp, zfs_prop_t prop)
|
||||
{
|
||||
char *source;
|
||||
const char *source;
|
||||
uint64_t val = 0;
|
||||
|
||||
(void) get_numeric_property(zhp, prop, NULL, &source, &val);
|
||||
@@ -3077,7 +3077,7 @@ int
|
||||
zfs_prop_get_numeric(zfs_handle_t *zhp, zfs_prop_t prop, uint64_t *value,
|
||||
zprop_source_t *src, char *statbuf, size_t statlen)
|
||||
{
|
||||
char *source;
|
||||
const char *source;
|
||||
|
||||
/*
|
||||
* Check to see if this property applies to our object
|
||||
@@ -4698,7 +4698,7 @@ zfs_expand_proplist(zfs_handle_t *zhp, zprop_list_t **plp, boolean_t received,
|
||||
zprop_list_t **last, **start;
|
||||
nvlist_t *userprops, *propval;
|
||||
nvpair_t *elem;
|
||||
char *strval;
|
||||
const char *strval;
|
||||
char buf[ZFS_MAXPROPLEN];
|
||||
|
||||
if (zprop_expand_list(hdl, plp, ZFS_TYPE_DATASET) != 0)
|
||||
@@ -5484,7 +5484,7 @@ volsize_from_vdevs(zpool_handle_t *zhp, uint64_t nblocks, uint64_t blksize)
|
||||
}
|
||||
|
||||
for (int v = 0; v < nvdevs; v++) {
|
||||
char *type;
|
||||
const char *type;
|
||||
uint64_t nparity, ashift, asize, tsize;
|
||||
uint64_t volsize;
|
||||
|
||||
@@ -5566,7 +5566,7 @@ zvol_volsize_to_reservation(zpool_handle_t *zph, uint64_t volsize,
|
||||
uint64_t numdb;
|
||||
uint64_t nblocks, volblocksize;
|
||||
int ncopies;
|
||||
char *strval;
|
||||
const char *strval;
|
||||
|
||||
if (nvlist_lookup_string(props,
|
||||
zfs_prop_to_name(ZFS_PROP_COPIES), &strval) == 0)
|
||||
|
||||
@@ -140,7 +140,7 @@ extern zfs_handle_t *make_dataset_handle_zc(libzfs_handle_t *, zfs_cmd_t *);
|
||||
extern zfs_handle_t *make_dataset_simple_handle_zc(zfs_handle_t *, zfs_cmd_t *);
|
||||
|
||||
extern int zprop_parse_value(libzfs_handle_t *, nvpair_t *, int, zfs_type_t,
|
||||
nvlist_t *, char **, uint64_t *, const char *);
|
||||
nvlist_t *, const char **, uint64_t *, const char *);
|
||||
extern int zprop_expand_list(libzfs_handle_t *hdl, zprop_list_t **plp,
|
||||
zfs_type_t type);
|
||||
|
||||
|
||||
@@ -280,7 +280,7 @@ zpool_in_use(libzfs_handle_t *hdl, int fd, pool_state_t *state, char **namestr,
|
||||
boolean_t *inuse)
|
||||
{
|
||||
nvlist_t *config;
|
||||
char *name = NULL;
|
||||
const char *name = NULL;
|
||||
boolean_t ret;
|
||||
uint64_t guid = 0, vdev_guid;
|
||||
zpool_handle_t *zhp;
|
||||
|
||||
@@ -224,7 +224,7 @@ zfs_iter_bookmarks(zfs_handle_t *zhp, int flags __maybe_unused,
|
||||
for (pair = nvlist_next_nvpair(bmarks, NULL);
|
||||
pair != NULL; pair = nvlist_next_nvpair(bmarks, pair)) {
|
||||
char name[ZFS_MAX_DATASET_NAME_LEN];
|
||||
char *bmark_name;
|
||||
const char *bmark_name;
|
||||
nvlist_t *bmark_props;
|
||||
|
||||
bmark_name = nvpair_name(pair);
|
||||
|
||||
@@ -291,7 +291,7 @@ static int
|
||||
zfs_add_option(zfs_handle_t *zhp, char *options, int len,
|
||||
zfs_prop_t prop, const char *on, const char *off)
|
||||
{
|
||||
char *source;
|
||||
const char *source;
|
||||
uint64_t value;
|
||||
|
||||
/* Skip adding duplicate default options */
|
||||
|
||||
+23
-21
@@ -459,9 +459,9 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname,
|
||||
nvpair_t *elem;
|
||||
nvlist_t *retprops;
|
||||
zpool_prop_t prop;
|
||||
char *strval;
|
||||
const char *strval;
|
||||
uint64_t intval;
|
||||
char *slash, *check;
|
||||
const char *slash, *check;
|
||||
struct stat64 statbuf;
|
||||
zpool_handle_t *zhp;
|
||||
char report[1024];
|
||||
@@ -689,12 +689,12 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname,
|
||||
goto error;
|
||||
}
|
||||
|
||||
*slash = '\0';
|
||||
*(char *)slash = '\0';
|
||||
|
||||
if (strval[0] != '\0' &&
|
||||
(stat64(strval, &statbuf) != 0 ||
|
||||
!S_ISDIR(statbuf.st_mode))) {
|
||||
*slash = '/';
|
||||
*(char *)slash = '/';
|
||||
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
|
||||
"'%s' is not a valid directory"),
|
||||
strval);
|
||||
@@ -702,7 +702,7 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname,
|
||||
goto error;
|
||||
}
|
||||
|
||||
*slash = '/';
|
||||
*(char *)slash = '/';
|
||||
break;
|
||||
|
||||
case ZPOOL_PROP_COMPATIBILITY:
|
||||
@@ -932,7 +932,7 @@ vdev_expand_proplist(zpool_handle_t *zhp, const char *vdevname,
|
||||
{
|
||||
zprop_list_t *entry;
|
||||
char buf[ZFS_MAXPROPLEN];
|
||||
char *strval = NULL;
|
||||
const char *strval = NULL;
|
||||
int err = 0;
|
||||
nvpair_t *elem = NULL;
|
||||
nvlist_t *vprops = NULL;
|
||||
@@ -1290,7 +1290,7 @@ zpool_has_special_vdev(nvlist_t *nvroot)
|
||||
if (nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN, &child,
|
||||
&children) == 0) {
|
||||
for (uint_t c = 0; c < children; c++) {
|
||||
char *bias;
|
||||
const char *bias;
|
||||
|
||||
if (nvlist_lookup_string(child[c],
|
||||
ZPOOL_CONFIG_ALLOCATION_BIAS, &bias) == 0 &&
|
||||
@@ -1314,7 +1314,7 @@ zpool_has_draid_vdev(nvlist_t *nvroot)
|
||||
if (nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN,
|
||||
&child, &children) == 0) {
|
||||
for (uint_t c = 0; c < children; c++) {
|
||||
char *type;
|
||||
const char *type;
|
||||
|
||||
if (nvlist_lookup_string(child[c],
|
||||
ZPOOL_CONFIG_TYPE, &type) == 0 &&
|
||||
@@ -1394,7 +1394,7 @@ zpool_create(libzfs_handle_t *hdl, const char *pool, nvlist_t *nvroot,
|
||||
|
||||
if (fsprops) {
|
||||
uint64_t zoned;
|
||||
char *zonestr;
|
||||
const char *zonestr;
|
||||
|
||||
zoned = ((nvlist_lookup_string(fsprops,
|
||||
zfs_prop_to_name(ZFS_PROP_ZONED), &zonestr) == 0) &&
|
||||
@@ -1987,7 +1987,7 @@ zpool_print_unsup_feat(nvlist_t *config)
|
||||
|
||||
for (nvpair_t *nvp = nvlist_next_nvpair(unsup_feat, NULL);
|
||||
nvp != NULL; nvp = nvlist_next_nvpair(unsup_feat, nvp)) {
|
||||
char *desc = fnvpair_value_string(nvp);
|
||||
const char *desc = fnvpair_value_string(nvp);
|
||||
if (strlen(desc) > 0)
|
||||
(void) printf("\t%s (%s)\n", nvpair_name(nvp), desc);
|
||||
else
|
||||
@@ -2011,7 +2011,7 @@ zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname,
|
||||
nvlist_t *nvinfo = NULL;
|
||||
nvlist_t *missing = NULL;
|
||||
const char *thename;
|
||||
char *origname;
|
||||
const char *origname;
|
||||
int ret;
|
||||
int error = 0;
|
||||
char errbuf[ERRBUFLEN];
|
||||
@@ -2239,7 +2239,7 @@ zpool_translate_vdev_guids(zpool_handle_t *zhp, nvlist_t *vds,
|
||||
elem = nvlist_next_nvpair(vds, elem)) {
|
||||
boolean_t spare, cache;
|
||||
|
||||
char *vd_path = nvpair_name(elem);
|
||||
const char *vd_path = nvpair_name(elem);
|
||||
nvlist_t *tgt = zpool_find_vdev(zhp, vd_path, &spare, &cache,
|
||||
NULL);
|
||||
|
||||
@@ -2353,7 +2353,7 @@ list_errors:
|
||||
for (elem = nvlist_next_nvpair(vd_errlist, NULL); elem != NULL;
|
||||
elem = nvlist_next_nvpair(vd_errlist, elem)) {
|
||||
int64_t vd_error = xlate_init_err(fnvpair_value_int64(elem));
|
||||
char *path;
|
||||
const char *path;
|
||||
|
||||
if (nvlist_lookup_string(guids_to_paths, nvpair_name(elem),
|
||||
&path) != 0)
|
||||
@@ -2451,7 +2451,7 @@ check_trim_errs(zpool_handle_t *zhp, trimflags_t *trim_flags,
|
||||
for (elem = nvlist_next_nvpair(errlist, NULL);
|
||||
elem != NULL; elem = nvlist_next_nvpair(errlist, elem)) {
|
||||
int64_t vd_error = xlate_trim_err(fnvpair_value_int64(elem));
|
||||
char *path;
|
||||
const char *path;
|
||||
|
||||
/*
|
||||
* If only the pool was specified, and it was not a secure
|
||||
@@ -2634,7 +2634,7 @@ vdev_to_nvlist_iter(nvlist_t *nv, nvlist_t *search, boolean_t *avail_spare,
|
||||
nvlist_t **child;
|
||||
nvlist_t *ret;
|
||||
uint64_t is_log;
|
||||
char *srchkey;
|
||||
const char *srchkey;
|
||||
nvpair_t *pair = nvlist_next_nvpair(search, NULL);
|
||||
|
||||
/* Nothing to look for */
|
||||
@@ -2656,7 +2656,7 @@ vdev_to_nvlist_iter(nvlist_t *nv, nvlist_t *search, boolean_t *avail_spare,
|
||||
break;
|
||||
|
||||
case DATA_TYPE_STRING: {
|
||||
char *srchval, *val;
|
||||
const char *srchval, *val;
|
||||
|
||||
srchval = fnvpair_value_string(pair);
|
||||
if (nvlist_lookup_string(nv, srchkey, &val) != 0)
|
||||
@@ -2969,7 +2969,7 @@ zpool_vdev_online(zpool_handle_t *zhp, const char *path, int flags,
|
||||
return (zfs_error(hdl, EZFS_ISSPARE, errbuf));
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
char *pathname;
|
||||
const char *pathname;
|
||||
if ((flags & ZFS_ONLINE_EXPAND ||
|
||||
zpool_get_prop_int(zhp, ZPOOL_PROP_AUTOEXPAND, NULL)) &&
|
||||
nvlist_lookup_string(tgt, ZPOOL_CONFIG_PATH, &pathname) == 0) {
|
||||
@@ -3181,7 +3181,8 @@ is_replacing_spare(nvlist_t *search, nvlist_t *tgt, int which)
|
||||
|
||||
if (nvlist_lookup_nvlist_array(search, ZPOOL_CONFIG_CHILDREN, &child,
|
||||
&children) == 0) {
|
||||
char *type = fnvlist_lookup_string(search, ZPOOL_CONFIG_TYPE);
|
||||
const char *type = fnvlist_lookup_string(search,
|
||||
ZPOOL_CONFIG_TYPE);
|
||||
if ((strcmp(type, VDEV_TYPE_SPARE) == 0 ||
|
||||
strcmp(type, VDEV_TYPE_DRAID_SPARE) == 0) &&
|
||||
children == 2 && child[which] == tgt)
|
||||
@@ -3484,7 +3485,8 @@ zpool_vdev_split(zpool_handle_t *zhp, char *newname, nvlist_t **newroot,
|
||||
nvlist_t *props, splitflags_t flags)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char errbuf[ERRBUFLEN], *bias;
|
||||
char errbuf[ERRBUFLEN];
|
||||
const char *bias;
|
||||
nvlist_t *tree, *config, **child, **newchild, *newconfig = NULL;
|
||||
nvlist_t **varray = NULL, *zc_props = NULL;
|
||||
uint_t c, children, newchildren, lastlog = 0, vcount, found = 0;
|
||||
@@ -3542,7 +3544,7 @@ zpool_vdev_split(zpool_handle_t *zhp, char *newname, nvlist_t **newroot,
|
||||
for (c = 0; c < children; c++) {
|
||||
uint64_t is_log = B_FALSE, is_hole = B_FALSE;
|
||||
boolean_t is_special = B_FALSE, is_dedup = B_FALSE;
|
||||
char *type;
|
||||
const char *type;
|
||||
nvlist_t **mchild, *vdev;
|
||||
uint_t mchildren;
|
||||
int entry;
|
||||
@@ -4015,7 +4017,7 @@ char *
|
||||
zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv,
|
||||
int name_flags)
|
||||
{
|
||||
char *type, *tpath;
|
||||
const char *type, *tpath;
|
||||
const char *path;
|
||||
uint64_t value;
|
||||
char buf[PATH_BUF_LEN];
|
||||
|
||||
@@ -119,7 +119,7 @@ dump_record(dmu_replay_record_t *drr, void *payload, size_t payload_len,
|
||||
typedef struct fsavl_node {
|
||||
avl_node_t fn_node;
|
||||
nvlist_t *fn_nvfs;
|
||||
char *fn_snapname;
|
||||
const char *fn_snapname;
|
||||
uint64_t fn_guid;
|
||||
} fsavl_node_t;
|
||||
|
||||
@@ -137,7 +137,7 @@ fsavl_compare(const void *arg1, const void *arg2)
|
||||
* (optionally) name.
|
||||
*/
|
||||
static nvlist_t *
|
||||
fsavl_find(avl_tree_t *avl, uint64_t snapguid, char **snapname)
|
||||
fsavl_find(avl_tree_t *avl, uint64_t snapguid, const char **snapname)
|
||||
{
|
||||
fsavl_node_t fn_find;
|
||||
fsavl_node_t *fn;
|
||||
@@ -384,7 +384,7 @@ send_iterate_prop(zfs_handle_t *zhp, boolean_t received_only, nvlist_t *nv)
|
||||
|
||||
nvpair_t *elem = NULL;
|
||||
while ((elem = nvlist_next_nvpair(props, elem)) != NULL) {
|
||||
char *propname = nvpair_name(elem);
|
||||
const char *propname = nvpair_name(elem);
|
||||
zfs_prop_t prop = zfs_name_to_prop(propname);
|
||||
|
||||
if (!zfs_prop_user(propname)) {
|
||||
@@ -412,7 +412,7 @@ send_iterate_prop(zfs_handle_t *zhp, boolean_t received_only, nvlist_t *nv)
|
||||
if (isspacelimit && zhp->zfs_type == ZFS_TYPE_SNAPSHOT)
|
||||
continue;
|
||||
|
||||
char *source;
|
||||
const char *source;
|
||||
if (nvlist_lookup_string(propnv, ZPROP_SOURCE, &source) == 0) {
|
||||
if (strcmp(source, zhp->zfs_name) != 0 &&
|
||||
strcmp(source, ZPROP_SOURCE_VAL_RECVD) != 0)
|
||||
@@ -428,7 +428,7 @@ send_iterate_prop(zfs_handle_t *zhp, boolean_t received_only, nvlist_t *nv)
|
||||
|
||||
if (zfs_prop_user(propname) ||
|
||||
zfs_prop_get_type(prop) == PROP_TYPE_STRING) {
|
||||
char *value;
|
||||
const char *value;
|
||||
value = fnvlist_lookup_string(propnv, ZPROP_VALUE);
|
||||
fnvlist_add_string(nv, propname, value);
|
||||
} else {
|
||||
@@ -1132,7 +1132,7 @@ dump_snapshot(zfs_handle_t *zhp, void *arg)
|
||||
|
||||
if (!sdd->doall && !isfromsnap && !istosnap) {
|
||||
if (sdd->replicate) {
|
||||
char *snapname;
|
||||
const char *snapname;
|
||||
nvlist_t *snapprops;
|
||||
/*
|
||||
* Filter out all intermediate snapshots except origin
|
||||
@@ -1372,7 +1372,7 @@ dump_filesystems(zfs_handle_t *rzhp, send_dump_data_t *sdd)
|
||||
nvfs = fnvpair_value_nvlist(fspair);
|
||||
(void) nvlist_lookup_uint64(nvfs, "origin", &origin_guid);
|
||||
if (origin_guid != 0) {
|
||||
char *snapname;
|
||||
const char *snapname;
|
||||
nvlist_t *origin_nv = fsavl_find(sdd->fsavl,
|
||||
origin_guid, &snapname);
|
||||
if (origin_nv != NULL) {
|
||||
@@ -1391,7 +1391,7 @@ again:
|
||||
for (fspair = nvlist_next_nvpair(sdd->fss, NULL); fspair;
|
||||
fspair = nvlist_next_nvpair(sdd->fss, fspair)) {
|
||||
nvlist_t *fslist, *parent_nv;
|
||||
char *fsname;
|
||||
const char *fsname;
|
||||
zfs_handle_t *zhp;
|
||||
int err;
|
||||
uint64_t origin_guid = 0;
|
||||
@@ -1757,8 +1757,8 @@ zfs_send_resume_impl_cb_impl(libzfs_handle_t *hdl, sendflags_t *flags,
|
||||
int outfd, nvlist_t *resume_nvl)
|
||||
{
|
||||
char errbuf[ERRBUFLEN];
|
||||
char *toname;
|
||||
char *fromname = NULL;
|
||||
const char *toname;
|
||||
const char *fromname = NULL;
|
||||
uint64_t resumeobj, resumeoff, toguid, fromguid, bytes;
|
||||
zfs_handle_t *zhp;
|
||||
int error = 0;
|
||||
@@ -3254,7 +3254,7 @@ created_before(libzfs_handle_t *hdl, avl_tree_t *avl,
|
||||
uint64_t guid1, uint64_t guid2)
|
||||
{
|
||||
nvlist_t *nvfs;
|
||||
char *fsname = NULL, *snapname = NULL;
|
||||
const char *fsname = NULL, *snapname = NULL;
|
||||
char buf[ZFS_MAX_DATASET_NAME_LEN];
|
||||
int rv;
|
||||
zfs_handle_t *guid1hdl, *guid2hdl;
|
||||
@@ -3320,7 +3320,7 @@ recv_fix_encryption_hierarchy(libzfs_handle_t *hdl, const char *top_zfs,
|
||||
nvpair_t *snapel = NULL;
|
||||
boolean_t is_encroot, is_clone, stream_encroot;
|
||||
char *cp;
|
||||
char *stream_keylocation = NULL;
|
||||
const char *stream_keylocation = NULL;
|
||||
char keylocation[MAXNAMELEN];
|
||||
char fsname[ZFS_MAX_DATASET_NAME_LEN];
|
||||
|
||||
@@ -3440,12 +3440,12 @@ recv_incremental_replication(libzfs_handle_t *hdl, const char *tofs,
|
||||
nvlist_t *local_nv, *deleted = NULL;
|
||||
avl_tree_t *local_avl;
|
||||
nvpair_t *fselem, *nextfselem;
|
||||
char *fromsnap;
|
||||
const char *fromsnap;
|
||||
char newname[ZFS_MAX_DATASET_NAME_LEN];
|
||||
char guidname[32];
|
||||
int error;
|
||||
boolean_t needagain, progress, recursive;
|
||||
char *s1, *s2;
|
||||
const char *s1, *s2;
|
||||
|
||||
fromsnap = fnvlist_lookup_string(stream_nv, "fromsnap");
|
||||
|
||||
@@ -3477,7 +3477,7 @@ again:
|
||||
uint64_t originguid = 0;
|
||||
uint64_t stream_originguid = 0;
|
||||
uint64_t parent_fromsnap_guid, stream_parent_fromsnap_guid;
|
||||
char *fsname, *stream_fsname;
|
||||
const char *fsname, *stream_fsname;
|
||||
|
||||
nextfselem = nvlist_next_nvpair(local_nv, fselem);
|
||||
|
||||
@@ -3512,7 +3512,7 @@ again:
|
||||
case 1: {
|
||||
/* promote it! */
|
||||
nvlist_t *origin_nvfs;
|
||||
char *origin_fsname;
|
||||
const char *origin_fsname;
|
||||
|
||||
origin_nvfs = fsavl_find(local_avl, originguid,
|
||||
NULL);
|
||||
@@ -3543,7 +3543,7 @@ again:
|
||||
for (snapelem = nvlist_next_nvpair(snaps, NULL);
|
||||
snapelem; snapelem = nextsnapelem) {
|
||||
uint64_t thisguid;
|
||||
char *stream_snapname;
|
||||
const char *stream_snapname;
|
||||
nvlist_t *found, *props;
|
||||
|
||||
nextsnapelem = nvlist_next_nvpair(snaps, snapelem);
|
||||
@@ -3689,7 +3689,7 @@ again:
|
||||
* new fs.
|
||||
*/
|
||||
if (parent != NULL) {
|
||||
char *pname;
|
||||
const char *pname;
|
||||
|
||||
pname = fnvlist_lookup_string(parent, "name");
|
||||
(void) snprintf(tryname, sizeof (tryname),
|
||||
@@ -3740,8 +3740,8 @@ zfs_receive_package(libzfs_handle_t *hdl, int fd, const char *destname,
|
||||
{
|
||||
nvlist_t *stream_nv = NULL;
|
||||
avl_tree_t *stream_avl = NULL;
|
||||
char *fromsnap = NULL;
|
||||
char *sendsnap = NULL;
|
||||
const char *fromsnap = NULL;
|
||||
const char *sendsnap = NULL;
|
||||
char *cp;
|
||||
char tofs[ZFS_MAX_DATASET_NAME_LEN];
|
||||
char sendfs[ZFS_MAX_DATASET_NAME_LEN];
|
||||
@@ -4230,7 +4230,7 @@ zfs_setup_cmdline_props(libzfs_handle_t *hdl, zfs_type_t type,
|
||||
*/
|
||||
if (nvlist_exists(origprops, newname)) {
|
||||
nvlist_t *attrs;
|
||||
char *source = NULL;
|
||||
const char *source = NULL;
|
||||
|
||||
attrs = fnvlist_lookup_nvlist(origprops,
|
||||
newname);
|
||||
@@ -4354,7 +4354,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
|
||||
zprop_errflags_t prop_errflags;
|
||||
nvlist_t *prop_errors = NULL;
|
||||
boolean_t recursive;
|
||||
char *snapname = NULL;
|
||||
const char *snapname = NULL;
|
||||
char destsnap[MAXPATHLEN * 2];
|
||||
char origin[MAXNAMELEN] = {0};
|
||||
char name[MAXPATHLEN];
|
||||
@@ -4385,7 +4385,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
|
||||
boolean_t holds = flags->holds && !flags->skipholds;
|
||||
|
||||
if (stream_avl != NULL) {
|
||||
char *keylocation = NULL;
|
||||
const char *keylocation = NULL;
|
||||
nvlist_t *lookup = NULL;
|
||||
nvlist_t *fs = fsavl_find(stream_avl, drrb->drr_toguid,
|
||||
&snapname);
|
||||
@@ -5503,7 +5503,7 @@ zfs_receive(libzfs_handle_t *hdl, const char *tosnap, nvlist_t *props,
|
||||
char *top_zfs = NULL;
|
||||
int err;
|
||||
struct stat sb;
|
||||
char *originsnap = NULL;
|
||||
const char *originsnap = NULL;
|
||||
|
||||
/*
|
||||
* The only way fstat can fail is if we do not have a valid file
|
||||
|
||||
@@ -168,7 +168,8 @@ find_vdev_problem(nvlist_t *vdev, int (*func)(vdev_stat_t *, uint_t),
|
||||
* later.
|
||||
*/
|
||||
if (ignore_replacing == B_TRUE) {
|
||||
char *type = fnvlist_lookup_string(vdev, ZPOOL_CONFIG_TYPE);
|
||||
const char *type = fnvlist_lookup_string(vdev,
|
||||
ZPOOL_CONFIG_TYPE);
|
||||
if (strcmp(type, VDEV_TYPE_REPLACING) == 0)
|
||||
return (B_FALSE);
|
||||
}
|
||||
|
||||
@@ -1595,13 +1595,13 @@ zfs_nicestrtonum(libzfs_handle_t *hdl, const char *value, uint64_t *num)
|
||||
*/
|
||||
int
|
||||
zprop_parse_value(libzfs_handle_t *hdl, nvpair_t *elem, int prop,
|
||||
zfs_type_t type, nvlist_t *ret, char **svalp, uint64_t *ivalp,
|
||||
zfs_type_t type, nvlist_t *ret, const char **svalp, uint64_t *ivalp,
|
||||
const char *errbuf)
|
||||
{
|
||||
data_type_t datatype = nvpair_type(elem);
|
||||
zprop_type_t proptype;
|
||||
const char *propname;
|
||||
char *value;
|
||||
const char *value;
|
||||
boolean_t isnone = B_FALSE;
|
||||
boolean_t isauto = B_FALSE;
|
||||
int err = 0;
|
||||
|
||||
@@ -96,7 +96,7 @@ zpool_relabel_disk(libzfs_handle_t *hdl, const char *path, const char *msg)
|
||||
static int
|
||||
read_efi_label(nvlist_t *config, diskaddr_t *sb)
|
||||
{
|
||||
char *path;
|
||||
const char *path;
|
||||
int fd;
|
||||
char diskname[MAXPATHLEN];
|
||||
int err = -1;
|
||||
|
||||
Reference in New Issue
Block a user