diff --git a/lib/libzfs/libzfs_config.c b/lib/libzfs/libzfs_config.c index dd5901596..97b10bb76 100644 --- a/lib/libzfs/libzfs_config.c +++ b/lib/libzfs/libzfs_config.c @@ -193,7 +193,7 @@ namespace_reload(libzfs_handle_t *hdl) return (-1); } - verify(nvpair_value_nvlist(elem, &child) == 0); + child = fnvpair_value_nvlist(elem); if (nvlist_dup(child, &cn->cn_config, 0) != 0) { free(cn->cn_name); free(cn); diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index 0115a17e6..b973e0950 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -234,7 +234,6 @@ process_user_props(zfs_handle_t *zhp, nvlist_t *props) { libzfs_handle_t *hdl = zhp->zfs_hdl; nvpair_t *elem; - nvlist_t *propval; nvlist_t *nvl; if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, 0) != 0) { @@ -247,7 +246,7 @@ process_user_props(zfs_handle_t *zhp, nvlist_t *props) if (!zfs_prop_user(nvpair_name(elem))) continue; - verify(nvpair_value_nvlist(elem, &propval) == 0); + nvlist_t *propval = fnvpair_value_nvlist(elem); if (nvlist_add_nvlist(nvl, nvpair_name(elem), propval) != 0) { nvlist_free(nvl); (void) no_memory(hdl); @@ -1315,8 +1314,7 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl, /* Replace the label string with the internal form. */ (void) nvlist_remove(ret, zfs_prop_to_name(prop), DATA_TYPE_STRING); - verify(nvlist_add_string(ret, zfs_prop_to_name(prop), - hex) == 0); + fnvlist_add_string(ret, zfs_prop_to_name(prop), hex); free(hex); break; @@ -2056,7 +2054,7 @@ getprop_uint64(zfs_handle_t *zhp, zfs_prop_t prop, char **source) *source = NULL; if (nvlist_lookup_nvlist(zhp->zfs_props, zfs_prop_to_name(prop), &nv) == 0) { - verify(nvlist_lookup_uint64(nv, ZPROP_VALUE, &value) == 0); + value = fnvlist_lookup_uint64(nv, ZPROP_VALUE); (void) nvlist_lookup_string(nv, ZPROP_SOURCE, source); } else { verify(!zhp->zfs_props_table || @@ -2385,8 +2383,7 @@ zfs_prop_get_recvd(zfs_handle_t *zhp, const char *propname, char *propbuf, if (nvlist_lookup_nvlist(zhp->zfs_recvd_props, propname, &propval) != 0) return (-1); - verify(nvlist_lookup_string(propval, ZPROP_VALUE, - &recvdval) == 0); + recvdval = fnvlist_lookup_string(propval, ZPROP_VALUE); (void) strlcpy(propbuf, recvdval, proplen); } @@ -2500,13 +2497,11 @@ zfs_get_clones_nvl(zfs_handle_t *zhp) } nvlist_free(nv); nvlist_free(value); - verify(0 == nvlist_lookup_nvlist(zhp->zfs_props, - zfs_prop_to_name(ZFS_PROP_CLONES), &nv)); + nv = fnvlist_lookup_nvlist(zhp->zfs_props, + zfs_prop_to_name(ZFS_PROP_CLONES)); } - verify(nvlist_lookup_nvlist(nv, ZPROP_VALUE, &value) == 0); - - return (value); + return (fnvlist_lookup_nvlist(nv, ZPROP_VALUE)); } static int @@ -3863,7 +3858,7 @@ zfs_check_snap_cb(zfs_handle_t *zhp, void *arg) return (EINVAL); if (lzc_exists(name)) - verify(nvlist_add_boolean(dd->nvl, name) == 0); + fnvlist_add_boolean(dd->nvl, name); rv = zfs_iter_filesystems(zhp, zfs_check_snap_cb, dd); zfs_close(zhp); @@ -3880,7 +3875,7 @@ zfs_destroy_snaps(zfs_handle_t *zhp, char *snapname, boolean_t defer) struct destroydata dd = { 0 }; dd.snapname = snapname; - verify(nvlist_alloc(&dd.nvl, NV_UNIQUE_NAME, 0) == 0); + dd.nvl = fnvlist_alloc(); (void) zfs_check_snap_cb(zfs_handle_dup(zhp), &dd); if (nvlist_empty(dd.nvl)) { @@ -3890,7 +3885,7 @@ zfs_destroy_snaps(zfs_handle_t *zhp, char *snapname, boolean_t defer) } else { ret = zfs_destroy_snaps_nvl(zhp->zfs_hdl, dd.nvl, defer); } - nvlist_free(dd.nvl); + fnvlist_free(dd.nvl); return (ret); } @@ -4221,7 +4216,7 @@ zfs_snapshot(libzfs_handle_t *hdl, const char *path, boolean_t recursive, return (-1); } - verify(nvlist_alloc(&sd.sd_nvl, NV_UNIQUE_NAME, 0) == 0); + sd.sd_nvl = fnvlist_alloc(); if (recursive) { (void) zfs_snapshot_cb(zfs_handle_dup(zhp), &sd); } else { @@ -4229,7 +4224,7 @@ zfs_snapshot(libzfs_handle_t *hdl, const char *path, boolean_t recursive, } ret = zfs_snapshot_nvl(hdl, sd.sd_nvl, props); - nvlist_free(sd.sd_nvl); + fnvlist_free(sd.sd_nvl); zfs_close(zhp); return (ret); } @@ -4712,8 +4707,8 @@ zfs_expand_proplist(zfs_handle_t *zhp, zprop_list_t **plp, boolean_t received, } else { if (nvlist_lookup_nvlist(userprops, entry->pl_user_prop, &propval) == 0) { - verify(nvlist_lookup_string(propval, - ZPROP_VALUE, &strval) == 0); + strval = fnvlist_lookup_string(propval, + ZPROP_VALUE); if (strlen(strval) > entry->pl_width) entry->pl_width = strlen(strval); } diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c index 0d375b355..004a684d5 100644 --- a/lib/libzfs/libzfs_import.c +++ b/lib/libzfs/libzfs_import.c @@ -48,7 +48,6 @@ pool_active(libzfs_handle_t *hdl, const char *name, uint64_t guid, boolean_t *isactive) { zpool_handle_t *zhp; - uint64_t theguid; if (zpool_open_silent(hdl, name, &zhp) != 0) return (-1); @@ -58,8 +57,8 @@ pool_active(libzfs_handle_t *hdl, const char *name, uint64_t guid, return (0); } - verify(nvlist_lookup_uint64(zhp->zpool_config, ZPOOL_CONFIG_POOL_GUID, - &theguid) == 0); + uint64_t theguid = fnvlist_lookup_uint64(zhp->zpool_config, + ZPOOL_CONFIG_POOL_GUID); zpool_close(zhp); @@ -239,12 +238,10 @@ zpool_clear_label(int fd) static boolean_t find_guid(nvlist_t *nv, uint64_t guid) { - uint64_t tmp; nvlist_t **child; uint_t c, children; - verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_GUID, &tmp) == 0); - if (tmp == guid) + if (fnvlist_lookup_uint64(nv, ZPOOL_CONFIG_GUID) == guid) return (B_TRUE); if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN, @@ -268,18 +265,16 @@ find_aux(zpool_handle_t *zhp, void *data) { aux_cbdata_t *cbp = data; nvlist_t **list; - uint_t i, count; - uint64_t guid; - nvlist_t *nvroot; + uint_t count; - verify(nvlist_lookup_nvlist(zhp->zpool_config, ZPOOL_CONFIG_VDEV_TREE, - &nvroot) == 0); + nvlist_t *nvroot = fnvlist_lookup_nvlist(zhp->zpool_config, + ZPOOL_CONFIG_VDEV_TREE); if (nvlist_lookup_nvlist_array(nvroot, cbp->cb_type, &list, &count) == 0) { - for (i = 0; i < count; i++) { - verify(nvlist_lookup_uint64(list[i], - ZPOOL_CONFIG_GUID, &guid) == 0); + for (uint_t i = 0; i < count; i++) { + uint64_t guid = fnvlist_lookup_uint64(list[i], + ZPOOL_CONFIG_GUID); if (guid == cbp->cb_guid) { cbp->cb_zhp = zhp; return (1); @@ -301,9 +296,9 @@ zpool_in_use(libzfs_handle_t *hdl, int fd, pool_state_t *state, char **namestr, boolean_t *inuse) { nvlist_t *config; - char *name; + char *name = NULL; boolean_t ret; - uint64_t guid, vdev_guid; + uint64_t guid = 0, vdev_guid; zpool_handle_t *zhp; nvlist_t *pool_config; uint64_t stateval, isspare; @@ -320,16 +315,12 @@ zpool_in_use(libzfs_handle_t *hdl, int fd, pool_state_t *state, char **namestr, if (config == NULL) return (0); - verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_STATE, - &stateval) == 0); - verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_GUID, - &vdev_guid) == 0); + stateval = fnvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_STATE); + vdev_guid = fnvlist_lookup_uint64(config, ZPOOL_CONFIG_GUID); if (stateval != POOL_STATE_SPARE && stateval != POOL_STATE_L2CACHE) { - verify(nvlist_lookup_string(config, ZPOOL_CONFIG_POOL_NAME, - &name) == 0); - verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID, - &guid) == 0); + name = fnvlist_lookup_string(config, ZPOOL_CONFIG_POOL_NAME); + guid = fnvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID); } switch (stateval) { @@ -378,10 +369,8 @@ zpool_in_use(libzfs_handle_t *hdl, int fd, pool_state_t *state, char **namestr, if ((zhp = zpool_open_canfail(hdl, name)) != NULL && (pool_config = zpool_get_config(zhp, NULL)) != NULL) { - nvlist_t *nvroot; - - verify(nvlist_lookup_nvlist(pool_config, - ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0); + nvlist_t *nvroot = fnvlist_lookup_nvlist( + pool_config, ZPOOL_CONFIG_VDEV_TREE); ret = find_guid(nvroot, vdev_guid); } else { ret = B_FALSE; diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index b632ff74a..059aa7adb 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -123,15 +123,13 @@ zpool_get_prop_string(zpool_handle_t *zhp, zpool_prop_t prop, zprop_source_t *src) { nvlist_t *nv, *nvl; - uint64_t ival; char *value; zprop_source_t source; nvl = zhp->zpool_props; if (nvlist_lookup_nvlist(nvl, zpool_prop_to_name(prop), &nv) == 0) { - verify(nvlist_lookup_uint64(nv, ZPROP_SOURCE, &ival) == 0); - source = ival; - verify(nvlist_lookup_string(nv, ZPROP_VALUE, &value) == 0); + source = fnvlist_lookup_uint64(nv, ZPROP_SOURCE); + value = fnvlist_lookup_string(nv, ZPROP_VALUE); } else { source = ZPROP_SRC_DEFAULT; if ((value = (char *)zpool_prop_default_string(prop)) == NULL) @@ -169,9 +167,8 @@ zpool_get_prop_int(zpool_handle_t *zhp, zpool_prop_t prop, zprop_source_t *src) nvl = zhp->zpool_props; if (nvlist_lookup_nvlist(nvl, zpool_prop_to_name(prop), &nv) == 0) { - verify(nvlist_lookup_uint64(nv, ZPROP_SOURCE, &value) == 0); - source = value; - verify(nvlist_lookup_uint64(nv, ZPROP_VALUE, &value) == 0); + source = fnvlist_lookup_uint64(nv, ZPROP_SOURCE); + value = fnvlist_lookup_uint64(nv, ZPROP_VALUE); } else { source = ZPROP_SRC_DEFAULT; value = zpool_prop_default_numeric(prop); @@ -255,9 +252,6 @@ zpool_get_state_str(zpool_handle_t *zhp) { zpool_errata_t errata; zpool_status_t status; - nvlist_t *nvroot; - vdev_stat_t *vs; - uint_t vsc; const char *str; status = zpool_get_status(zhp, NULL, &errata); @@ -268,11 +262,11 @@ zpool_get_state_str(zpool_handle_t *zhp) status == ZPOOL_STATUS_IO_FAILURE_MMP) { str = gettext("SUSPENDED"); } else { - verify(nvlist_lookup_nvlist(zpool_get_config(zhp, NULL), - ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0); - verify(nvlist_lookup_uint64_array(nvroot, - ZPOOL_CONFIG_VDEV_STATS, (uint64_t **)&vs, &vsc) - == 0); + nvlist_t *nvroot = fnvlist_lookup_nvlist( + zpool_get_config(zhp, NULL), ZPOOL_CONFIG_VDEV_TREE); + uint_t vsc; + vdev_stat_t *vs = (vdev_stat_t *)fnvlist_lookup_uint64_array( + nvroot, ZPOOL_CONFIG_VDEV_STATS, &vsc); str = zpool_state_to_name(vs->vs_state, vs->vs_aux); } return (str); @@ -986,8 +980,7 @@ vdev_expand_proplist(zpool_handle_t *zhp, const char *vdevname, if (nvpair_value_nvlist(elem, &propval) != 0) continue; - verify(nvlist_lookup_string(propval, ZPROP_VALUE, - &strval) == 0); + strval = fnvlist_lookup_string(propval, ZPROP_VALUE); if ((entry = zfs_alloc(zhp->zpool_hdl, sizeof (zprop_list_t))) == NULL) @@ -1996,20 +1989,13 @@ void zpool_print_unsup_feat(nvlist_t *config) { nvlist_t *nvinfo, *unsup_feat; - nvpair_t *nvp; - verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_LOAD_INFO, &nvinfo) == - 0); - verify(nvlist_lookup_nvlist(nvinfo, ZPOOL_CONFIG_UNSUP_FEAT, - &unsup_feat) == 0); - - for (nvp = nvlist_next_nvpair(unsup_feat, NULL); nvp != NULL; - nvp = nvlist_next_nvpair(unsup_feat, nvp)) { - char *desc; - - verify(nvpair_type(nvp) == DATA_TYPE_STRING); - verify(nvpair_value_string(nvp, &desc) == 0); + nvinfo = fnvlist_lookup_nvlist(config, ZPOOL_CONFIG_LOAD_INFO); + unsup_feat = fnvlist_lookup_nvlist(nvinfo, ZPOOL_CONFIG_UNSUP_FEAT); + 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); if (strlen(desc) > 0) (void) printf("\t%s (%s)\n", nvpair_name(nvp), desc); else @@ -2038,8 +2024,7 @@ zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname, int error = 0; char errbuf[1024]; - verify(nvlist_lookup_string(config, ZPOOL_CONFIG_POOL_NAME, - &origname) == 0); + origname = fnvlist_lookup_string(config, ZPOOL_CONFIG_POOL_NAME); (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, "cannot import pool '%s'"), origname); @@ -2058,8 +2043,7 @@ zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname, uint64_t version; prop_flags_t flags = { .create = B_FALSE, .import = B_TRUE }; - verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION, - &version) == 0); + version = fnvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION); if ((props = zpool_valid_proplist(hdl, origname, props, version, flags, errbuf)) == NULL) @@ -2073,8 +2057,7 @@ zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname, (void) strlcpy(zc.zc_name, thename, sizeof (zc.zc_name)); - verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID, - &zc.zc_guid) == 0); + zc.zc_guid = fnvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID); if (zcmd_write_conf_nvlist(hdl, &zc, config) != 0) { zcmd_free_nvlists(&zc); @@ -2635,8 +2618,8 @@ zpool_scan(zpool_handle_t *zhp, pool_scan_func_t func, pool_scrub_cmd_t cmd) pool_scan_stat_t *ps = NULL; uint_t psc; - verify(nvlist_lookup_nvlist(zhp->zpool_config, - ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0); + nvroot = fnvlist_lookup_nvlist(zhp->zpool_config, + ZPOOL_CONFIG_VDEV_TREE); (void) nvlist_lookup_uint64_array(nvroot, ZPOOL_CONFIG_SCAN_STATS, (uint64_t **)&ps, &psc); if (ps && ps->pss_func == POOL_SCAN_SCRUB && @@ -2684,11 +2667,9 @@ vdev_to_nvlist_iter(nvlist_t *nv, nvlist_t *search, boolean_t *avail_spare, switch (nvpair_type(pair)) { case DATA_TYPE_UINT64: if (strcmp(srchkey, ZPOOL_CONFIG_GUID) == 0) { - uint64_t srchval, theguid; - - verify(nvpair_value_uint64(pair, &srchval) == 0); - verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_GUID, - &theguid) == 0); + uint64_t srchval = fnvpair_value_uint64(pair); + uint64_t theguid = fnvlist_lookup_uint64(nv, + ZPOOL_CONFIG_GUID); if (theguid == srchval) return (nv); } @@ -2697,7 +2678,7 @@ vdev_to_nvlist_iter(nvlist_t *nv, nvlist_t *search, boolean_t *avail_spare, case DATA_TYPE_STRING: { char *srchval, *val; - verify(nvpair_value_string(pair, &srchval) == 0); + srchval = fnvpair_value_string(pair); if (nvlist_lookup_string(nv, srchkey, &val) != 0) break; @@ -2749,9 +2730,8 @@ vdev_to_nvlist_iter(nvlist_t *nv, nvlist_t *search, boolean_t *avail_spare, } verify(zpool_vdev_is_interior(type)); - verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_ID, - &id) == 0); + id = fnvlist_lookup_uint64(nv, ZPOOL_CONFIG_ID); errno = 0; vdev_id = strtoull(idx, &end, 10); @@ -2777,8 +2757,8 @@ vdev_to_nvlist_iter(nvlist_t *nv, nvlist_t *search, boolean_t *avail_spare, free(type); return (NULL); } - verify(nvlist_lookup_uint64(nv, - ZPOOL_CONFIG_NPARITY, &vdev_parity) == 0); + vdev_parity = fnvlist_lookup_uint64(nv, + ZPOOL_CONFIG_NPARITY); if ((int)vdev_parity != parity) { free(type); break; @@ -2867,25 +2847,24 @@ zpool_find_vdev_by_physpath(zpool_handle_t *zhp, const char *ppath, uint64_t guid; char *end; - verify(nvlist_alloc(&search, NV_UNIQUE_NAME, KM_SLEEP) == 0); + search = fnvlist_alloc(); guid = strtoull(ppath, &end, 0); if (guid != 0 && *end == '\0') { - verify(nvlist_add_uint64(search, ZPOOL_CONFIG_GUID, guid) == 0); + fnvlist_add_uint64(search, ZPOOL_CONFIG_GUID, guid); } else { - verify(nvlist_add_string(search, ZPOOL_CONFIG_PHYS_PATH, - ppath) == 0); + fnvlist_add_string(search, ZPOOL_CONFIG_PHYS_PATH, ppath); } - verify(nvlist_lookup_nvlist(zhp->zpool_config, ZPOOL_CONFIG_VDEV_TREE, - &nvroot) == 0); + nvroot = fnvlist_lookup_nvlist(zhp->zpool_config, + ZPOOL_CONFIG_VDEV_TREE); *avail_spare = B_FALSE; *l2cache = B_FALSE; if (log != NULL) *log = B_FALSE; ret = vdev_to_nvlist_iter(nvroot, search, avail_spare, l2cache, log); - nvlist_free(search); + fnvlist_free(search); return (ret); } @@ -2918,26 +2897,26 @@ zpool_find_vdev(zpool_handle_t *zhp, const char *path, boolean_t *avail_spare, nvlist_t *nvroot, *search, *ret; uint64_t guid; - verify(nvlist_alloc(&search, NV_UNIQUE_NAME, KM_SLEEP) == 0); + search = fnvlist_alloc(); guid = strtoull(path, &end, 0); if (guid != 0 && *end == '\0') { - verify(nvlist_add_uint64(search, ZPOOL_CONFIG_GUID, guid) == 0); + fnvlist_add_uint64(search, ZPOOL_CONFIG_GUID, guid); } else if (zpool_vdev_is_interior(path)) { - verify(nvlist_add_string(search, ZPOOL_CONFIG_TYPE, path) == 0); + fnvlist_add_string(search, ZPOOL_CONFIG_TYPE, path); } else { - verify(nvlist_add_string(search, ZPOOL_CONFIG_PATH, path) == 0); + fnvlist_add_string(search, ZPOOL_CONFIG_PATH, path); } - verify(nvlist_lookup_nvlist(zhp->zpool_config, ZPOOL_CONFIG_VDEV_TREE, - &nvroot) == 0); + nvroot = fnvlist_lookup_nvlist(zhp->zpool_config, + ZPOOL_CONFIG_VDEV_TREE); *avail_spare = B_FALSE; *l2cache = B_FALSE; if (log != NULL) *log = B_FALSE; ret = vdev_to_nvlist_iter(nvroot, search, avail_spare, l2cache, log); - nvlist_free(search); + fnvlist_free(search); return (ret); } @@ -3101,7 +3080,6 @@ static uint64_t zpool_vdev_path_to_guid_impl(zpool_handle_t *zhp, const char *path, boolean_t *is_spare, boolean_t *is_l2cache, boolean_t *is_log) { - uint64_t guid; boolean_t spare = B_FALSE, l2cache = B_FALSE, log = B_FALSE; nvlist_t *tgt; @@ -3109,7 +3087,6 @@ zpool_vdev_path_to_guid_impl(zpool_handle_t *zhp, const char *path, &log)) == NULL) return (0); - verify(nvlist_lookup_uint64(tgt, ZPOOL_CONFIG_GUID, &guid) == 0); if (is_spare != NULL) *is_spare = spare; if (is_l2cache != NULL) @@ -3117,7 +3094,7 @@ zpool_vdev_path_to_guid_impl(zpool_handle_t *zhp, const char *path, if (is_log != NULL) *is_log = log; - return (guid); + return (fnvlist_lookup_uint64(tgt, ZPOOL_CONFIG_GUID)); } /* Convert a vdev path to a GUID. Returns GUID or 0 on error. */ @@ -3154,7 +3131,7 @@ zpool_vdev_online(zpool_handle_t *zhp, const char *path, int flags, &islog)) == NULL) return (zfs_error(hdl, EZFS_NODEVICE, msg)); - verify(nvlist_lookup_uint64(tgt, ZPOOL_CONFIG_GUID, &zc.zc_guid) == 0); + zc.zc_guid = fnvlist_lookup_uint64(tgt, ZPOOL_CONFIG_GUID); if (avail_spare) return (zfs_error(hdl, EZFS_ISSPARE, msg)); @@ -3237,7 +3214,7 @@ zpool_vdev_offline(zpool_handle_t *zhp, const char *path, boolean_t istmp) NULL)) == NULL) return (zfs_error(hdl, EZFS_NODEVICE, msg)); - verify(nvlist_lookup_uint64(tgt, ZPOOL_CONFIG_GUID, &zc.zc_guid) == 0); + zc.zc_guid = fnvlist_lookup_uint64(tgt, ZPOOL_CONFIG_GUID); if (avail_spare) return (zfs_error(hdl, EZFS_ISSPARE, msg)); @@ -3335,13 +3312,10 @@ is_replacing_spare(nvlist_t *search, nvlist_t *tgt, int which) { nvlist_t **child; uint_t c, children; - char *type; if (nvlist_lookup_nvlist_array(search, ZPOOL_CONFIG_CHILDREN, &child, &children) == 0) { - verify(nvlist_lookup_string(search, ZPOOL_CONFIG_TYPE, - &type) == 0); - + 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) @@ -3393,7 +3367,7 @@ zpool_vdev_attach(zpool_handle_t *zhp, const char *old_disk, if (l2cache) return (zfs_error(hdl, EZFS_ISL2CACHE, msg)); - verify(nvlist_lookup_uint64(tgt, ZPOOL_CONFIG_GUID, &zc.zc_guid) == 0); + zc.zc_guid = fnvlist_lookup_uint64(tgt, ZPOOL_CONFIG_GUID); zc.zc_cookie = replacing; zc.zc_simple = rebuild; @@ -3411,8 +3385,8 @@ zpool_vdev_attach(zpool_handle_t *zhp, const char *old_disk, return (zfs_error(hdl, EZFS_INVALCONFIG, msg)); } - verify(nvlist_lookup_nvlist(zpool_get_config(zhp, NULL), - ZPOOL_CONFIG_VDEV_TREE, &config_root) == 0); + config_root = fnvlist_lookup_nvlist(zpool_get_config(zhp, NULL), + ZPOOL_CONFIG_VDEV_TREE); if ((newname = zpool_vdev_name(NULL, NULL, child[0], 0)) == NULL) return (-1); @@ -3566,7 +3540,7 @@ zpool_vdev_detach(zpool_handle_t *zhp, const char *path) if (l2cache) return (zfs_error(hdl, EZFS_ISL2CACHE, msg)); - verify(nvlist_lookup_uint64(tgt, ZPOOL_CONFIG_GUID, &zc.zc_guid) == 0); + zc.zc_guid = fnvlist_lookup_uint64(tgt, ZPOOL_CONFIG_GUID); if (zfs_ioctl(hdl, ZFS_IOC_VDEV_DETACH, &zc) == 0) return (0); @@ -3666,9 +3640,8 @@ zpool_vdev_split(zpool_handle_t *zhp, char *newname, nvlist_t **newroot, return (-1); } - verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, &tree) - == 0); - verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION, &vers) == 0); + tree = fnvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE); + vers = fnvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION); if (props) { prop_flags_t flags = { .create = B_FALSE, .import = B_TRUE }; @@ -3735,8 +3708,7 @@ zpool_vdev_split(zpool_handle_t *zhp, char *newname, nvlist_t **newroot, continue; } lastlog = 0; - verify(nvlist_lookup_string(child[c], ZPOOL_CONFIG_TYPE, &type) - == 0); + type = fnvlist_lookup_string(child[c], ZPOOL_CONFIG_TYPE); if (strcmp(type, VDEV_TYPE_INDIRECT) == 0) { vdev = child[c]; @@ -4043,8 +4015,7 @@ zpool_clear(zpool_handle_t *zhp, const char *path, nvlist_t *rewindnvl) if (avail_spare) return (zfs_error(hdl, EZFS_ISSPARE, msg)); - verify(nvlist_lookup_uint64(tgt, ZPOOL_CONFIG_GUID, - &zc.zc_guid) == 0); + zc.zc_guid = fnvlist_lookup_uint64(tgt, ZPOOL_CONFIG_GUID); } zpool_get_load_policy(rewindnvl, &policy); @@ -4197,7 +4168,7 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv, * vdev_name will be "root"/"root-0" for the root vdev, but it is the * zpool name that will be displayed to the user. */ - verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &type) == 0); + type = fnvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE); if (zhp != NULL && strcmp(type, "root") == 0) return (zfs_strdup(hdl, zpool_get_name(zhp))); @@ -4254,8 +4225,7 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv, * If it's a raidz device, we need to stick in the parity level. */ if (strcmp(path, VDEV_TYPE_RAIDZ) == 0) { - verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_NPARITY, - &value) == 0); + value = fnvlist_lookup_uint64(nv, ZPOOL_CONFIG_NPARITY); (void) snprintf(buf, sizeof (buf), "%s%llu", path, (u_longlong_t)value); path = buf; @@ -4271,12 +4241,12 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv, verify(nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN, &child, &children) == 0); - verify(nvlist_lookup_uint64(nv, - ZPOOL_CONFIG_NPARITY, &nparity) == 0); - verify(nvlist_lookup_uint64(nv, - ZPOOL_CONFIG_DRAID_NDATA, &ndata) == 0); - verify(nvlist_lookup_uint64(nv, - ZPOOL_CONFIG_DRAID_NSPARES, &nspares) == 0); + nparity = fnvlist_lookup_uint64(nv, + ZPOOL_CONFIG_NPARITY); + ndata = fnvlist_lookup_uint64(nv, + ZPOOL_CONFIG_DRAID_NDATA); + nspares = fnvlist_lookup_uint64(nv, + ZPOOL_CONFIG_DRAID_NSPARES); path = zpool_draid_name(buf, sizeof (buf), ndata, nparity, nspares, children); @@ -4287,9 +4257,8 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv, * naming convention. */ if (name_flags & VDEV_NAME_TYPE_ID) { - uint64_t id; - verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_ID, - &id) == 0); + uint64_t id = fnvlist_lookup_uint64(nv, + ZPOOL_CONFIG_ID); (void) snprintf(tmpbuf, sizeof (tmpbuf), "%s-%llu", path, (u_longlong_t)id); path = tmpbuf; @@ -4323,8 +4292,7 @@ zpool_get_errlog(zpool_handle_t *zhp, nvlist_t **nverrlistp) * has increased, allocate more space and continue until we get the * entire list. */ - verify(nvlist_lookup_uint64(zhp->zpool_config, ZPOOL_CONFIG_ERRCOUNT, - &count) == 0); + count = fnvlist_lookup_uint64(zhp->zpool_config, ZPOOL_CONFIG_ERRCOUNT); if (count == 0) return (0); zc.zc_nvlist_dst = (uintptr_t)zfs_alloc(zhp->zpool_hdl, @@ -4553,9 +4521,9 @@ zpool_get_history(zpool_handle_t *zhp, nvlist_t **nvhisp, uint64_t *off, free(buf); if (!err) { - verify(nvlist_alloc(nvhisp, NV_UNIQUE_NAME, 0) == 0); - verify(nvlist_add_nvlist_array(*nvhisp, ZPOOL_HIST_RECORD, - (const nvlist_t **)records, numrecords) == 0); + *nvhisp = fnvlist_alloc(); + fnvlist_add_nvlist_array(*nvhisp, ZPOOL_HIST_RECORD, + (const nvlist_t **)records, numrecords); } for (i = 0; i < numrecords; i++) nvlist_free(records[i]); @@ -5092,7 +5060,7 @@ zpool_vdev_guid(zpool_handle_t *zhp, const char *vdevname, uint64_t *vdev_guid) return (zfs_error(zhp->zpool_hdl, EZFS_NODEVICE, errbuf)); } - verify(nvlist_lookup_uint64(tgt, ZPOOL_CONFIG_GUID, vdev_guid) == 0); + *vdev_guid = fnvlist_lookup_uint64(tgt, ZPOOL_CONFIG_GUID); return (0); } @@ -5105,19 +5073,16 @@ zpool_get_vdev_prop_value(nvlist_t *nvprop, vdev_prop_t prop, char *prop_name, char *buf, size_t len, zprop_source_t *srctype, boolean_t literal) { nvlist_t *nv; - uint64_t intval; char *strval; + uint64_t intval; zprop_source_t src = ZPROP_SRC_NONE; if (prop == VDEV_PROP_USER) { /* user property, prop_name must contain the property name */ assert(prop_name != NULL); if (nvlist_lookup_nvlist(nvprop, prop_name, &nv) == 0) { - verify(nvlist_lookup_uint64(nv, ZPROP_SOURCE, - &intval) == 0); - src = intval; - verify(nvlist_lookup_string(nv, ZPROP_VALUE, - &strval) == 0); + src = fnvlist_lookup_uint64(nv, ZPROP_SOURCE); + strval = fnvlist_lookup_string(nv, ZPROP_VALUE); } else { /* user prop not found */ return (-1); @@ -5134,11 +5099,8 @@ zpool_get_vdev_prop_value(nvlist_t *nvprop, vdev_prop_t prop, char *prop_name, switch (vdev_prop_get_type(prop)) { case PROP_TYPE_STRING: if (nvlist_lookup_nvlist(nvprop, prop_name, &nv) == 0) { - verify(nvlist_lookup_uint64(nv, ZPROP_SOURCE, - &intval) == 0); - src = intval; - verify(nvlist_lookup_string(nv, ZPROP_VALUE, - &strval) == 0); + src = fnvlist_lookup_uint64(nv, ZPROP_SOURCE); + strval = fnvlist_lookup_string(nv, ZPROP_VALUE); } else { src = ZPROP_SRC_DEFAULT; if ((strval = (char *)vdev_prop_default_string(prop)) @@ -5150,11 +5112,8 @@ zpool_get_vdev_prop_value(nvlist_t *nvprop, vdev_prop_t prop, char *prop_name, case PROP_TYPE_NUMBER: if (nvlist_lookup_nvlist(nvprop, prop_name, &nv) == 0) { - verify(nvlist_lookup_uint64(nv, ZPROP_SOURCE, - &intval) == 0); - src = intval; - verify(nvlist_lookup_uint64(nv, ZPROP_VALUE, - &intval) == 0); + src = fnvlist_lookup_uint64(nv, ZPROP_SOURCE); + intval = fnvlist_lookup_uint64(nv, ZPROP_VALUE); } else { src = ZPROP_SRC_DEFAULT; intval = vdev_prop_default_numeric(prop); @@ -5234,11 +5193,8 @@ zpool_get_vdev_prop_value(nvlist_t *nvprop, vdev_prop_t prop, char *prop_name, case PROP_TYPE_INDEX: if (nvlist_lookup_nvlist(nvprop, prop_name, &nv) == 0) { - verify(nvlist_lookup_uint64(nv, ZPROP_SOURCE, - &intval) == 0); - src = intval; - verify(nvlist_lookup_uint64(nv, ZPROP_VALUE, - &intval) == 0); + src = fnvlist_lookup_uint64(nv, ZPROP_SOURCE); + intval = fnvlist_lookup_uint64(nv, ZPROP_VALUE); } else { src = ZPROP_SRC_DEFAULT; intval = vdev_prop_default_numeric(prop); diff --git a/lib/libzfs/libzfs_status.c b/lib/libzfs/libzfs_status.c index b7713b2bf..348a09361 100644 --- a/lib/libzfs/libzfs_status.c +++ b/lib/libzfs/libzfs_status.c @@ -159,8 +159,7 @@ find_vdev_problem(nvlist_t *vdev, int (*func)(vdev_stat_t *, uint_t), boolean_t ignore_replacing) { nvlist_t **child; - vdev_stat_t *vs; - uint_t c, vsc, children; + uint_t c, children; /* * Ignore problems within a 'replacing' vdev, since we're presumably in @@ -169,10 +168,7 @@ find_vdev_problem(nvlist_t *vdev, int (*func)(vdev_stat_t *, uint_t), * later. */ if (ignore_replacing == B_TRUE) { - char *type; - - verify(nvlist_lookup_string(vdev, ZPOOL_CONFIG_TYPE, - &type) == 0); + char *type = fnvlist_lookup_string(vdev, ZPOOL_CONFIG_TYPE); if (strcmp(type, VDEV_TYPE_REPLACING) == 0) return (B_FALSE); } @@ -183,9 +179,9 @@ find_vdev_problem(nvlist_t *vdev, int (*func)(vdev_stat_t *, uint_t), if (find_vdev_problem(child[c], func, ignore_replacing)) return (B_TRUE); } else { - verify(nvlist_lookup_uint64_array(vdev, ZPOOL_CONFIG_VDEV_STATS, - (uint64_t **)&vs, &vsc) == 0); - + uint_t vsc; + vdev_stat_t *vs = (vdev_stat_t *)fnvlist_lookup_uint64_array( + vdev, ZPOOL_CONFIG_VDEV_STATS, &vsc); if (func(vs, vsc) != 0) return (B_TRUE); } @@ -224,26 +220,21 @@ static zpool_status_t check_status(nvlist_t *config, boolean_t isimport, zpool_errata_t *erratap, const char *compat) { - nvlist_t *nvroot; - vdev_stat_t *vs; pool_scan_stat_t *ps = NULL; uint_t vsc, psc; uint64_t nerr; - uint64_t version; - uint64_t stateval; uint64_t suspended; uint64_t hostid = 0; uint64_t errata = 0; unsigned long system_hostid = get_system_hostid(); - verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION, - &version) == 0); - verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, - &nvroot) == 0); - verify(nvlist_lookup_uint64_array(nvroot, ZPOOL_CONFIG_VDEV_STATS, - (uint64_t **)&vs, &vsc) == 0); - verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_STATE, - &stateval) == 0); + uint64_t version = fnvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION); + nvlist_t *nvroot = fnvlist_lookup_nvlist(config, + ZPOOL_CONFIG_VDEV_TREE); + vdev_stat_t *vs = (vdev_stat_t *)fnvlist_lookup_uint64_array(nvroot, + ZPOOL_CONFIG_VDEV_STATS, &vsc); + uint64_t stateval = fnvlist_lookup_uint64(config, + ZPOOL_CONFIG_POOL_STATE); /* * Currently resilvering a vdev @@ -337,10 +328,8 @@ check_status(nvlist_t *config, boolean_t isimport, */ if (vs->vs_state == VDEV_STATE_CANT_OPEN && vs->vs_aux == VDEV_AUX_UNSUP_FEAT) { - nvlist_t *nvinfo; - - verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_LOAD_INFO, - &nvinfo) == 0); + nvlist_t *nvinfo = fnvlist_lookup_nvlist(config, + ZPOOL_CONFIG_LOAD_INFO); if (nvlist_exists(nvinfo, ZPOOL_CONFIG_CAN_RDONLY)) return (ZPOOL_STATUS_UNSUP_FEAT_WRITE); return (ZPOOL_STATUS_UNSUP_FEAT_READ); diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c index f38eeb512..7ed03d182 100644 --- a/lib/libzfs/libzfs_util.c +++ b/lib/libzfs/libzfs_util.c @@ -1199,10 +1199,8 @@ zcmd_write_nvlist_com(libzfs_handle_t *hdl, uint64_t *outnv, uint64_t *outlen, nvlist_t *nvl) { char *packed; - size_t len; - - verify(nvlist_size(nvl, &len, NV_ENCODE_NATIVE) == 0); + size_t len = fnvlist_size(nvl); if ((packed = zfs_alloc(hdl, len)) == NULL) return (-1); diff --git a/lib/libzfs/os/linux/libzfs_pool_os.c b/lib/libzfs/os/linux/libzfs_pool_os.c index 90eb8db50..65a7a89fa 100644 --- a/lib/libzfs/os/linux/libzfs_pool_os.c +++ b/lib/libzfs/os/linux/libzfs_pool_os.c @@ -224,10 +224,8 @@ zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, const char *name) dgettext(TEXT_DOMAIN, "cannot label '%s'"), name); if (zhp) { - nvlist_t *nvroot; - - verify(nvlist_lookup_nvlist(zhp->zpool_config, - ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0); + nvlist_t *nvroot = fnvlist_lookup_nvlist(zhp->zpool_config, + ZPOOL_CONFIG_VDEV_TREE); if (zhp->zpool_start_block == 0) start_block = find_start_block(nvroot);