From 795075e63803db70793079c2176dc419df3788c5 Mon Sep 17 00:00:00 2001 From: Paul Dagnelie Date: Mon, 6 Dec 2021 17:19:13 -0800 Subject: [PATCH] Add `const` to nvlist functions to properly expose their real behavior Reviewed-by: Matthew Ahrens Reviewed-by: Brian Behlendorf Reviewed-by: Tony Nguyen Reviewed-by: Ryan Moeller Signed-off-by: Paul Dagnelie Closes #12728 --- cmd/zed/agents/fmd_api.c | 3 +- cmd/zed/agents/zfs_mod.c | 4 +- cmd/zed/agents/zfs_retire.c | 2 +- cmd/zfs/zfs_main.c | 3 +- cmd/zpool/zpool_vdev.c | 10 +- cmd/ztest/ztest.c | 12 +- .../pyzfs/libzfs_core/bindings/libnvpair.py | 38 ++- include/sys/nvpair.h | 197 +++++++------ include/sys/nvpair_impl.h | 2 +- lib/libnvpair/libnvpair.abi | 267 ++++++++++-------- lib/libuutil/libuutil.abi | 155 +++++----- lib/libzfs/libzfs.abi | 171 +++++------ lib/libzfs/libzfs_pool.c | 6 +- lib/libzfs_core/libzfs_core.abi | 137 ++++----- lib/libzfsbootenv/libzfsbootenv.abi | 37 +-- lib/libzfsbootenv/lzbe_pair.c | 3 +- lib/libzutil/zutil_import.c | 2 +- module/nvpair/fnvpair.c | 74 ++--- module/nvpair/nvpair.c | 144 ++++++---- module/os/freebsd/zfs/spa_os.c | 4 +- module/zfs/fm.c | 14 +- module/zfs/spa.c | 47 +-- module/zfs/vdev_draid.c | 2 +- module/zfs/vdev_label.c | 2 +- module/zfs/vdev_removal.c | 3 +- module/zfs/zfs_fuid.c | 4 +- .../libzfs_input_check/libzfs_input_check.c | 2 +- .../cmd/nvlist_to_lua/nvlist_to_lua.c | 4 +- 28 files changed, 728 insertions(+), 621 deletions(-) diff --git a/cmd/zed/agents/fmd_api.c b/cmd/zed/agents/fmd_api.c index 607b387ca3a8..c9231fba2aee 100644 --- a/cmd/zed/agents/fmd_api.c +++ b/cmd/zed/agents/fmd_api.c @@ -428,7 +428,8 @@ fmd_case_add_suspect(fmd_hdl_t *hdl, fmd_case_t *cp, nvlist_t *fault) err |= nvlist_add_string(nvl, FM_SUSPECT_DIAG_CODE, code); err |= nvlist_add_int64_array(nvl, FM_SUSPECT_DIAG_TIME, tod, 2); err |= nvlist_add_uint32(nvl, FM_SUSPECT_FAULT_SZ, 1); - err |= nvlist_add_nvlist_array(nvl, FM_SUSPECT_FAULT_LIST, &fault, 1); + err |= nvlist_add_nvlist_array(nvl, FM_SUSPECT_FAULT_LIST, + (const nvlist_t **)&fault, 1); if (err) zed_log_die("failed to populate nvlist"); diff --git a/cmd/zed/agents/zfs_mod.c b/cmd/zed/agents/zfs_mod.c index 3bcdf6e1d718..b496b29ac136 100644 --- a/cmd/zed/agents/zfs_mod.c +++ b/cmd/zed/agents/zfs_mod.c @@ -414,8 +414,8 @@ zfs_process_add(zpool_handle_t *zhp, nvlist_t *vdev, boolean_t labeled) ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH, enc_sysfs_path) != 0) || nvlist_add_uint64(newvd, ZPOOL_CONFIG_WHOLE_DISK, wholedisk) != 0 || nvlist_add_string(nvroot, ZPOOL_CONFIG_TYPE, VDEV_TYPE_ROOT) != 0 || - nvlist_add_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN, &newvd, - 1) != 0) { + nvlist_add_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN, + (const nvlist_t **)&newvd, 1) != 0) { zed_log_msg(LOG_WARNING, "zfs_mod: unable to add nvlist pairs"); nvlist_free(newvd); nvlist_free(nvroot); diff --git a/cmd/zed/agents/zfs_retire.c b/cmd/zed/agents/zfs_retire.c index 6c009bdc1235..5fb7b4e84c5e 100644 --- a/cmd/zed/agents/zfs_retire.c +++ b/cmd/zed/agents/zfs_retire.c @@ -239,7 +239,7 @@ replace_with_spare(fmd_hdl_t *hdl, zpool_handle_t *zhp, nvlist_t *vdev) ZPOOL_CONFIG_ASHIFT, ashift); (void) nvlist_add_nvlist_array(replacement, - ZPOOL_CONFIG_CHILDREN, &spares[s], 1); + ZPOOL_CONFIG_CHILDREN, (const nvlist_t **)&spares[s], 1); fmd_hdl_debug(hdl, "zpool_vdev_replace '%s' with spare '%s'", dev_name, zfs_basename(spare_name)); diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index d05cb29c69d6..c43951d82897 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -8010,7 +8010,8 @@ zfs_do_channel_program(int argc, char **argv) * } */ nvlist_t *argnvl = fnvlist_alloc(); - fnvlist_add_string_array(argnvl, ZCP_ARG_CLIARGV, argv + 2, argc - 2); + fnvlist_add_string_array(argnvl, ZCP_ARG_CLIARGV, + (const char **)argv + 2, argc - 2); if (sync_flag) { ret = lzc_channel_program(poolname, progbuf, diff --git a/cmd/zpool/zpool_vdev.c b/cmd/zpool/zpool_vdev.c index dcc67e7e2014..0653a09faea2 100644 --- a/cmd/zpool/zpool_vdev.c +++ b/cmd/zpool/zpool_vdev.c @@ -1647,8 +1647,8 @@ construct_spec(nvlist_t *props, int argc, char **argv) } } verify(nvlist_add_nvlist_array(nv, - ZPOOL_CONFIG_CHILDREN, child, - children) == 0); + ZPOOL_CONFIG_CHILDREN, + (const nvlist_t **)child, children) == 0); for (c = 0; c < children; c++) nvlist_free(child[c]); @@ -1713,13 +1713,13 @@ construct_spec(nvlist_t *props, int argc, char **argv) verify(nvlist_add_string(nvroot, ZPOOL_CONFIG_TYPE, VDEV_TYPE_ROOT) == 0); verify(nvlist_add_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN, - top, toplevels) == 0); + (const nvlist_t **)top, toplevels) == 0); if (nspares != 0) verify(nvlist_add_nvlist_array(nvroot, ZPOOL_CONFIG_SPARES, - spares, nspares) == 0); + (const nvlist_t **)spares, nspares) == 0); if (nl2cache != 0) verify(nvlist_add_nvlist_array(nvroot, ZPOOL_CONFIG_L2CACHE, - l2cache, nl2cache) == 0); + (const nvlist_t **)l2cache, nl2cache) == 0); spec_out: for (t = 0; t < toplevels; t++) diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c index 5a5c381409a2..a2568962d877 100644 --- a/cmd/ztest/ztest.c +++ b/cmd/ztest/ztest.c @@ -1287,7 +1287,8 @@ make_vdev_raid(char *path, char *aux, char *pool, size_t size, ztest_opts.zo_raid_type); fnvlist_add_uint64(raid, ZPOOL_CONFIG_NPARITY, ztest_opts.zo_raid_parity); - fnvlist_add_nvlist_array(raid, ZPOOL_CONFIG_CHILDREN, child, r); + fnvlist_add_nvlist_array(raid, ZPOOL_CONFIG_CHILDREN, + (const nvlist_t **)child, r); if (strcmp(ztest_opts.zo_raid_type, VDEV_TYPE_DRAID) == 0) { uint64_t ndata = ztest_opts.zo_draid_data; @@ -1335,7 +1336,8 @@ make_vdev_mirror(char *path, char *aux, char *pool, size_t size, mirror = fnvlist_alloc(); fnvlist_add_string(mirror, ZPOOL_CONFIG_TYPE, VDEV_TYPE_MIRROR); - fnvlist_add_nvlist_array(mirror, ZPOOL_CONFIG_CHILDREN, child, m); + fnvlist_add_nvlist_array(mirror, ZPOOL_CONFIG_CHILDREN, + (const nvlist_t **)child, m); for (c = 0; c < m; c++) fnvlist_free(child[c]); @@ -1374,7 +1376,7 @@ make_vdev_root(char *path, char *aux, char *pool, size_t size, uint64_t ashift, root = fnvlist_alloc(); fnvlist_add_string(root, ZPOOL_CONFIG_TYPE, VDEV_TYPE_ROOT); fnvlist_add_nvlist_array(root, aux ? aux : ZPOOL_CONFIG_CHILDREN, - child, t); + (const nvlist_t **)child, t); for (c = 0; c < t; c++) fnvlist_free(child[c]); @@ -3550,8 +3552,8 @@ ztest_split_pool(ztest_ds_t *zd, uint64_t id) /* OK, create a config that can be used to split */ split = fnvlist_alloc(); fnvlist_add_string(split, ZPOOL_CONFIG_TYPE, VDEV_TYPE_ROOT); - fnvlist_add_nvlist_array(split, ZPOOL_CONFIG_CHILDREN, schild, - lastlogid != 0 ? lastlogid : schildren); + fnvlist_add_nvlist_array(split, ZPOOL_CONFIG_CHILDREN, + (const nvlist_t **)schild, lastlogid != 0 ? lastlogid : schildren); config = fnvlist_alloc(); fnvlist_add_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, split); diff --git a/contrib/pyzfs/libzfs_core/bindings/libnvpair.py b/contrib/pyzfs/libzfs_core/bindings/libnvpair.py index 3cd72d4908de..54a805907237 100644 --- a/contrib/pyzfs/libzfs_core/bindings/libnvpair.py +++ b/contrib/pyzfs/libzfs_core/bindings/libnvpair.py @@ -79,20 +79,30 @@ int nvlist_add_uint64(nvlist_t *, const char *, uint64_t); int nvlist_add_string(nvlist_t *, const char *, const char *); int nvlist_add_nvlist(nvlist_t *, const char *, nvlist_t *); - int nvlist_add_boolean_array(nvlist_t *, const char *, boolean_t *, - uint_t); - int nvlist_add_byte_array(nvlist_t *, const char *, uchar_t *, uint_t); - int nvlist_add_int8_array(nvlist_t *, const char *, int8_t *, uint_t); - int nvlist_add_uint8_array(nvlist_t *, const char *, uint8_t *, uint_t); - int nvlist_add_int16_array(nvlist_t *, const char *, int16_t *, uint_t); - int nvlist_add_uint16_array(nvlist_t *, const char *, uint16_t *, uint_t); - int nvlist_add_int32_array(nvlist_t *, const char *, int32_t *, uint_t); - int nvlist_add_uint32_array(nvlist_t *, const char *, uint32_t *, uint_t); - int nvlist_add_int64_array(nvlist_t *, const char *, int64_t *, uint_t); - int nvlist_add_uint64_array(nvlist_t *, const char *, uint64_t *, uint_t); - int nvlist_add_string_array(nvlist_t *, const char *, char *const *, - uint_t); - int nvlist_add_nvlist_array(nvlist_t *, const char *, nvlist_t **, uint_t); + int nvlist_add_boolean_array(nvlist_t *, const char *, + const boolean_t *, uint_t); + int nvlist_add_byte_array(nvlist_t *, const char *, + const uchar_t *, uint_t); + int nvlist_add_int8_array(nvlist_t *, const char *, + const int8_t *, uint_t); + int nvlist_add_uint8_array(nvlist_t *, const char *, + const uint8_t *, uint_t); + int nvlist_add_int16_array(nvlist_t *, const char *, + const int16_t *, uint_t); + int nvlist_add_uint16_array(nvlist_t *, const char *, + const uint16_t *, uint_t); + int nvlist_add_int32_array(nvlist_t *, const char *, + const int32_t *, uint_t); + int nvlist_add_uint32_array(nvlist_t *, const char *, + const uint32_t *, uint_t); + int nvlist_add_int64_array(nvlist_t *, const char *, + const int64_t *, uint_t); + int nvlist_add_uint64_array(nvlist_t *, const char *, + const uint64_t *, uint_t); + int nvlist_add_string_array(nvlist_t *, const char *, + const char * const *, uint_t); + int nvlist_add_nvlist_array(nvlist_t *, const char *, + const nvlist_t * const *, uint_t); nvpair_t *nvlist_next_nvpair(nvlist_t *, nvpair_t *); nvpair_t *nvlist_prev_nvpair(nvlist_t *, nvpair_t *); diff --git a/include/sys/nvpair.h b/include/sys/nvpair.h index 76d383a3c681..340b0d79c0a2 100644 --- a/include/sys/nvpair.h +++ b/include/sys/nvpair.h @@ -154,7 +154,7 @@ _SYS_NVPAIR_H void nvlist_free(nvlist_t *); _SYS_NVPAIR_H int nvlist_size(nvlist_t *, size_t *, int); _SYS_NVPAIR_H int nvlist_pack(nvlist_t *, char **, size_t *, int, int); _SYS_NVPAIR_H int nvlist_unpack(char *, size_t, nvlist_t **, int); -_SYS_NVPAIR_H int nvlist_dup(nvlist_t *, nvlist_t **, int); +_SYS_NVPAIR_H int nvlist_dup(const nvlist_t *, nvlist_t **, int); _SYS_NVPAIR_H int nvlist_merge(nvlist_t *, nvlist_t *, int); _SYS_NVPAIR_H uint_t nvlist_nvflag(nvlist_t *); @@ -163,7 +163,7 @@ _SYS_NVPAIR_H int nvlist_xalloc(nvlist_t **, uint_t, nv_alloc_t *); _SYS_NVPAIR_H int nvlist_xpack(nvlist_t *, char **, size_t *, int, nv_alloc_t *); _SYS_NVPAIR_H int nvlist_xunpack(char *, size_t, nvlist_t **, nv_alloc_t *); -_SYS_NVPAIR_H int nvlist_xdup(nvlist_t *, nvlist_t **, nv_alloc_t *); +_SYS_NVPAIR_H int nvlist_xdup(const nvlist_t *, nvlist_t **, nv_alloc_t *); _SYS_NVPAIR_H nv_alloc_t *nvlist_lookup_nv_alloc(nvlist_t *); _SYS_NVPAIR_H int nvlist_add_nvpair(nvlist_t *, nvpair_t *); @@ -179,31 +179,31 @@ _SYS_NVPAIR_H int nvlist_add_uint32(nvlist_t *, const char *, uint32_t); _SYS_NVPAIR_H int nvlist_add_int64(nvlist_t *, const char *, int64_t); _SYS_NVPAIR_H int nvlist_add_uint64(nvlist_t *, const char *, uint64_t); _SYS_NVPAIR_H int nvlist_add_string(nvlist_t *, const char *, const char *); -_SYS_NVPAIR_H int nvlist_add_nvlist(nvlist_t *, const char *, nvlist_t *); +_SYS_NVPAIR_H int nvlist_add_nvlist(nvlist_t *, const char *, const nvlist_t *); _SYS_NVPAIR_H int nvlist_add_boolean_array(nvlist_t *, const char *, - boolean_t *, uint_t); -_SYS_NVPAIR_H int nvlist_add_byte_array(nvlist_t *, const char *, uchar_t *, - uint_t); -_SYS_NVPAIR_H int nvlist_add_int8_array(nvlist_t *, const char *, int8_t *, - uint_t); -_SYS_NVPAIR_H int nvlist_add_uint8_array(nvlist_t *, const char *, uint8_t *, - uint_t); -_SYS_NVPAIR_H int nvlist_add_int16_array(nvlist_t *, const char *, int16_t *, - uint_t); -_SYS_NVPAIR_H int nvlist_add_uint16_array(nvlist_t *, const char *, uint16_t *, - uint_t); -_SYS_NVPAIR_H int nvlist_add_int32_array(nvlist_t *, const char *, int32_t *, - uint_t); -_SYS_NVPAIR_H int nvlist_add_uint32_array(nvlist_t *, const char *, uint32_t *, - uint_t); -_SYS_NVPAIR_H int nvlist_add_int64_array(nvlist_t *, const char *, int64_t *, - uint_t); -_SYS_NVPAIR_H int nvlist_add_uint64_array(nvlist_t *, const char *, uint64_t *, - uint_t); + const boolean_t *, uint_t); +_SYS_NVPAIR_H int nvlist_add_byte_array(nvlist_t *, const char *, + const uchar_t *, uint_t); +_SYS_NVPAIR_H int nvlist_add_int8_array(nvlist_t *, const char *, + const int8_t *, uint_t); +_SYS_NVPAIR_H int nvlist_add_uint8_array(nvlist_t *, const char *, + const uint8_t *, uint_t); +_SYS_NVPAIR_H int nvlist_add_int16_array(nvlist_t *, const char *, + const int16_t *, uint_t); +_SYS_NVPAIR_H int nvlist_add_uint16_array(nvlist_t *, const char *, + const uint16_t *, uint_t); +_SYS_NVPAIR_H int nvlist_add_int32_array(nvlist_t *, const char *, + const int32_t *, uint_t); +_SYS_NVPAIR_H int nvlist_add_uint32_array(nvlist_t *, const char *, + const uint32_t *, uint_t); +_SYS_NVPAIR_H int nvlist_add_int64_array(nvlist_t *, const char *, + const int64_t *, uint_t); +_SYS_NVPAIR_H int nvlist_add_uint64_array(nvlist_t *, const char *, + const uint64_t *, uint_t); _SYS_NVPAIR_H int nvlist_add_string_array(nvlist_t *, const char *, - char * const *, uint_t); + const char * const *, uint_t); _SYS_NVPAIR_H int nvlist_add_nvlist_array(nvlist_t *, const char *, - nvlist_t **, uint_t); + const nvlist_t * const *, uint_t); _SYS_NVPAIR_H int nvlist_add_hrtime(nvlist_t *, const char *, hrtime_t); #if !defined(_KERNEL) && !defined(_STANDALONE) _SYS_NVPAIR_H int nvlist_add_double(nvlist_t *, const char *, double); @@ -213,18 +213,25 @@ _SYS_NVPAIR_H int nvlist_remove(nvlist_t *, const char *, data_type_t); _SYS_NVPAIR_H int nvlist_remove_all(nvlist_t *, const char *); _SYS_NVPAIR_H int nvlist_remove_nvpair(nvlist_t *, nvpair_t *); -_SYS_NVPAIR_H int nvlist_lookup_boolean(nvlist_t *, const char *); -_SYS_NVPAIR_H int nvlist_lookup_boolean_value(nvlist_t *, const char *, +_SYS_NVPAIR_H int nvlist_lookup_boolean(const nvlist_t *, const char *); +_SYS_NVPAIR_H int nvlist_lookup_boolean_value(const nvlist_t *, const char *, boolean_t *); -_SYS_NVPAIR_H int nvlist_lookup_byte(nvlist_t *, const char *, uchar_t *); -_SYS_NVPAIR_H int nvlist_lookup_int8(nvlist_t *, const char *, int8_t *); -_SYS_NVPAIR_H int nvlist_lookup_uint8(nvlist_t *, const char *, uint8_t *); -_SYS_NVPAIR_H int nvlist_lookup_int16(nvlist_t *, const char *, int16_t *); -_SYS_NVPAIR_H int nvlist_lookup_uint16(nvlist_t *, const char *, uint16_t *); -_SYS_NVPAIR_H int nvlist_lookup_int32(nvlist_t *, const char *, int32_t *); -_SYS_NVPAIR_H int nvlist_lookup_uint32(nvlist_t *, const char *, uint32_t *); -_SYS_NVPAIR_H int nvlist_lookup_int64(nvlist_t *, const char *, int64_t *); -_SYS_NVPAIR_H int nvlist_lookup_uint64(nvlist_t *, const char *, uint64_t *); +_SYS_NVPAIR_H int nvlist_lookup_byte(const nvlist_t *, const char *, uchar_t *); +_SYS_NVPAIR_H int nvlist_lookup_int8(const nvlist_t *, const char *, int8_t *); +_SYS_NVPAIR_H int nvlist_lookup_uint8(const nvlist_t *, const char *, + uint8_t *); +_SYS_NVPAIR_H int nvlist_lookup_int16(const nvlist_t *, const char *, + int16_t *); +_SYS_NVPAIR_H int nvlist_lookup_uint16(const nvlist_t *, const char *, + uint16_t *); +_SYS_NVPAIR_H int nvlist_lookup_int32(const nvlist_t *, const char *, + int32_t *); +_SYS_NVPAIR_H int nvlist_lookup_uint32(const nvlist_t *, const char *, + uint32_t *); +_SYS_NVPAIR_H int nvlist_lookup_int64(const nvlist_t *, const char *, + int64_t *); +_SYS_NVPAIR_H int nvlist_lookup_uint64(const nvlist_t *, const char *, + uint64_t *); _SYS_NVPAIR_H int nvlist_lookup_string(nvlist_t *, const char *, char **); _SYS_NVPAIR_H int nvlist_lookup_nvlist(nvlist_t *, const char *, nvlist_t **); _SYS_NVPAIR_H int nvlist_lookup_boolean_array(nvlist_t *, const char *, @@ -254,31 +261,32 @@ _SYS_NVPAIR_H int nvlist_lookup_nvlist_array(nvlist_t *, const char *, _SYS_NVPAIR_H int nvlist_lookup_hrtime(nvlist_t *, const char *, hrtime_t *); _SYS_NVPAIR_H int nvlist_lookup_pairs(nvlist_t *, int, ...); #if !defined(_KERNEL) && !defined(_STANDALONE) -_SYS_NVPAIR_H int nvlist_lookup_double(nvlist_t *, const char *, double *); +_SYS_NVPAIR_H int nvlist_lookup_double(const nvlist_t *, const char *, + double *); #endif _SYS_NVPAIR_H int nvlist_lookup_nvpair(nvlist_t *, const char *, nvpair_t **); _SYS_NVPAIR_H int nvlist_lookup_nvpair_embedded_index(nvlist_t *, const char *, nvpair_t **, int *, char **); -_SYS_NVPAIR_H boolean_t nvlist_exists(nvlist_t *, const char *); -_SYS_NVPAIR_H boolean_t nvlist_empty(nvlist_t *); +_SYS_NVPAIR_H boolean_t nvlist_exists(const nvlist_t *, const char *); +_SYS_NVPAIR_H boolean_t nvlist_empty(const nvlist_t *); /* processing nvpair */ -_SYS_NVPAIR_H nvpair_t *nvlist_next_nvpair(nvlist_t *, nvpair_t *); -_SYS_NVPAIR_H nvpair_t *nvlist_prev_nvpair(nvlist_t *, nvpair_t *); -_SYS_NVPAIR_H char *nvpair_name(nvpair_t *); -_SYS_NVPAIR_H data_type_t nvpair_type(nvpair_t *); -_SYS_NVPAIR_H int nvpair_type_is_array(nvpair_t *); -_SYS_NVPAIR_H int nvpair_value_boolean_value(nvpair_t *, boolean_t *); -_SYS_NVPAIR_H int nvpair_value_byte(nvpair_t *, uchar_t *); -_SYS_NVPAIR_H int nvpair_value_int8(nvpair_t *, int8_t *); -_SYS_NVPAIR_H int nvpair_value_uint8(nvpair_t *, uint8_t *); -_SYS_NVPAIR_H int nvpair_value_int16(nvpair_t *, int16_t *); -_SYS_NVPAIR_H int nvpair_value_uint16(nvpair_t *, uint16_t *); -_SYS_NVPAIR_H int nvpair_value_int32(nvpair_t *, int32_t *); -_SYS_NVPAIR_H int nvpair_value_uint32(nvpair_t *, uint32_t *); -_SYS_NVPAIR_H int nvpair_value_int64(nvpair_t *, int64_t *); -_SYS_NVPAIR_H int nvpair_value_uint64(nvpair_t *, uint64_t *); +_SYS_NVPAIR_H nvpair_t *nvlist_next_nvpair(nvlist_t *, const nvpair_t *); +_SYS_NVPAIR_H nvpair_t *nvlist_prev_nvpair(nvlist_t *, const nvpair_t *); +_SYS_NVPAIR_H char *nvpair_name(const nvpair_t *); +_SYS_NVPAIR_H data_type_t nvpair_type(const nvpair_t *); +_SYS_NVPAIR_H int nvpair_type_is_array(const nvpair_t *); +_SYS_NVPAIR_H int nvpair_value_boolean_value(const nvpair_t *, boolean_t *); +_SYS_NVPAIR_H int nvpair_value_byte(const nvpair_t *, uchar_t *); +_SYS_NVPAIR_H int nvpair_value_int8(const nvpair_t *, int8_t *); +_SYS_NVPAIR_H int nvpair_value_uint8(const nvpair_t *, uint8_t *); +_SYS_NVPAIR_H int nvpair_value_int16(const nvpair_t *, int16_t *); +_SYS_NVPAIR_H int nvpair_value_uint16(const nvpair_t *, uint16_t *); +_SYS_NVPAIR_H int nvpair_value_int32(const nvpair_t *, int32_t *); +_SYS_NVPAIR_H int nvpair_value_uint32(const nvpair_t *, uint32_t *); +_SYS_NVPAIR_H int nvpair_value_int64(const nvpair_t *, int64_t *); +_SYS_NVPAIR_H int nvpair_value_uint64(const nvpair_t *, uint64_t *); _SYS_NVPAIR_H int nvpair_value_string(nvpair_t *, char **); _SYS_NVPAIR_H int nvpair_value_nvlist(nvpair_t *, nvlist_t **); _SYS_NVPAIR_H int nvpair_value_boolean_array(nvpair_t *, boolean_t **, @@ -296,7 +304,7 @@ _SYS_NVPAIR_H int nvpair_value_string_array(nvpair_t *, char ***, uint_t *); _SYS_NVPAIR_H int nvpair_value_nvlist_array(nvpair_t *, nvlist_t ***, uint_t *); _SYS_NVPAIR_H int nvpair_value_hrtime(nvpair_t *, hrtime_t *); #if !defined(_KERNEL) && !defined(_STANDALONE) -_SYS_NVPAIR_H int nvpair_value_double(nvpair_t *, double *); +_SYS_NVPAIR_H int nvpair_value_double(const nvpair_t *, double *); #endif _SYS_NVPAIR_H nvlist_t *fnvlist_alloc(void); @@ -305,7 +313,7 @@ _SYS_NVPAIR_H size_t fnvlist_size(nvlist_t *); _SYS_NVPAIR_H char *fnvlist_pack(nvlist_t *, size_t *); _SYS_NVPAIR_H void fnvlist_pack_free(char *, size_t); _SYS_NVPAIR_H nvlist_t *fnvlist_unpack(char *, size_t); -_SYS_NVPAIR_H nvlist_t *fnvlist_dup(nvlist_t *); +_SYS_NVPAIR_H nvlist_t *fnvlist_dup(const nvlist_t *); _SYS_NVPAIR_H void fnvlist_merge(nvlist_t *, nvlist_t *); _SYS_NVPAIR_H size_t fnvlist_num_pairs(nvlist_t *); @@ -325,45 +333,46 @@ _SYS_NVPAIR_H void fnvlist_add_string(nvlist_t *, const char *, const char *); _SYS_NVPAIR_H void fnvlist_add_nvlist(nvlist_t *, const char *, nvlist_t *); _SYS_NVPAIR_H void fnvlist_add_nvpair(nvlist_t *, nvpair_t *); _SYS_NVPAIR_H void fnvlist_add_boolean_array(nvlist_t *, const char *, - boolean_t *, uint_t); -_SYS_NVPAIR_H void fnvlist_add_byte_array(nvlist_t *, const char *, uchar_t *, - uint_t); -_SYS_NVPAIR_H void fnvlist_add_int8_array(nvlist_t *, const char *, int8_t *, - uint_t); -_SYS_NVPAIR_H void fnvlist_add_uint8_array(nvlist_t *, const char *, uint8_t *, - uint_t); -_SYS_NVPAIR_H void fnvlist_add_int16_array(nvlist_t *, const char *, int16_t *, - uint_t); + const boolean_t *, uint_t); +_SYS_NVPAIR_H void fnvlist_add_byte_array(nvlist_t *, const char *, + const uchar_t *, uint_t); +_SYS_NVPAIR_H void fnvlist_add_int8_array(nvlist_t *, const char *, + const int8_t *, uint_t); +_SYS_NVPAIR_H void fnvlist_add_uint8_array(nvlist_t *, const char *, + const uint8_t *, uint_t); +_SYS_NVPAIR_H void fnvlist_add_int16_array(nvlist_t *, const char *, + const int16_t *, uint_t); _SYS_NVPAIR_H void fnvlist_add_uint16_array(nvlist_t *, const char *, - uint16_t *, uint_t); -_SYS_NVPAIR_H void fnvlist_add_int32_array(nvlist_t *, const char *, int32_t *, - uint_t); + const uint16_t *, uint_t); +_SYS_NVPAIR_H void fnvlist_add_int32_array(nvlist_t *, const char *, + const int32_t *, uint_t); _SYS_NVPAIR_H void fnvlist_add_uint32_array(nvlist_t *, const char *, - uint32_t *, uint_t); -_SYS_NVPAIR_H void fnvlist_add_int64_array(nvlist_t *, const char *, int64_t *, - uint_t); + const uint32_t *, uint_t); +_SYS_NVPAIR_H void fnvlist_add_int64_array(nvlist_t *, const char *, + const int64_t *, uint_t); _SYS_NVPAIR_H void fnvlist_add_uint64_array(nvlist_t *, const char *, - uint64_t *, uint_t); + const uint64_t *, uint_t); _SYS_NVPAIR_H void fnvlist_add_string_array(nvlist_t *, const char *, - char * const *, uint_t); + const char * const *, uint_t); _SYS_NVPAIR_H void fnvlist_add_nvlist_array(nvlist_t *, const char *, - nvlist_t **, uint_t); + const nvlist_t * const *, uint_t); _SYS_NVPAIR_H void fnvlist_remove(nvlist_t *, const char *); _SYS_NVPAIR_H void fnvlist_remove_nvpair(nvlist_t *, nvpair_t *); _SYS_NVPAIR_H nvpair_t *fnvlist_lookup_nvpair(nvlist_t *, const char *); -_SYS_NVPAIR_H boolean_t fnvlist_lookup_boolean(nvlist_t *, const char *); -_SYS_NVPAIR_H boolean_t fnvlist_lookup_boolean_value(nvlist_t *, const char *); -_SYS_NVPAIR_H uchar_t fnvlist_lookup_byte(nvlist_t *, const char *); -_SYS_NVPAIR_H int8_t fnvlist_lookup_int8(nvlist_t *, const char *); -_SYS_NVPAIR_H int16_t fnvlist_lookup_int16(nvlist_t *, const char *); -_SYS_NVPAIR_H int32_t fnvlist_lookup_int32(nvlist_t *, const char *); -_SYS_NVPAIR_H int64_t fnvlist_lookup_int64(nvlist_t *, const char *); -_SYS_NVPAIR_H uint8_t fnvlist_lookup_uint8(nvlist_t *, const char *); -_SYS_NVPAIR_H uint16_t fnvlist_lookup_uint16(nvlist_t *, const char *); -_SYS_NVPAIR_H uint32_t fnvlist_lookup_uint32(nvlist_t *, const char *); -_SYS_NVPAIR_H uint64_t fnvlist_lookup_uint64(nvlist_t *, const char *); +_SYS_NVPAIR_H boolean_t fnvlist_lookup_boolean(const nvlist_t *, const char *); +_SYS_NVPAIR_H boolean_t fnvlist_lookup_boolean_value(const nvlist_t *, + const char *); +_SYS_NVPAIR_H uchar_t fnvlist_lookup_byte(const nvlist_t *, const char *); +_SYS_NVPAIR_H int8_t fnvlist_lookup_int8(const nvlist_t *, const char *); +_SYS_NVPAIR_H int16_t fnvlist_lookup_int16(const nvlist_t *, const char *); +_SYS_NVPAIR_H int32_t fnvlist_lookup_int32(const nvlist_t *, const char *); +_SYS_NVPAIR_H int64_t fnvlist_lookup_int64(const nvlist_t *, const char *); +_SYS_NVPAIR_H uint8_t fnvlist_lookup_uint8(const nvlist_t *, const char *); +_SYS_NVPAIR_H uint16_t fnvlist_lookup_uint16(const nvlist_t *, const char *); +_SYS_NVPAIR_H uint32_t fnvlist_lookup_uint32(const nvlist_t *, const char *); +_SYS_NVPAIR_H uint64_t fnvlist_lookup_uint64(const nvlist_t *, const char *); _SYS_NVPAIR_H char *fnvlist_lookup_string(nvlist_t *, const char *); _SYS_NVPAIR_H nvlist_t *fnvlist_lookup_nvlist(nvlist_t *, const char *); _SYS_NVPAIR_H boolean_t *fnvlist_lookup_boolean_array(nvlist_t *, const char *, @@ -387,16 +396,16 @@ _SYS_NVPAIR_H int64_t *fnvlist_lookup_int64_array(nvlist_t *, const char *, _SYS_NVPAIR_H uint64_t *fnvlist_lookup_uint64_array(nvlist_t *, const char *, uint_t *); -_SYS_NVPAIR_H boolean_t fnvpair_value_boolean_value(nvpair_t *nvp); -_SYS_NVPAIR_H uchar_t fnvpair_value_byte(nvpair_t *nvp); -_SYS_NVPAIR_H int8_t fnvpair_value_int8(nvpair_t *nvp); -_SYS_NVPAIR_H int16_t fnvpair_value_int16(nvpair_t *nvp); -_SYS_NVPAIR_H int32_t fnvpair_value_int32(nvpair_t *nvp); -_SYS_NVPAIR_H int64_t fnvpair_value_int64(nvpair_t *nvp); -_SYS_NVPAIR_H uint8_t fnvpair_value_uint8(nvpair_t *nvp); -_SYS_NVPAIR_H uint16_t fnvpair_value_uint16(nvpair_t *nvp); -_SYS_NVPAIR_H uint32_t fnvpair_value_uint32(nvpair_t *nvp); -_SYS_NVPAIR_H uint64_t fnvpair_value_uint64(nvpair_t *nvp); +_SYS_NVPAIR_H boolean_t fnvpair_value_boolean_value(const nvpair_t *nvp); +_SYS_NVPAIR_H uchar_t fnvpair_value_byte(const nvpair_t *nvp); +_SYS_NVPAIR_H int8_t fnvpair_value_int8(const nvpair_t *nvp); +_SYS_NVPAIR_H int16_t fnvpair_value_int16(const nvpair_t *nvp); +_SYS_NVPAIR_H int32_t fnvpair_value_int32(const nvpair_t *nvp); +_SYS_NVPAIR_H int64_t fnvpair_value_int64(const nvpair_t *nvp); +_SYS_NVPAIR_H uint8_t fnvpair_value_uint8(const nvpair_t *nvp); +_SYS_NVPAIR_H uint16_t fnvpair_value_uint16(const nvpair_t *nvp); +_SYS_NVPAIR_H uint32_t fnvpair_value_uint32(const nvpair_t *nvp); +_SYS_NVPAIR_H uint64_t fnvpair_value_uint64(const nvpair_t *nvp); _SYS_NVPAIR_H char *fnvpair_value_string(nvpair_t *nvp); _SYS_NVPAIR_H nvlist_t *fnvpair_value_nvlist(nvpair_t *nvp); diff --git a/include/sys/nvpair_impl.h b/include/sys/nvpair_impl.h index c9874b3e4db7..809e5c454712 100644 --- a/include/sys/nvpair_impl.h +++ b/include/sys/nvpair_impl.h @@ -74,7 +74,7 @@ struct i_nvp { typedef struct { i_nvp_t *nvp_list; /* linked list of nvpairs */ i_nvp_t *nvp_last; /* last nvpair */ - i_nvp_t *nvp_curr; /* current walker nvpair */ + const i_nvp_t *nvp_curr; /* current walker nvpair */ nv_alloc_t *nvp_nva; /* pluggable allocator */ uint32_t nvp_stat; /* internal state */ diff --git a/lib/libnvpair/libnvpair.abi b/lib/libnvpair/libnvpair.abi index 9c27d178dc05..4a001c3dc3a6 100644 --- a/lib/libnvpair/libnvpair.abi +++ b/lib/libnvpair/libnvpair.abi @@ -3,6 +3,8 @@ + + @@ -262,7 +264,7 @@ - + @@ -359,84 +361,84 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -456,57 +458,57 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -581,43 +583,43 @@ - + - + - + - + - + - + - + - + - + - + @@ -631,9 +633,35 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -689,13 +717,13 @@ - + - + @@ -796,77 +824,77 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -879,109 +907,109 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1109,62 +1137,62 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -1314,10 +1342,6 @@ - - - - @@ -1330,7 +1354,6 @@ - @@ -1752,17 +1775,16 @@ - - + - + - + @@ -1799,26 +1821,18 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + @@ -1887,16 +1901,16 @@ - + - + - + - + @@ -1908,13 +1922,30 @@ + + + + + + + + + + + + + + + + + + + - - @@ -1983,7 +2014,6 @@ - @@ -1992,10 +2022,6 @@ - - - - @@ -2684,6 +2710,7 @@ + diff --git a/lib/libuutil/libuutil.abi b/lib/libuutil/libuutil.abi index c7ab5672eace..48575ebc6a9f 100644 --- a/lib/libuutil/libuutil.abi +++ b/lib/libuutil/libuutil.abi @@ -5,6 +5,8 @@ + + @@ -853,9 +855,6 @@ - - - @@ -890,66 +889,18 @@ - + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - @@ -1018,16 +969,16 @@ - + - + - + - + @@ -1039,6 +990,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1049,16 +1059,11 @@ - - - - - @@ -1114,7 +1119,6 @@ - @@ -1147,6 +1151,7 @@ + @@ -1299,6 +1304,15 @@ + + + + + + + + + @@ -1325,15 +1339,6 @@ - - - - - - - - - diff --git a/lib/libzfs/libzfs.abi b/lib/libzfs/libzfs.abi index 8a696206a56f..9bd1fd0db0e9 100644 --- a/lib/libzfs/libzfs.abi +++ b/lib/libzfs/libzfs.abi @@ -10,11 +10,14 @@ + + + @@ -1398,9 +1401,6 @@ - - - @@ -1421,66 +1421,18 @@ - + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - @@ -1549,16 +1501,16 @@ - + - + - + - + @@ -1570,6 +1522,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1580,15 +1591,10 @@ - - - - - @@ -2901,9 +2907,6 @@ - - - @@ -3146,17 +3149,16 @@ - - + - + - + @@ -3210,6 +3212,15 @@ + + + + + + + + + @@ -3236,15 +3247,6 @@ - - - - - - - - - @@ -3262,7 +3264,6 @@ - @@ -3270,7 +3271,6 @@ - @@ -4175,6 +4175,10 @@ + + + + @@ -5619,7 +5623,6 @@ - diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index 6e302ad4b396..867b72f2da07 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -3807,8 +3807,8 @@ zpool_vdev_split(zpool_handle_t *zhp, char *newname, nvlist_t **newroot, } /* Add all the children we found */ - if (nvlist_add_nvlist_array(*newroot, ZPOOL_CONFIG_CHILDREN, varray, - lastlog == 0 ? vcount : lastlog) != 0) + if (nvlist_add_nvlist_array(*newroot, ZPOOL_CONFIG_CHILDREN, + (const nvlist_t **)varray, lastlog == 0 ? vcount : lastlog) != 0) goto out; /* @@ -4551,7 +4551,7 @@ zpool_get_history(zpool_handle_t *zhp, nvlist_t **nvhisp, uint64_t *off, if (!err) { verify(nvlist_alloc(nvhisp, NV_UNIQUE_NAME, 0) == 0); verify(nvlist_add_nvlist_array(*nvhisp, ZPOOL_HIST_RECORD, - records, numrecords) == 0); + (const nvlist_t **)records, numrecords) == 0); } for (i = 0; i < numrecords; i++) nvlist_free(records[i]); diff --git a/lib/libzfs_core/libzfs_core.abi b/lib/libzfs_core/libzfs_core.abi index 4f4d7f6ab771..5a3cbaf0b80d 100644 --- a/lib/libzfs_core/libzfs_core.abi +++ b/lib/libzfs_core/libzfs_core.abi @@ -6,6 +6,8 @@ + + @@ -713,9 +715,6 @@ - - - @@ -750,66 +749,18 @@ - + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - @@ -878,16 +829,16 @@ - + - + - + - + @@ -899,6 +850,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -909,16 +919,11 @@ - - - - - @@ -1004,7 +1009,6 @@ - @@ -1912,6 +1916,7 @@ + diff --git a/lib/libzfsbootenv/libzfsbootenv.abi b/lib/libzfsbootenv/libzfsbootenv.abi index 86ec25cf8470..f1401a14f7a0 100644 --- a/lib/libzfsbootenv/libzfsbootenv.abi +++ b/lib/libzfsbootenv/libzfsbootenv.abi @@ -5,6 +5,8 @@ + + @@ -18,7 +20,6 @@ - @@ -83,16 +84,21 @@ - - - - - - + + + + + + + + + + + @@ -161,16 +167,16 @@ - + - + - + - + @@ -182,20 +188,19 @@ + + + - - - - - + diff --git a/lib/libzfsbootenv/lzbe_pair.c b/lib/libzfsbootenv/lzbe_pair.c index 831355ba4b7c..b92225984517 100644 --- a/lib/libzfsbootenv/lzbe_pair.c +++ b/lib/libzfsbootenv/lzbe_pair.c @@ -293,7 +293,8 @@ lzbe_add_pair(void *ptr, const char *key, const char *type, void *value, break; case DATA_TYPE_NVLIST_ARRAY: - rv = nvlist_add_nvlist_array(nv, key, value, size); + rv = nvlist_add_nvlist_array(nv, key, (const nvlist_t **)value, + size); break; case DATA_TYPE_BOOLEAN_VALUE: diff --git a/lib/libzutil/zutil_import.c b/lib/libzutil/zutil_import.c index f637e680c841..4d956fdd8056 100644 --- a/lib/libzutil/zutil_import.c +++ b/lib/libzutil/zutil_import.c @@ -749,7 +749,7 @@ get_configs(libpc_handle_t *hdl, pool_list_t *pl, boolean_t active_ok, nvlist_add_uint64(nvroot, ZPOOL_CONFIG_ID, 0ULL) != 0 || nvlist_add_uint64(nvroot, ZPOOL_CONFIG_GUID, guid) != 0 || nvlist_add_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN, - child, children) != 0) { + (const nvlist_t **)child, children) != 0) { nvlist_free(nvroot); goto nomem; } diff --git a/module/nvpair/fnvpair.c b/module/nvpair/fnvpair.c index dc8257e48594..3a4f07486808 100644 --- a/module/nvpair/fnvpair.c +++ b/module/nvpair/fnvpair.c @@ -102,7 +102,7 @@ fnvlist_unpack(char *buf, size_t buflen) } nvlist_t * -fnvlist_dup(nvlist_t *nvl) +fnvlist_dup(const nvlist_t *nvl) { nvlist_t *rv; VERIFY0(nvlist_dup(nvl, &rv, KM_SLEEP)); @@ -213,78 +213,84 @@ fnvlist_add_nvpair(nvlist_t *nvl, nvpair_t *pair) void fnvlist_add_boolean_array(nvlist_t *nvl, const char *name, - boolean_t *val, uint_t n) + const boolean_t *val, uint_t n) { VERIFY0(nvlist_add_boolean_array(nvl, name, val, n)); } void -fnvlist_add_byte_array(nvlist_t *nvl, const char *name, uchar_t *val, uint_t n) +fnvlist_add_byte_array(nvlist_t *nvl, const char *name, const uchar_t *val, + uint_t n) { VERIFY0(nvlist_add_byte_array(nvl, name, val, n)); } void -fnvlist_add_int8_array(nvlist_t *nvl, const char *name, int8_t *val, uint_t n) +fnvlist_add_int8_array(nvlist_t *nvl, const char *name, const int8_t *val, + uint_t n) { VERIFY0(nvlist_add_int8_array(nvl, name, val, n)); } void -fnvlist_add_uint8_array(nvlist_t *nvl, const char *name, uint8_t *val, uint_t n) +fnvlist_add_uint8_array(nvlist_t *nvl, const char *name, const uint8_t *val, + uint_t n) { VERIFY0(nvlist_add_uint8_array(nvl, name, val, n)); } void -fnvlist_add_int16_array(nvlist_t *nvl, const char *name, int16_t *val, uint_t n) +fnvlist_add_int16_array(nvlist_t *nvl, const char *name, const int16_t *val, + uint_t n) { VERIFY0(nvlist_add_int16_array(nvl, name, val, n)); } void fnvlist_add_uint16_array(nvlist_t *nvl, const char *name, - uint16_t *val, uint_t n) + const uint16_t *val, uint_t n) { VERIFY0(nvlist_add_uint16_array(nvl, name, val, n)); } void -fnvlist_add_int32_array(nvlist_t *nvl, const char *name, int32_t *val, uint_t n) +fnvlist_add_int32_array(nvlist_t *nvl, const char *name, const int32_t *val, + uint_t n) { VERIFY0(nvlist_add_int32_array(nvl, name, val, n)); } void fnvlist_add_uint32_array(nvlist_t *nvl, const char *name, - uint32_t *val, uint_t n) + const uint32_t *val, uint_t n) { VERIFY0(nvlist_add_uint32_array(nvl, name, val, n)); } void -fnvlist_add_int64_array(nvlist_t *nvl, const char *name, int64_t *val, uint_t n) +fnvlist_add_int64_array(nvlist_t *nvl, const char *name, const int64_t *val, + uint_t n) { VERIFY0(nvlist_add_int64_array(nvl, name, val, n)); } void fnvlist_add_uint64_array(nvlist_t *nvl, const char *name, - uint64_t *val, uint_t n) + const uint64_t *val, uint_t n) { VERIFY0(nvlist_add_uint64_array(nvl, name, val, n)); } void fnvlist_add_string_array(nvlist_t *nvl, const char *name, - char * const *val, uint_t n) + const char * const *val, uint_t n) { VERIFY0(nvlist_add_string_array(nvl, name, val, n)); } void fnvlist_add_nvlist_array(nvlist_t *nvl, const char *name, - nvlist_t **val, uint_t n) + const nvlist_t * const *val, uint_t n) { VERIFY0(nvlist_add_nvlist_array(nvl, name, val, n)); } @@ -311,13 +317,13 @@ fnvlist_lookup_nvpair(nvlist_t *nvl, const char *name) /* returns B_TRUE if the entry exists */ boolean_t -fnvlist_lookup_boolean(nvlist_t *nvl, const char *name) +fnvlist_lookup_boolean(const nvlist_t *nvl, const char *name) { return (nvlist_lookup_boolean(nvl, name) == 0); } boolean_t -fnvlist_lookup_boolean_value(nvlist_t *nvl, const char *name) +fnvlist_lookup_boolean_value(const nvlist_t *nvl, const char *name) { boolean_t rv; VERIFY0(nvlist_lookup_boolean_value(nvl, name, &rv)); @@ -325,7 +331,7 @@ fnvlist_lookup_boolean_value(nvlist_t *nvl, const char *name) } uchar_t -fnvlist_lookup_byte(nvlist_t *nvl, const char *name) +fnvlist_lookup_byte(const nvlist_t *nvl, const char *name) { uchar_t rv; VERIFY0(nvlist_lookup_byte(nvl, name, &rv)); @@ -333,7 +339,7 @@ fnvlist_lookup_byte(nvlist_t *nvl, const char *name) } int8_t -fnvlist_lookup_int8(nvlist_t *nvl, const char *name) +fnvlist_lookup_int8(const nvlist_t *nvl, const char *name) { int8_t rv; VERIFY0(nvlist_lookup_int8(nvl, name, &rv)); @@ -341,7 +347,7 @@ fnvlist_lookup_int8(nvlist_t *nvl, const char *name) } int16_t -fnvlist_lookup_int16(nvlist_t *nvl, const char *name) +fnvlist_lookup_int16(const nvlist_t *nvl, const char *name) { int16_t rv; VERIFY0(nvlist_lookup_int16(nvl, name, &rv)); @@ -349,7 +355,7 @@ fnvlist_lookup_int16(nvlist_t *nvl, const char *name) } int32_t -fnvlist_lookup_int32(nvlist_t *nvl, const char *name) +fnvlist_lookup_int32(const nvlist_t *nvl, const char *name) { int32_t rv; VERIFY0(nvlist_lookup_int32(nvl, name, &rv)); @@ -357,7 +363,7 @@ fnvlist_lookup_int32(nvlist_t *nvl, const char *name) } int64_t -fnvlist_lookup_int64(nvlist_t *nvl, const char *name) +fnvlist_lookup_int64(const nvlist_t *nvl, const char *name) { int64_t rv; VERIFY0(nvlist_lookup_int64(nvl, name, &rv)); @@ -365,7 +371,7 @@ fnvlist_lookup_int64(nvlist_t *nvl, const char *name) } uint8_t -fnvlist_lookup_uint8(nvlist_t *nvl, const char *name) +fnvlist_lookup_uint8(const nvlist_t *nvl, const char *name) { uint8_t rv; VERIFY0(nvlist_lookup_uint8(nvl, name, &rv)); @@ -373,7 +379,7 @@ fnvlist_lookup_uint8(nvlist_t *nvl, const char *name) } uint16_t -fnvlist_lookup_uint16(nvlist_t *nvl, const char *name) +fnvlist_lookup_uint16(const nvlist_t *nvl, const char *name) { uint16_t rv; VERIFY0(nvlist_lookup_uint16(nvl, name, &rv)); @@ -381,7 +387,7 @@ fnvlist_lookup_uint16(nvlist_t *nvl, const char *name) } uint32_t -fnvlist_lookup_uint32(nvlist_t *nvl, const char *name) +fnvlist_lookup_uint32(const nvlist_t *nvl, const char *name) { uint32_t rv; VERIFY0(nvlist_lookup_uint32(nvl, name, &rv)); @@ -389,7 +395,7 @@ fnvlist_lookup_uint32(nvlist_t *nvl, const char *name) } uint64_t -fnvlist_lookup_uint64(nvlist_t *nvl, const char *name) +fnvlist_lookup_uint64(const nvlist_t *nvl, const char *name) { uint64_t rv; VERIFY0(nvlist_lookup_uint64(nvl, name, &rv)); @@ -492,7 +498,7 @@ fnvlist_lookup_uint64_array(nvlist_t *nvl, const char *name, uint_t *n) } boolean_t -fnvpair_value_boolean_value(nvpair_t *nvp) +fnvpair_value_boolean_value(const nvpair_t *nvp) { boolean_t rv; VERIFY0(nvpair_value_boolean_value(nvp, &rv)); @@ -500,7 +506,7 @@ fnvpair_value_boolean_value(nvpair_t *nvp) } uchar_t -fnvpair_value_byte(nvpair_t *nvp) +fnvpair_value_byte(const nvpair_t *nvp) { uchar_t rv; VERIFY0(nvpair_value_byte(nvp, &rv)); @@ -508,7 +514,7 @@ fnvpair_value_byte(nvpair_t *nvp) } int8_t -fnvpair_value_int8(nvpair_t *nvp) +fnvpair_value_int8(const nvpair_t *nvp) { int8_t rv; VERIFY0(nvpair_value_int8(nvp, &rv)); @@ -516,7 +522,7 @@ fnvpair_value_int8(nvpair_t *nvp) } int16_t -fnvpair_value_int16(nvpair_t *nvp) +fnvpair_value_int16(const nvpair_t *nvp) { int16_t rv; VERIFY0(nvpair_value_int16(nvp, &rv)); @@ -524,7 +530,7 @@ fnvpair_value_int16(nvpair_t *nvp) } int32_t -fnvpair_value_int32(nvpair_t *nvp) +fnvpair_value_int32(const nvpair_t *nvp) { int32_t rv; VERIFY0(nvpair_value_int32(nvp, &rv)); @@ -532,7 +538,7 @@ fnvpair_value_int32(nvpair_t *nvp) } int64_t -fnvpair_value_int64(nvpair_t *nvp) +fnvpair_value_int64(const nvpair_t *nvp) { int64_t rv; VERIFY0(nvpair_value_int64(nvp, &rv)); @@ -540,7 +546,7 @@ fnvpair_value_int64(nvpair_t *nvp) } uint8_t -fnvpair_value_uint8(nvpair_t *nvp) +fnvpair_value_uint8(const nvpair_t *nvp) { uint8_t rv; VERIFY0(nvpair_value_uint8(nvp, &rv)); @@ -548,7 +554,7 @@ fnvpair_value_uint8(nvpair_t *nvp) } uint16_t -fnvpair_value_uint16(nvpair_t *nvp) +fnvpair_value_uint16(const nvpair_t *nvp) { uint16_t rv; VERIFY0(nvpair_value_uint16(nvp, &rv)); @@ -556,7 +562,7 @@ fnvpair_value_uint16(nvpair_t *nvp) } uint32_t -fnvpair_value_uint32(nvpair_t *nvp) +fnvpair_value_uint32(const nvpair_t *nvp) { uint32_t rv; VERIFY0(nvpair_value_uint32(nvp, &rv)); @@ -564,7 +570,7 @@ fnvpair_value_uint32(nvpair_t *nvp) } uint64_t -fnvpair_value_uint64(nvpair_t *nvp) +fnvpair_value_uint64(const nvpair_t *nvp) { uint64_t rv; VERIFY0(nvpair_value_uint64(nvp, &rv)); diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c index 9834dedd859d..668e4a978105 100644 --- a/module/nvpair/nvpair.c +++ b/module/nvpair/nvpair.c @@ -308,7 +308,7 @@ nvt_hash(const char *p) } static boolean_t -nvt_nvpair_match(nvpair_t *nvp1, nvpair_t *nvp2, uint32_t nvflag) +nvt_nvpair_match(const nvpair_t *nvp1, const nvpair_t *nvp2, uint32_t nvflag) { boolean_t match = B_FALSE; if (nvflag & NV_UNIQUE_NAME_TYPE) { @@ -324,9 +324,9 @@ nvt_nvpair_match(nvpair_t *nvp1, nvpair_t *nvp2, uint32_t nvflag) } static nvpair_t * -nvt_lookup_name_type(nvlist_t *nvl, const char *name, data_type_t type) +nvt_lookup_name_type(const nvlist_t *nvl, const char *name, data_type_t type) { - nvpriv_t *priv = (nvpriv_t *)(uintptr_t)nvl->nvl_priv; + const nvpriv_t *priv = (const nvpriv_t *)(uintptr_t)nvl->nvl_priv; ASSERT(priv != NULL); i_nvp_t **tab = priv->nvp_hashtable; @@ -356,7 +356,7 @@ nvt_lookup_name_type(nvlist_t *nvl, const char *name, data_type_t type) } static nvpair_t * -nvt_lookup_name(nvlist_t *nvl, const char *name) +nvt_lookup_name(const nvlist_t *nvl, const char *name) { return (nvt_lookup_name_type(nvl, name, DATA_TYPE_DONTCARE)); } @@ -462,7 +462,7 @@ nvt_shrink(nvpriv_t *priv) } static int -nvt_remove_nvpair(nvlist_t *nvl, nvpair_t *nvp) +nvt_remove_nvpair(nvlist_t *nvl, const nvpair_t *nvp) { nvpriv_t *priv = (nvpriv_t *)(uintptr_t)nvl->nvl_priv; @@ -816,16 +816,16 @@ i_validate_nvpair(nvpair_t *nvp) } static int -nvlist_copy_pairs(nvlist_t *snvl, nvlist_t *dnvl) +nvlist_copy_pairs(const nvlist_t *snvl, nvlist_t *dnvl) { - nvpriv_t *priv; - i_nvp_t *curr; + const nvpriv_t *priv; + const i_nvp_t *curr; - if ((priv = (nvpriv_t *)(uintptr_t)snvl->nvl_priv) == NULL) + if ((priv = (const nvpriv_t *)(uintptr_t)snvl->nvl_priv) == NULL) return (EINVAL); for (curr = priv->nvp_list; curr != NULL; curr = curr->nvi_next) { - nvpair_t *nvp = &curr->nvi_nvp; + const nvpair_t *nvp = &curr->nvi_nvp; int err; if ((err = nvlist_add_common(dnvl, NVP_NAME(nvp), NVP_TYPE(nvp), @@ -896,10 +896,10 @@ nvlist_free(nvlist_t *nvl) } static int -nvlist_contains_nvp(nvlist_t *nvl, nvpair_t *nvp) +nvlist_contains_nvp(const nvlist_t *nvl, const nvpair_t *nvp) { - nvpriv_t *priv = (nvpriv_t *)(uintptr_t)nvl->nvl_priv; - i_nvp_t *curr; + const nvpriv_t *priv = (const nvpriv_t *)(uintptr_t)nvl->nvl_priv; + const i_nvp_t *curr; if (nvp == NULL) return (0); @@ -915,13 +915,13 @@ nvlist_contains_nvp(nvlist_t *nvl, nvpair_t *nvp) * Make a copy of nvlist */ int -nvlist_dup(nvlist_t *nvl, nvlist_t **nvlp, int kmflag) +nvlist_dup(const nvlist_t *nvl, nvlist_t **nvlp, int kmflag) { return (nvlist_xdup(nvl, nvlp, nvlist_nv_alloc(kmflag))); } int -nvlist_xdup(nvlist_t *nvl, nvlist_t **nvlp, nv_alloc_t *nva) +nvlist_xdup(const nvlist_t *nvl, nvlist_t **nvlp, nv_alloc_t *nva) { int err; nvlist_t *ret; @@ -1356,68 +1356,77 @@ nvlist_add_string(nvlist_t *nvl, const char *name, const char *val) int nvlist_add_boolean_array(nvlist_t *nvl, const char *name, - boolean_t *a, uint_t n) + const boolean_t *a, uint_t n) { return (nvlist_add_common(nvl, name, DATA_TYPE_BOOLEAN_ARRAY, n, a)); } int -nvlist_add_byte_array(nvlist_t *nvl, const char *name, uchar_t *a, uint_t n) +nvlist_add_byte_array(nvlist_t *nvl, const char *name, const uchar_t *a, + uint_t n) { return (nvlist_add_common(nvl, name, DATA_TYPE_BYTE_ARRAY, n, a)); } int -nvlist_add_int8_array(nvlist_t *nvl, const char *name, int8_t *a, uint_t n) +nvlist_add_int8_array(nvlist_t *nvl, const char *name, const int8_t *a, + uint_t n) { return (nvlist_add_common(nvl, name, DATA_TYPE_INT8_ARRAY, n, a)); } int -nvlist_add_uint8_array(nvlist_t *nvl, const char *name, uint8_t *a, uint_t n) +nvlist_add_uint8_array(nvlist_t *nvl, const char *name, const uint8_t *a, + uint_t n) { return (nvlist_add_common(nvl, name, DATA_TYPE_UINT8_ARRAY, n, a)); } int -nvlist_add_int16_array(nvlist_t *nvl, const char *name, int16_t *a, uint_t n) +nvlist_add_int16_array(nvlist_t *nvl, const char *name, const int16_t *a, + uint_t n) { return (nvlist_add_common(nvl, name, DATA_TYPE_INT16_ARRAY, n, a)); } int -nvlist_add_uint16_array(nvlist_t *nvl, const char *name, uint16_t *a, uint_t n) +nvlist_add_uint16_array(nvlist_t *nvl, const char *name, const uint16_t *a, + uint_t n) { return (nvlist_add_common(nvl, name, DATA_TYPE_UINT16_ARRAY, n, a)); } int -nvlist_add_int32_array(nvlist_t *nvl, const char *name, int32_t *a, uint_t n) +nvlist_add_int32_array(nvlist_t *nvl, const char *name, const int32_t *a, + uint_t n) { return (nvlist_add_common(nvl, name, DATA_TYPE_INT32_ARRAY, n, a)); } int -nvlist_add_uint32_array(nvlist_t *nvl, const char *name, uint32_t *a, uint_t n) +nvlist_add_uint32_array(nvlist_t *nvl, const char *name, const uint32_t *a, + uint_t n) { return (nvlist_add_common(nvl, name, DATA_TYPE_UINT32_ARRAY, n, a)); } int -nvlist_add_int64_array(nvlist_t *nvl, const char *name, int64_t *a, uint_t n) +nvlist_add_int64_array(nvlist_t *nvl, const char *name, const int64_t *a, + uint_t n) { return (nvlist_add_common(nvl, name, DATA_TYPE_INT64_ARRAY, n, a)); } int -nvlist_add_uint64_array(nvlist_t *nvl, const char *name, uint64_t *a, uint_t n) +nvlist_add_uint64_array(nvlist_t *nvl, const char *name, const uint64_t *a, + uint_t n) { return (nvlist_add_common(nvl, name, DATA_TYPE_UINT64_ARRAY, n, a)); } int nvlist_add_string_array(nvlist_t *nvl, const char *name, - char *const *a, uint_t n) + const char *const *a, uint_t n) { return (nvlist_add_common(nvl, name, DATA_TYPE_STRING_ARRAY, n, a)); } @@ -1429,20 +1438,21 @@ nvlist_add_hrtime(nvlist_t *nvl, const char *name, hrtime_t val) } int -nvlist_add_nvlist(nvlist_t *nvl, const char *name, nvlist_t *val) +nvlist_add_nvlist(nvlist_t *nvl, const char *name, const nvlist_t *val) { return (nvlist_add_common(nvl, name, DATA_TYPE_NVLIST, 1, val)); } int -nvlist_add_nvlist_array(nvlist_t *nvl, const char *name, nvlist_t **a, uint_t n) +nvlist_add_nvlist_array(nvlist_t *nvl, const char *name, + const nvlist_t * const *a, uint_t n) { return (nvlist_add_common(nvl, name, DATA_TYPE_NVLIST_ARRAY, n, a)); } /* reading name-value pairs */ nvpair_t * -nvlist_next_nvpair(nvlist_t *nvl, nvpair_t *nvp) +nvlist_next_nvpair(nvlist_t *nvl, const nvpair_t *nvp) { nvpriv_t *priv; i_nvp_t *curr; @@ -1471,7 +1481,7 @@ nvlist_next_nvpair(nvlist_t *nvl, nvpair_t *nvp) } nvpair_t * -nvlist_prev_nvpair(nvlist_t *nvl, nvpair_t *nvp) +nvlist_prev_nvpair(nvlist_t *nvl, const nvpair_t *nvp) { nvpriv_t *priv; i_nvp_t *curr; @@ -1495,31 +1505,31 @@ nvlist_prev_nvpair(nvlist_t *nvl, nvpair_t *nvp) } boolean_t -nvlist_empty(nvlist_t *nvl) +nvlist_empty(const nvlist_t *nvl) { - nvpriv_t *priv; + const nvpriv_t *priv; if (nvl == NULL || - (priv = (nvpriv_t *)(uintptr_t)nvl->nvl_priv) == NULL) + (priv = (const nvpriv_t *)(uintptr_t)nvl->nvl_priv) == NULL) return (B_TRUE); return (priv->nvp_list == NULL); } char * -nvpair_name(nvpair_t *nvp) +nvpair_name(const nvpair_t *nvp) { return (NVP_NAME(nvp)); } data_type_t -nvpair_type(nvpair_t *nvp) +nvpair_type(const nvpair_t *nvp) { return (NVP_TYPE(nvp)); } int -nvpair_type_is_array(nvpair_t *nvp) +nvpair_type_is_array(const nvpair_t *nvp) { data_type_t type = NVP_TYPE(nvp); @@ -1541,7 +1551,8 @@ nvpair_type_is_array(nvpair_t *nvp) } static int -nvpair_value_common(nvpair_t *nvp, data_type_t type, uint_t *nelem, void *data) +nvpair_value_common(const nvpair_t *nvp, data_type_t type, uint_t *nelem, + void *data) { int value_sz; @@ -1585,6 +1596,10 @@ nvpair_value_common(nvpair_t *nvp, data_type_t type, uint_t *nelem, void *data) case DATA_TYPE_STRING: if (data == NULL) return (EINVAL); + /* + * This discards the const from nvp, so all callers for these + * types must not accept const nvpairs. + */ *(void **)data = (void *)NVP_VALUE(nvp); if (nelem != NULL) *nelem = 1; @@ -1604,6 +1619,10 @@ nvpair_value_common(nvpair_t *nvp, data_type_t type, uint_t *nelem, void *data) case DATA_TYPE_NVLIST_ARRAY: if (nelem == NULL || data == NULL) return (EINVAL); + /* + * This discards the const from nvp, so all callers for these + * types must not accept const nvpairs. + */ if ((*nelem = NVP_NELEM(nvp)) != 0) *(void **)data = (void *)NVP_VALUE(nvp); else @@ -1618,7 +1637,7 @@ nvpair_value_common(nvpair_t *nvp, data_type_t type, uint_t *nelem, void *data) } static int -nvlist_lookup_common(nvlist_t *nvl, const char *name, data_type_t type, +nvlist_lookup_common(const nvlist_t *nvl, const char *name, data_type_t type, uint_t *nelem, void *data) { if (name == NULL || nvl == NULL || nvl->nvl_priv == 0) @@ -1635,75 +1654,76 @@ nvlist_lookup_common(nvlist_t *nvl, const char *name, data_type_t type, } int -nvlist_lookup_boolean(nvlist_t *nvl, const char *name) +nvlist_lookup_boolean(const nvlist_t *nvl, const char *name) { return (nvlist_lookup_common(nvl, name, DATA_TYPE_BOOLEAN, NULL, NULL)); } int -nvlist_lookup_boolean_value(nvlist_t *nvl, const char *name, boolean_t *val) +nvlist_lookup_boolean_value(const nvlist_t *nvl, const char *name, + boolean_t *val) { return (nvlist_lookup_common(nvl, name, DATA_TYPE_BOOLEAN_VALUE, NULL, val)); } int -nvlist_lookup_byte(nvlist_t *nvl, const char *name, uchar_t *val) +nvlist_lookup_byte(const nvlist_t *nvl, const char *name, uchar_t *val) { return (nvlist_lookup_common(nvl, name, DATA_TYPE_BYTE, NULL, val)); } int -nvlist_lookup_int8(nvlist_t *nvl, const char *name, int8_t *val) +nvlist_lookup_int8(const nvlist_t *nvl, const char *name, int8_t *val) { return (nvlist_lookup_common(nvl, name, DATA_TYPE_INT8, NULL, val)); } int -nvlist_lookup_uint8(nvlist_t *nvl, const char *name, uint8_t *val) +nvlist_lookup_uint8(const nvlist_t *nvl, const char *name, uint8_t *val) { return (nvlist_lookup_common(nvl, name, DATA_TYPE_UINT8, NULL, val)); } int -nvlist_lookup_int16(nvlist_t *nvl, const char *name, int16_t *val) +nvlist_lookup_int16(const nvlist_t *nvl, const char *name, int16_t *val) { return (nvlist_lookup_common(nvl, name, DATA_TYPE_INT16, NULL, val)); } int -nvlist_lookup_uint16(nvlist_t *nvl, const char *name, uint16_t *val) +nvlist_lookup_uint16(const nvlist_t *nvl, const char *name, uint16_t *val) { return (nvlist_lookup_common(nvl, name, DATA_TYPE_UINT16, NULL, val)); } int -nvlist_lookup_int32(nvlist_t *nvl, const char *name, int32_t *val) +nvlist_lookup_int32(const nvlist_t *nvl, const char *name, int32_t *val) { return (nvlist_lookup_common(nvl, name, DATA_TYPE_INT32, NULL, val)); } int -nvlist_lookup_uint32(nvlist_t *nvl, const char *name, uint32_t *val) +nvlist_lookup_uint32(const nvlist_t *nvl, const char *name, uint32_t *val) { return (nvlist_lookup_common(nvl, name, DATA_TYPE_UINT32, NULL, val)); } int -nvlist_lookup_int64(nvlist_t *nvl, const char *name, int64_t *val) +nvlist_lookup_int64(const nvlist_t *nvl, const char *name, int64_t *val) { return (nvlist_lookup_common(nvl, name, DATA_TYPE_INT64, NULL, val)); } int -nvlist_lookup_uint64(nvlist_t *nvl, const char *name, uint64_t *val) +nvlist_lookup_uint64(const nvlist_t *nvl, const char *name, uint64_t *val) { return (nvlist_lookup_common(nvl, name, DATA_TYPE_UINT64, NULL, val)); } #if !defined(_KERNEL) int -nvlist_lookup_double(nvlist_t *nvl, const char *name, double *val) +nvlist_lookup_double(const nvlist_t *nvl, const char *name, double *val) { return (nvlist_lookup_common(nvl, name, DATA_TYPE_DOUBLE, NULL, val)); } @@ -2079,7 +2099,7 @@ int nvlist_lookup_nvpair_embedded_index(nvlist_t *nvl, } boolean_t -nvlist_exists(nvlist_t *nvl, const char *name) +nvlist_exists(const nvlist_t *nvl, const char *name) { nvpriv_t *priv; nvpair_t *nvp; @@ -2100,68 +2120,68 @@ nvlist_exists(nvlist_t *nvl, const char *name) } int -nvpair_value_boolean_value(nvpair_t *nvp, boolean_t *val) +nvpair_value_boolean_value(const nvpair_t *nvp, boolean_t *val) { return (nvpair_value_common(nvp, DATA_TYPE_BOOLEAN_VALUE, NULL, val)); } int -nvpair_value_byte(nvpair_t *nvp, uchar_t *val) +nvpair_value_byte(const nvpair_t *nvp, uchar_t *val) { return (nvpair_value_common(nvp, DATA_TYPE_BYTE, NULL, val)); } int -nvpair_value_int8(nvpair_t *nvp, int8_t *val) +nvpair_value_int8(const nvpair_t *nvp, int8_t *val) { return (nvpair_value_common(nvp, DATA_TYPE_INT8, NULL, val)); } int -nvpair_value_uint8(nvpair_t *nvp, uint8_t *val) +nvpair_value_uint8(const nvpair_t *nvp, uint8_t *val) { return (nvpair_value_common(nvp, DATA_TYPE_UINT8, NULL, val)); } int -nvpair_value_int16(nvpair_t *nvp, int16_t *val) +nvpair_value_int16(const nvpair_t *nvp, int16_t *val) { return (nvpair_value_common(nvp, DATA_TYPE_INT16, NULL, val)); } int -nvpair_value_uint16(nvpair_t *nvp, uint16_t *val) +nvpair_value_uint16(const nvpair_t *nvp, uint16_t *val) { return (nvpair_value_common(nvp, DATA_TYPE_UINT16, NULL, val)); } int -nvpair_value_int32(nvpair_t *nvp, int32_t *val) +nvpair_value_int32(const nvpair_t *nvp, int32_t *val) { return (nvpair_value_common(nvp, DATA_TYPE_INT32, NULL, val)); } int -nvpair_value_uint32(nvpair_t *nvp, uint32_t *val) +nvpair_value_uint32(const nvpair_t *nvp, uint32_t *val) { return (nvpair_value_common(nvp, DATA_TYPE_UINT32, NULL, val)); } int -nvpair_value_int64(nvpair_t *nvp, int64_t *val) +nvpair_value_int64(const nvpair_t *nvp, int64_t *val) { return (nvpair_value_common(nvp, DATA_TYPE_INT64, NULL, val)); } int -nvpair_value_uint64(nvpair_t *nvp, uint64_t *val) +nvpair_value_uint64(const nvpair_t *nvp, uint64_t *val) { return (nvpair_value_common(nvp, DATA_TYPE_UINT64, NULL, val)); } #if !defined(_KERNEL) int -nvpair_value_double(nvpair_t *nvp, double *val) +nvpair_value_double(const nvpair_t *nvp, double *val) { return (nvpair_value_common(nvp, DATA_TYPE_DOUBLE, NULL, val)); } diff --git a/module/os/freebsd/zfs/spa_os.c b/module/os/freebsd/zfs/spa_os.c index 070e7a5b9f1b..85aecaacefdd 100644 --- a/module/os/freebsd/zfs/spa_os.c +++ b/module/os/freebsd/zfs/spa_os.c @@ -152,8 +152,8 @@ spa_generate_rootconf(const char *name) fnvlist_add_string(nvroot, ZPOOL_CONFIG_TYPE, VDEV_TYPE_ROOT); fnvlist_add_uint64(nvroot, ZPOOL_CONFIG_ID, 0ULL); fnvlist_add_uint64(nvroot, ZPOOL_CONFIG_GUID, pgid); - fnvlist_add_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN, tops, - nchildren); + fnvlist_add_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN, + (const nvlist_t * const *)tops, nchildren); /* * Replace the existing vdev_tree with the new root vdev in diff --git a/module/zfs/fm.c b/module/zfs/fm.c index b8a1c7c8a5ca..cdf0fcf71556 100644 --- a/module/zfs/fm.c +++ b/module/zfs/fm.c @@ -702,7 +702,7 @@ i_fm_payload_set(nvlist_t *payload, const char *name, va_list ap) case DATA_TYPE_STRING_ARRAY: nelem = va_arg(ap, int); ret = nvlist_add_string_array(payload, name, - va_arg(ap, char **), nelem); + va_arg(ap, const char **), nelem); break; case DATA_TYPE_NVLIST: ret = nvlist_add_nvlist(payload, name, @@ -711,7 +711,7 @@ i_fm_payload_set(nvlist_t *payload, const char *name, va_list ap) case DATA_TYPE_NVLIST_ARRAY: nelem = va_arg(ap, int); ret = nvlist_add_nvlist_array(payload, name, - va_arg(ap, nvlist_t **), nelem); + va_arg(ap, const nvlist_t **), nelem); break; default: ret = EINVAL; @@ -867,8 +867,10 @@ fm_fmri_hc_set(nvlist_t *fmri, int version, const nvlist_t *auth, } va_end(ap); - if (nvlist_add_nvlist_array(fmri, FM_FMRI_HC_LIST, pairs, npairs) != 0) + if (nvlist_add_nvlist_array(fmri, FM_FMRI_HC_LIST, + (const nvlist_t **)pairs, npairs) != 0) { atomic_inc_64(&erpt_kstat_data.fmri_set_failed.value.ui64); + } for (i = 0; i < npairs; i++) fm_nvlist_destroy(pairs[i], FM_NVA_RETAIN); @@ -961,8 +963,8 @@ fm_fmri_hc_create(nvlist_t *fmri, int version, const nvlist_t *auth, /* * Create the fmri hc list */ - if (nvlist_add_nvlist_array(fmri, FM_FMRI_HC_LIST, pairs, - npairs + n) != 0) { + if (nvlist_add_nvlist_array(fmri, FM_FMRI_HC_LIST, + (const nvlist_t **)pairs, npairs + n) != 0) { atomic_inc_64(&erpt_kstat_data.fmri_set_failed.value.ui64); return; } @@ -1128,7 +1130,7 @@ fm_fmri_mem_set(nvlist_t *fmri, int version, const nvlist_t *auth, if (serial != NULL) { if (nvlist_add_string_array(fmri, FM_FMRI_MEM_SERIAL_ID, - (char **)&serial, 1) != 0) { + (const char **)&serial, 1) != 0) { atomic_inc_64( &erpt_kstat_data.fmri_set_failed.value.ui64); } diff --git a/module/zfs/spa.c b/module/zfs/spa.c index 30a442ab8caa..e5c41dc2b069 100644 --- a/module/zfs/spa.c +++ b/module/zfs/spa.c @@ -1851,7 +1851,8 @@ spa_load_spares(spa_t *spa) spares[i] = vdev_config_generate(spa, spa->spa_spares.sav_vdevs[i], B_TRUE, VDEV_CONFIG_SPARE); fnvlist_add_nvlist_array(spa->spa_spares.sav_config, - ZPOOL_CONFIG_SPARES, spares, spa->spa_spares.sav_count); + ZPOOL_CONFIG_SPARES, (const nvlist_t * const *)spares, + spa->spa_spares.sav_count); for (i = 0; i < spa->spa_spares.sav_count; i++) nvlist_free(spares[i]); kmem_free(spares, spa->spa_spares.sav_count * sizeof (void *)); @@ -1978,8 +1979,8 @@ spa_load_l2cache(spa_t *spa) for (i = 0; i < sav->sav_count; i++) l2cache[i] = vdev_config_generate(spa, sav->sav_vdevs[i], B_TRUE, VDEV_CONFIG_L2CACHE); - fnvlist_add_nvlist_array(sav->sav_config, ZPOOL_CONFIG_L2CACHE, l2cache, - sav->sav_count); + fnvlist_add_nvlist_array(sav->sav_config, ZPOOL_CONFIG_L2CACHE, + (const nvlist_t * const *)l2cache, sav->sav_count); out: /* @@ -2107,8 +2108,8 @@ spa_check_for_missing_logs(spa_t *spa) } if (idx > 0) { - fnvlist_add_nvlist_array(nv, - ZPOOL_CONFIG_CHILDREN, child, idx); + fnvlist_add_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN, + (const nvlist_t * const *)child, idx); fnvlist_add_nvlist(spa->spa_load_info, ZPOOL_CONFIG_MISSING_DEVICES, nv); @@ -5292,8 +5293,8 @@ spa_add_spares(spa_t *spa, nvlist_t *config) VERIFY0(nvlist_lookup_nvlist_array(spa->spa_spares.sav_config, ZPOOL_CONFIG_SPARES, &spares, &nspares)); if (nspares != 0) { - fnvlist_add_nvlist_array(nvroot, ZPOOL_CONFIG_SPARES, spares, - nspares); + fnvlist_add_nvlist_array(nvroot, ZPOOL_CONFIG_SPARES, + (const nvlist_t * const *)spares, nspares); VERIFY0(nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_SPARES, &spares, &nspares)); @@ -5340,8 +5341,8 @@ spa_add_l2cache(spa_t *spa, nvlist_t *config) VERIFY0(nvlist_lookup_nvlist_array(spa->spa_l2cache.sav_config, ZPOOL_CONFIG_L2CACHE, &l2cache, &nl2cache)); if (nl2cache != 0) { - fnvlist_add_nvlist_array(nvroot, ZPOOL_CONFIG_L2CACHE, l2cache, - nl2cache); + fnvlist_add_nvlist_array(nvroot, ZPOOL_CONFIG_L2CACHE, + (const nvlist_t * const *)l2cache, nl2cache); VERIFY0(nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_L2CACHE, &l2cache, &nl2cache)); @@ -5648,8 +5649,8 @@ spa_set_aux_vdevs(spa_aux_vdev_t *sav, nvlist_t **devs, int ndevs, fnvlist_remove(sav->sav_config, config); - fnvlist_add_nvlist_array(sav->sav_config, config, newdevs, - ndevs + oldndevs); + fnvlist_add_nvlist_array(sav->sav_config, config, + (const nvlist_t * const *)newdevs, ndevs + oldndevs); for (i = 0; i < oldndevs + ndevs; i++) nvlist_free(newdevs[i]); kmem_free(newdevs, (oldndevs + ndevs) * sizeof (void *)); @@ -5658,7 +5659,8 @@ spa_set_aux_vdevs(spa_aux_vdev_t *sav, nvlist_t **devs, int ndevs, * Generate a new dev list. */ sav->sav_config = fnvlist_alloc(); - fnvlist_add_nvlist_array(sav->sav_config, config, devs, ndevs); + fnvlist_add_nvlist_array(sav->sav_config, config, + (const nvlist_t * const *)devs, ndevs); } } @@ -5869,7 +5871,8 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props, &spares, &nspares) == 0) { spa->spa_spares.sav_config = fnvlist_alloc(); fnvlist_add_nvlist_array(spa->spa_spares.sav_config, - ZPOOL_CONFIG_SPARES, spares, nspares); + ZPOOL_CONFIG_SPARES, (const nvlist_t * const *)spares, + nspares); spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER); spa_load_spares(spa); spa_config_exit(spa, SCL_ALL, FTAG); @@ -5881,9 +5884,11 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props, */ if (nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_L2CACHE, &l2cache, &nl2cache) == 0) { - spa->spa_l2cache.sav_config = fnvlist_alloc(); + VERIFY0(nvlist_alloc(&spa->spa_l2cache.sav_config, + NV_UNIQUE_NAME, KM_SLEEP)); fnvlist_add_nvlist_array(spa->spa_l2cache.sav_config, - ZPOOL_CONFIG_L2CACHE, l2cache, nl2cache); + ZPOOL_CONFIG_L2CACHE, (const nvlist_t * const *)l2cache, + nl2cache); spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER); spa_load_l2cache(spa); spa_config_exit(spa, SCL_ALL, FTAG); @@ -6131,7 +6136,8 @@ spa_import(char *pool, nvlist_t *config, nvlist_t *props, uint64_t flags) else spa->spa_spares.sav_config = fnvlist_alloc(); fnvlist_add_nvlist_array(spa->spa_spares.sav_config, - ZPOOL_CONFIG_SPARES, spares, nspares); + ZPOOL_CONFIG_SPARES, (const nvlist_t * const *)spares, + nspares); spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER); spa_load_spares(spa); spa_config_exit(spa, SCL_ALL, FTAG); @@ -6145,7 +6151,8 @@ spa_import(char *pool, nvlist_t *config, nvlist_t *props, uint64_t flags) else spa->spa_l2cache.sav_config = fnvlist_alloc(); fnvlist_add_nvlist_array(spa->spa_l2cache.sav_config, - ZPOOL_CONFIG_L2CACHE, l2cache, nl2cache); + ZPOOL_CONFIG_L2CACHE, (const nvlist_t * const *)l2cache, + nl2cache); spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER); spa_load_l2cache(spa); spa_config_exit(spa, SCL_ALL, FTAG); @@ -8472,13 +8479,15 @@ spa_sync_aux_dev(spa_t *spa, spa_aux_vdev_t *sav, dmu_tx_t *tx, nvroot = fnvlist_alloc(); if (sav->sav_count == 0) { - fnvlist_add_nvlist_array(nvroot, config, NULL, 0); + fnvlist_add_nvlist_array(nvroot, config, + (const nvlist_t * const *)NULL, 0); } else { list = kmem_alloc(sav->sav_count*sizeof (void *), KM_SLEEP); for (i = 0; i < sav->sav_count; i++) list[i] = vdev_config_generate(spa, sav->sav_vdevs[i], B_FALSE, VDEV_CONFIG_L2CACHE); - fnvlist_add_nvlist_array(nvroot, config, list, sav->sav_count); + fnvlist_add_nvlist_array(nvroot, config, + (const nvlist_t * const *)list, sav->sav_count); for (i = 0; i < sav->sav_count; i++) nvlist_free(list[i]); kmem_free(list, sav->sav_count * sizeof (void *)); diff --git a/module/zfs/vdev_draid.c b/module/zfs/vdev_draid.c index b8f82d52e8f0..9c222feb9f06 100644 --- a/module/zfs/vdev_draid.c +++ b/module/zfs/vdev_draid.c @@ -1707,7 +1707,7 @@ vdev_draid_spare_create(nvlist_t *nvroot, vdev_t *vd, uint64_t *ndraidp, if (n > 0) { (void) nvlist_remove_all(nvroot, ZPOOL_CONFIG_SPARES); fnvlist_add_nvlist_array(nvroot, ZPOOL_CONFIG_SPARES, - new_spares, n); + (const nvlist_t **)new_spares, n); } for (int i = 0; i < n; i++) diff --git a/module/zfs/vdev_label.c b/module/zfs/vdev_label.c index 6252ee135b83..a62804ea8f49 100644 --- a/module/zfs/vdev_label.c +++ b/module/zfs/vdev_label.c @@ -669,7 +669,7 @@ vdev_config_generate(spa_t *spa, vdev_t *vd, boolean_t getstats, if (idx) { fnvlist_add_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN, - child, idx); + (const nvlist_t * const *)child, idx); } for (c = 0; c < idx; c++) diff --git a/module/zfs/vdev_removal.c b/module/zfs/vdev_removal.c index 02dbdfb6c500..482b5bb0ba54 100644 --- a/module/zfs/vdev_removal.c +++ b/module/zfs/vdev_removal.c @@ -353,7 +353,8 @@ spa_vdev_remove_aux(nvlist_t *config, char *name, nvlist_t **dev, int count, } VERIFY(nvlist_remove(config, name, DATA_TYPE_NVLIST_ARRAY) == 0); - VERIFY(nvlist_add_nvlist_array(config, name, newdev, count - 1) == 0); + fnvlist_add_nvlist_array(config, name, (const nvlist_t * const *)newdev, + count - 1); for (int i = 0; i < count - 1; i++) nvlist_free(newdev[i]); diff --git a/module/zfs/zfs_fuid.c b/module/zfs/zfs_fuid.c index a90bf5feeea1..3aa60034d42a 100644 --- a/module/zfs/zfs_fuid.c +++ b/module/zfs/zfs_fuid.c @@ -258,8 +258,8 @@ zfs_fuid_sync(zfsvfs_t *zfsvfs, dmu_tx_t *tx) VERIFY(nvlist_add_string(fuids[i], FUID_DOMAIN, domnode->f_ksid->kd_name) == 0); } - VERIFY(nvlist_add_nvlist_array(nvp, FUID_NVP_ARRAY, - fuids, numnodes) == 0); + fnvlist_add_nvlist_array(nvp, FUID_NVP_ARRAY, + (const nvlist_t * const *)fuids, numnodes); for (i = 0; i != numnodes; i++) nvlist_free(fuids[i]); kmem_free(fuids, numnodes * sizeof (void *)); diff --git a/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c b/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c index 0e552c2680a0..fba18068cfc8 100644 --- a/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c +++ b/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c @@ -603,7 +603,7 @@ test_channel_program(const char *pool) nvlist_t *args = fnvlist_alloc(); fnvlist_add_string(required, "program", program); - fnvlist_add_string_array(args, "argv", argv, 1); + fnvlist_add_string_array(args, "argv", (const char * const *)argv, 1); fnvlist_add_nvlist(required, "arg", args); fnvlist_add_boolean_value(optional, "sync", B_TRUE); diff --git a/tests/zfs-tests/cmd/nvlist_to_lua/nvlist_to_lua.c b/tests/zfs-tests/cmd/nvlist_to_lua/nvlist_to_lua.c index b130d667f231..3072ca97939c 100644 --- a/tests/zfs-tests/cmd/nvlist_to_lua/nvlist_to_lua.c +++ b/tests/zfs-tests/cmd/nvlist_to_lua/nvlist_to_lua.c @@ -232,7 +232,7 @@ run_tests(void) } { char *const val[2] = { "0", "1" }; - fnvlist_add_string_array(nvl, key, val, 2); + fnvlist_add_string_array(nvl, key, (const char **)val, 2); test("string_array", B_TRUE, B_FALSE); } { @@ -241,7 +241,7 @@ run_tests(void) fnvlist_add_string(val[0], "subkey", "subvalue"); val[1] = fnvlist_alloc(); fnvlist_add_string(val[1], "subkey2", "subvalue2"); - fnvlist_add_nvlist_array(nvl, key, val, 2); + fnvlist_add_nvlist_array(nvl, key, (const nvlist_t **)val, 2); fnvlist_free(val[0]); fnvlist_free(val[1]); test("nvlist_array", B_FALSE, B_FALSE);