ASSERT3U(clp->cl_prop, ==, ZFS_PROP_MOUNTPOINT);
- if ((cn = zfs_alloc(zfs_get_handle(zhp),
- sizeof (prop_changenode_t))) == NULL) {
- zfs_close(zhp);
- return (ENOMEM);
- }
-
+ cn = zfs_alloc(zfs_get_handle(zhp), sizeof (prop_changenode_t));
cn->cn_handle = zhp;
cn->cn_mounted = zfs_is_mounted(zhp, NULL);
ASSERT3U(cn->cn_mounted, ==, B_TRUE);
(clp->cl_shareprop != ZPROP_INVAL &&
(share_sourcetype == ZPROP_SRC_DEFAULT ||
share_sourcetype == ZPROP_SRC_INHERITED))) {
- if ((cn = zfs_alloc(zfs_get_handle(zhp),
- sizeof (prop_changenode_t))) == NULL) {
- ret = -1;
- goto out;
- }
-
+ cn = zfs_alloc(zfs_get_handle(zhp), sizeof (prop_changenode_t));
cn->cn_handle = zhp;
cn->cn_mounted = (clp->cl_gflags & CL_GATHER_MOUNT_ALWAYS) ||
zfs_is_mounted(zhp, NULL);
char property[ZFS_MAXPROPLEN];
boolean_t legacy = B_FALSE;
- if ((clp = zfs_alloc(zhp->zfs_hdl, sizeof (prop_changelist_t))) == NULL)
- return (NULL);
+ clp = zfs_alloc(zhp->zfs_hdl, sizeof (prop_changelist_t));
/*
* For mountpoint-related tasks, we want to sort everything by
* Always add ourself to the list. We add ourselves to the end so that
* we're the last to be unmounted.
*/
- if ((cn = zfs_alloc(zhp->zfs_hdl,
- sizeof (prop_changenode_t))) == NULL) {
- zfs_close(temp);
- changelist_free(clp);
- return (NULL);
- }
-
+ cn = zfs_alloc(zhp->zfs_hdl, sizeof (prop_changenode_t));
cn->cn_handle = temp;
cn->cn_mounted = (clp->cl_gflags & CL_GATHER_MOUNT_ALWAYS) ||
zfs_is_mounted(temp, NULL);
return (no_memory(hdl));
}
- if (zcmd_alloc_dst_nvlist(hdl, &zc, 0) != 0)
- return (-1);
+ zcmd_alloc_dst_nvlist(hdl, &zc, 0);
for (;;) {
zc.zc_cookie = hdl->libzfs_ns_gen;
return (0);
case ENOMEM:
- if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) {
- zcmd_free_nvlists(&zc);
- return (-1);
- }
+ zcmd_expand_dst_nvlist(hdl, &zc);
break;
default:
nvlist_t *child;
uu_avl_index_t where;
- if ((cn = zfs_alloc(hdl, sizeof (config_node_t))) == NULL) {
- nvlist_free(config);
- return (-1);
- }
-
- if ((cn->cn_name = zfs_strdup(hdl,
- nvpair_name(elem))) == NULL) {
- free(cn);
- nvlist_free(config);
- return (-1);
- }
-
+ cn = zfs_alloc(hdl, sizeof (config_node_t));
+ cn->cn_name = zfs_strdup(hdl, nvpair_name(elem));
child = fnvpair_value_nvlist(elem);
if (nvlist_dup(child, &cn->cn_config, 0) != 0) {
free(cn->cn_name);
if (zhp->zpool_config_size == 0)
zhp->zpool_config_size = 1 << 16;
- if (zcmd_alloc_dst_nvlist(hdl, &zc, zhp->zpool_config_size) != 0)
- return (-1);
+ zcmd_alloc_dst_nvlist(hdl, &zc, zhp->zpool_config_size);
for (;;) {
if (zfs_ioctl(zhp->zpool_hdl, ZFS_IOC_POOL_STATS,
break;
}
- if (errno == ENOMEM) {
- if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) {
- zcmd_free_nvlists(&zc);
- return (-1);
- }
- } else {
+ if (errno == ENOMEM)
+ zcmd_expand_dst_nvlist(hdl, &zc);
+ else {
zcmd_free_nvlists(&zc);
if (errno == ENOENT || errno == EINVAL)
*missing = B_TRUE;
*key_out = NULL;
key = zfs_alloc(hdl, WRAPPING_KEY_LEN);
- if (!key)
- return (ENOMEM);
switch (format) {
case ZFS_KEYFORMAT_RAW:
(void) strlcpy(zc->zc_name, zhp->zfs_name, sizeof (zc->zc_name));
while (zfs_ioctl(hdl, ZFS_IOC_OBJSET_STATS, zc) != 0) {
- if (errno == ENOMEM) {
- if (zcmd_expand_dst_nvlist(hdl, zc) != 0) {
- return (-1);
- }
- } else {
+ if (errno == ENOMEM)
+ zcmd_expand_dst_nvlist(hdl, zc);
+ else
return (-1);
- }
}
return (0);
}
zfs_cmd_t zc = {"\0"};
int err;
- if (zcmd_alloc_dst_nvlist(hdl, &zc, 0) != 0)
- return (-1);
+ zcmd_alloc_dst_nvlist(hdl, &zc, 0);
(void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
while (zfs_ioctl(hdl, ZFS_IOC_OBJSET_RECVD_PROPS, &zc) != 0) {
- if (errno == ENOMEM) {
- if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) {
- return (-1);
- }
- } else {
+ if (errno == ENOMEM)
+ zcmd_expand_dst_nvlist(hdl, &zc);
+ else {
zcmd_free_nvlists(&zc);
return (-1);
}
int rc = 0;
zfs_cmd_t zc = {"\0"};
- if (zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0) != 0)
- return (-1);
+ zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0);
+
if (get_stats_ioctl(zhp, &zc) != 0)
rc = -1;
else if (put_stats_zhdl(zhp, &zc) != 0)
zhp->zfs_hdl = hdl;
(void) strlcpy(zhp->zfs_name, path, sizeof (zhp->zfs_name));
- if (zcmd_alloc_dst_nvlist(hdl, &zc, 0) != 0) {
- free(zhp);
- return (NULL);
- }
+ zcmd_alloc_dst_nvlist(hdl, &zc, 0);
+
if (get_stats_ioctl(zhp, &zc) == -1) {
zcmd_free_nvlists(&zc);
free(zhp);
*/
(void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
- if ((ret = zcmd_write_src_nvlist(hdl, &zc, nvl)) != 0 ||
- (ret = zcmd_alloc_dst_nvlist(hdl, &zc, 0)) != 0)
- goto error;
+ zcmd_write_src_nvlist(hdl, &zc, nvl);
+ zcmd_alloc_dst_nvlist(hdl, &zc, 0);
ret = zfs_ioctl(hdl, ZFS_IOC_SET_PROP, &zc);
zfs_prop_to_name(ZFS_PROP_VOLSIZE),
old_volsize) != 0)
goto error;
- if (zcmd_write_src_nvlist(hdl, &zc, nvl) != 0)
- goto error;
+ zcmd_write_src_nvlist(hdl, &zc, nvl);
(void) zfs_ioctl(hdl, ZFS_IOC_SET_PROP, &zc);
}
} else {
libzfs_handle_t *hdl = zhp->zfs_hdl;
struct mnttab entry;
- if (libzfs_mnttab_find(hdl, zhp->zfs_name, &entry) == 0) {
+ if (libzfs_mnttab_find(hdl, zhp->zfs_name, &entry) == 0)
zhp->zfs_mntopts = zfs_strdup(hdl,
entry.mnt_mntopts);
- if (zhp->zfs_mntopts == NULL)
- return (-1);
- }
zhp->zfs_mntcheck = B_TRUE;
}
case ZFS_PROP_NORMALIZE:
case ZFS_PROP_UTF8ONLY:
case ZFS_PROP_CASE:
- if (zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0) != 0)
- return (-1);
+ zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0);
+
(void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
if (zfs_ioctl(zhp->zfs_hdl, ZFS_IOC_OBJSET_ZPLPROPS, &zc)) {
zcmd_free_nvlists(&zc);
}
if (flags.recursive) {
char *parentname = zfs_strdup(zhp->zfs_hdl, zhp->zfs_name);
- if (parentname == NULL) {
- ret = -1;
- goto error;
- }
delim = strchr(parentname, '@');
*delim = '\0';
zfs_handle_t *zhrp = zfs_open(zhp->zfs_hdl, parentname,
}
if (*last == NULL) {
- if ((entry = zfs_alloc(hdl,
- sizeof (zprop_list_t))) == NULL ||
- ((entry->pl_user_prop = zfs_strdup(hdl,
- nvpair_name(elem)))) == NULL) {
- free(entry);
- return (-1);
- }
-
+ entry = zfs_alloc(hdl, sizeof (zprop_list_t));
+ entry->pl_user_prop =
+ zfs_strdup(hdl, nvpair_name(elem));
entry->pl_prop = ZPROP_INVAL;
entry->pl_width = strlen(nvpair_name(elem));
entry->pl_all = B_TRUE;
(void) no_memory(hdl);
return (-1);
}
- if (zcmd_write_src_nvlist(hdl, &zc, nvlist) != 0) {
- nvlist_free(nvlist);
- return (-1);
- }
+ zcmd_write_src_nvlist(hdl, &zc, nvlist);
break;
case ZFS_SMB_ACL_PURGE:
break;
di->isclone = B_TRUE;
di->fromsnap = zfs_strdup(hdl, fromsnap);
- if (tsnlen) {
+ if (tsnlen)
di->tosnap = zfs_strdup(hdl, tosnap);
- } else {
+ else
return (make_temp_snapshot(di));
- }
} else {
int dslen = fdslen ? fdslen : tdslen;
typedef struct prop_changelist prop_changelist_t;
-extern int zcmd_alloc_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *, size_t);
-extern int zcmd_write_src_nvlist(libzfs_handle_t *, zfs_cmd_t *, nvlist_t *);
-extern int zcmd_write_conf_nvlist(libzfs_handle_t *, zfs_cmd_t *, nvlist_t *);
-extern int zcmd_expand_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *);
+extern void zcmd_alloc_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *, size_t);
+extern void zcmd_write_src_nvlist(libzfs_handle_t *, zfs_cmd_t *, nvlist_t *);
+extern void zcmd_write_conf_nvlist(libzfs_handle_t *, zfs_cmd_t *, nvlist_t *);
+extern void zcmd_expand_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *);
extern int zcmd_read_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *, nvlist_t **);
extern void zcmd_free_nvlists(zfs_cmd_t *);
zfs_cmd_t zc = {"\0"};
int err, dstbuf_size;
- if (zcmd_write_conf_nvlist(hdl, &zc, config) != 0)
- return (NULL);
+ zcmd_write_conf_nvlist(hdl, &zc, config);
dstbuf_size = MAX(CONFIG_BUF_MINSIZE, zc.zc_nvlist_conf_size * 32);
- if (zcmd_alloc_dst_nvlist(hdl, &zc, dstbuf_size) != 0) {
- zcmd_free_nvlists(&zc);
- return (NULL);
- }
+ zcmd_alloc_dst_nvlist(hdl, &zc, dstbuf_size);
while ((err = zfs_ioctl(hdl, ZFS_IOC_POOL_TRYIMPORT,
- &zc)) != 0 && errno == ENOMEM) {
- if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) {
- zcmd_free_nvlists(&zc);
- return (NULL);
- }
- }
+ &zc)) != 0 && errno == ENOMEM)
+ zcmd_expand_dst_nvlist(hdl, &zc);
if (err) {
zcmd_free_nvlists(&zc);
if (ret) {
- if ((*namestr = zfs_strdup(hdl, name)) == NULL) {
- if (cb.cb_zhp)
- zpool_close(cb.cb_zhp);
- nvlist_free(config);
- return (-1);
- }
+ *namestr = zfs_strdup(hdl, name);
*state = (pool_state_t)stateval;
}
switch (errno) {
case ENOMEM:
/* expand nvlist memory and try again */
- if (zcmd_expand_dst_nvlist(zhp->zfs_hdl, zc) != 0) {
- zcmd_free_nvlists(zc);
- return (-1);
- }
+ zcmd_expand_dst_nvlist(zhp->zfs_hdl, zc);
zc->zc_cookie = orig_cookie;
goto top;
/*
if (zhp->zfs_type != ZFS_TYPE_FILESYSTEM)
return (0);
- if (zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0) != 0)
- return (-1);
+ zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0);
while ((ret = zfs_do_list_ioctl(zhp, ZFS_IOC_DATASET_LIST_NEXT,
&zc)) == 0) {
zc.zc_simple = simple;
- if (zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0) != 0)
- return (-1);
+ zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0);
if (min_txg != 0) {
range_nvl = fnvlist_alloc();
fnvlist_add_uint64(range_nvl, SNAP_ITER_MAX_TXG, max_txg);
}
- if (range_nvl != NULL &&
- zcmd_write_src_nvlist(zhp->zfs_hdl, &zc, range_nvl) != 0) {
- zcmd_free_nvlists(&zc);
- fnvlist_free(range_nvl);
- return (-1);
- }
+ if (range_nvl != NULL)
+ zcmd_write_src_nvlist(zhp->zfs_hdl, &zc, range_nvl);
while ((ret = zfs_do_list_ioctl(zhp, ZFS_IOC_SNAPSHOT_LIST_NEXT,
&zc)) == 0) {
*/
if (used == alloc) {
if (alloc == 0) {
-
- if ((sets = zfs_alloc(hdl,
- 8 * sizeof (struct sets_s))) == NULL)
- goto out;
-
+ sets = zfs_alloc(hdl,
+ 8 * sizeof (struct sets_s));
alloc = 8;
} else {
- void *ptr;
-
- if ((ptr = zfs_realloc(hdl, sets,
+ sets = zfs_realloc(hdl, sets,
alloc * sizeof (struct sets_s),
- alloc * 2 * sizeof (struct sets_s)))
- == NULL)
- goto out;
- sets = ptr;
+ alloc * 2 * sizeof (struct sets_s));
alloc *= 2;
}
}
- if ((sets[used].mountpoint = zfs_strdup(hdl,
- entry.mnt_mountp)) == NULL)
- goto out;
+ sets[used].mountpoint = zfs_strdup(hdl, entry.mnt_mountp);
/*
* This is allowed to fail, in case there is some I/O error. It
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
- if (zcmd_alloc_dst_nvlist(hdl, &zc, 0) != 0)
- return (-1);
+ zcmd_alloc_dst_nvlist(hdl, &zc, 0);
while (zfs_ioctl(hdl, ZFS_IOC_POOL_GET_PROPS, &zc) != 0) {
- if (errno == ENOMEM) {
- if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) {
- zcmd_free_nvlists(&zc);
- return (-1);
- }
- } else {
+ if (errno == ENOMEM)
+ zcmd_expand_dst_nvlist(hdl, &zc);
+ else {
zcmd_free_nvlists(&zc);
return (-1);
}
*/
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
- if (zcmd_write_src_nvlist(zhp->zpool_hdl, &zc, nvl) != 0) {
- nvlist_free(nvl);
- return (-1);
- }
+ zcmd_write_src_nvlist(zhp->zpool_hdl, &zc, nvl);
ret = zfs_ioctl(zhp->zpool_hdl, ZFS_IOC_POOL_SET_PROPS, &zc);
strval = fnvlist_lookup_string(propval, ZPROP_VALUE);
- if ((entry = zfs_alloc(zhp->zpool_hdl,
- sizeof (zprop_list_t))) == NULL)
- return (ENOMEM);
-
+ entry = zfs_alloc(zhp->zpool_hdl,
+ sizeof (zprop_list_t));
entry->pl_prop = prop;
entry->pl_user_prop = zfs_strdup(zhp->zpool_hdl,
propname);
return (NULL);
}
- if ((zhp = zfs_alloc(hdl, sizeof (zpool_handle_t))) == NULL)
- return (NULL);
+ zhp = zfs_alloc(hdl, sizeof (zpool_handle_t));
zhp->zpool_hdl = hdl;
(void) strlcpy(zhp->zpool_name, pool, sizeof (zhp->zpool_name));
zpool_handle_t *zhp;
boolean_t missing;
- if ((zhp = zfs_alloc(hdl, sizeof (zpool_handle_t))) == NULL)
- return (-1);
+ zhp = zfs_alloc(hdl, sizeof (zpool_handle_t));
zhp->zpool_hdl = hdl;
(void) strlcpy(zhp->zpool_name, pool, sizeof (zhp->zpool_name));
if (!zpool_name_valid(hdl, B_FALSE, pool))
return (zfs_error(hdl, EZFS_INVALIDNAME, msg));
- if (zcmd_write_conf_nvlist(hdl, &zc, nvroot) != 0)
- return (-1);
+ zcmd_write_conf_nvlist(hdl, &zc, nvroot);
if (props) {
prop_flags_t flags = { .create = B_TRUE, .import = B_FALSE };
}
}
- if (zc_props && zcmd_write_src_nvlist(hdl, &zc, zc_props) != 0)
- goto create_failed;
+ if (zc_props)
+ zcmd_write_src_nvlist(hdl, &zc, zc_props);
(void) strlcpy(zc.zc_name, pool, sizeof (zc.zc_name));
return (zfs_error(hdl, EZFS_BADVERSION, msg));
}
- if (zcmd_write_conf_nvlist(hdl, &zc, nvroot) != 0)
- return (-1);
+ zcmd_write_conf_nvlist(hdl, &zc, nvroot);
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
if (zfs_ioctl(hdl, ZFS_IOC_VDEV_ADD, &zc) != 0) {
if ((props = zpool_valid_proplist(hdl, origname,
props, version, flags, errbuf)) == NULL)
return (-1);
- if (zcmd_write_src_nvlist(hdl, &zc, props) != 0) {
- nvlist_free(props);
- return (-1);
- }
+ zcmd_write_src_nvlist(hdl, &zc, props);
nvlist_free(props);
}
zc.zc_guid = fnvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID);
- if (zcmd_write_conf_nvlist(hdl, &zc, config) != 0) {
- zcmd_free_nvlists(&zc);
- return (-1);
- }
- if (zcmd_alloc_dst_nvlist(hdl, &zc, zc.zc_nvlist_conf_size * 2) != 0) {
- zcmd_free_nvlists(&zc);
- return (-1);
- }
+ zcmd_write_conf_nvlist(hdl, &zc, config);
+ zcmd_alloc_dst_nvlist(hdl, &zc, zc.zc_nvlist_conf_size * 2);
zc.zc_cookie = flags;
while ((ret = zfs_ioctl(hdl, ZFS_IOC_POOL_IMPORT, &zc)) != 0 &&
- errno == ENOMEM) {
- if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) {
- zcmd_free_nvlists(&zc);
- return (-1);
- }
- }
+ errno == ENOMEM)
+ zcmd_expand_dst_nvlist(hdl, &zc);
if (ret != 0)
error = errno;
free(newname);
- if (zcmd_write_conf_nvlist(hdl, &zc, nvroot) != 0)
- return (-1);
+ zcmd_write_conf_nvlist(hdl, &zc, nvroot);
ret = zfs_ioctl(hdl, ZFS_IOC_VDEV_ATTACH, &zc);
zc.zc_cookie = ZPOOL_EXPORT_AFTER_SPLIT;
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
(void) strlcpy(zc.zc_string, newname, sizeof (zc.zc_string));
- if (zcmd_write_conf_nvlist(hdl, &zc, newconfig) != 0)
- goto out;
- if (zc_props != NULL && zcmd_write_src_nvlist(hdl, &zc, zc_props) != 0)
- goto out;
+ zcmd_write_conf_nvlist(hdl, &zc, newconfig);
+ if (zc_props != NULL)
+ zcmd_write_src_nvlist(hdl, &zc, zc_props);
if (zfs_ioctl(hdl, ZFS_IOC_VDEV_SPLIT, &zc) != 0) {
retval = zpool_standard_error(hdl, errno, msg);
zpool_get_load_policy(rewindnvl, &policy);
zc.zc_cookie = policy.zlp_rewind;
- if (zcmd_alloc_dst_nvlist(hdl, &zc, zhp->zpool_config_size * 2) != 0)
- return (-1);
-
- if (zcmd_write_src_nvlist(hdl, &zc, rewindnvl) != 0)
- return (-1);
+ zcmd_alloc_dst_nvlist(hdl, &zc, zhp->zpool_config_size * 2);
+ zcmd_write_src_nvlist(hdl, &zc, rewindnvl);
while ((error = zfs_ioctl(hdl, ZFS_IOC_CLEAR, &zc)) != 0 &&
- errno == ENOMEM) {
- if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) {
- zcmd_free_nvlists(&zc);
- return (-1);
- }
- }
+ errno == ENOMEM)
+ zcmd_expand_dst_nvlist(hdl, &zc);
if (!error || ((policy.zlp_rewind & ZPOOL_TRY_REWIND) &&
errno != EPERM && errno != EACCES)) {
{
zfs_cmd_t zc = {"\0"};
nvlist_t *args;
- int err;
args = fnvlist_alloc();
fnvlist_add_string(args, "message", message);
- err = zcmd_write_src_nvlist(hdl, &zc, args);
- if (err == 0)
- err = zfs_ioctl(hdl, ZFS_IOC_LOG_HISTORY, &zc);
+ zcmd_write_src_nvlist(hdl, &zc, args);
+ int err = zfs_ioctl(hdl, ZFS_IOC_LOG_HISTORY, &zc);
nvlist_free(args);
zcmd_free_nvlists(&zc);
return (err);
if (flags & ZEVENT_NONBLOCK)
zc.zc_guid = ZEVENT_NONBLOCK;
- if (zcmd_alloc_dst_nvlist(hdl, &zc, ZEVENT_SIZE) != 0)
- return (-1);
+ zcmd_alloc_dst_nvlist(hdl, &zc, ZEVENT_SIZE);
retry:
if (zfs_ioctl(hdl, ZFS_IOC_EVENTS_NEXT, &zc) != 0) {
goto out;
case ENOMEM:
- if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) {
- error = zfs_error_fmt(hdl, EZFS_NOMEM,
- dgettext(TEXT_DOMAIN, "cannot get event"));
- goto out;
- } else {
- goto retry;
- }
+ zcmd_expand_dst_nvlist(hdl, &zc);
+ goto retry;
default:
error = zpool_standard_error_fmt(hdl, errno,
dgettext(TEXT_DOMAIN, "cannot get event"));
int err;
buf = zfs_alloc(hdl, len);
- if (buf == NULL)
- return (ENOMEM);
if (len > hdl->libzfs_max_nvlist) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "nvlist too large"));
zc.zc_cookie = B_TRUE; /* received */
(void) snprintf(zc.zc_name, sizeof (zc.zc_name),
"%s@%s", fsname, nvpair_name(snapelem));
- if (zcmd_write_src_nvlist(hdl, &zc,
- props) == 0) {
- (void) zfs_ioctl(hdl,
- ZFS_IOC_SET_PROP, &zc);
- zcmd_free_nvlists(&zc);
- }
+ zcmd_write_src_nvlist(hdl, &zc, props);
+ (void) zfs_ioctl(hdl,
+ ZFS_IOC_SET_PROP, &zc);
+ zcmd_free_nvlists(&zc);
}
/* check for different snapname */
(void) strcpy(zc.zc_name, destsnap);
zc.zc_cookie = B_TRUE; /* received */
- if (zcmd_write_src_nvlist(hdl, &zc, snapprops_nvlist) == 0) {
- (void) zfs_ioctl(hdl, ZFS_IOC_SET_PROP, &zc);
- zcmd_free_nvlists(&zc);
- }
+ zcmd_write_src_nvlist(hdl, &zc, snapprops_nvlist);
+ (void) zfs_ioctl(hdl, ZFS_IOC_SET_PROP, &zc);
+ zcmd_free_nvlists(&zc);
}
if (err == 0 && snapholds_nvlist) {
nvpair_t *pair;
* Initialize the zc_nvlist_dst member to prepare for receiving an nvlist from
* an ioctl().
*/
-int
+void
zcmd_alloc_dst_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, size_t len)
{
if (len == 0)
zc->zc_nvlist_dst_size = len;
zc->zc_nvlist_dst =
(uint64_t)(uintptr_t)zfs_alloc(hdl, zc->zc_nvlist_dst_size);
- if (zc->zc_nvlist_dst == 0)
- return (-1);
-
- return (0);
}
/*
* expand the nvlist to the size specified in 'zc_nvlist_dst_size', which was
* filled in by the kernel to indicate the actual required size.
*/
-int
+void
zcmd_expand_dst_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc)
{
free((void *)(uintptr_t)zc->zc_nvlist_dst);
zc->zc_nvlist_dst =
(uint64_t)(uintptr_t)zfs_alloc(hdl, zc->zc_nvlist_dst_size);
- if (zc->zc_nvlist_dst == 0)
- return (-1);
-
- return (0);
}
/*
zc->zc_nvlist_dst = 0;
}
-static int
+static void
zcmd_write_nvlist_com(libzfs_handle_t *hdl, uint64_t *outnv, uint64_t *outlen,
nvlist_t *nvl)
{
char *packed;
size_t len = fnvlist_size(nvl);
- if ((packed = zfs_alloc(hdl, len)) == NULL)
- return (-1);
+ packed = zfs_alloc(hdl, len);
verify(nvlist_pack(nvl, &packed, &len, NV_ENCODE_NATIVE, 0) == 0);
*outnv = (uint64_t)(uintptr_t)packed;
*outlen = len;
-
- return (0);
}
-int
+void
zcmd_write_conf_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, nvlist_t *nvl)
{
- return (zcmd_write_nvlist_com(hdl, &zc->zc_nvlist_conf,
- &zc->zc_nvlist_conf_size, nvl));
+ zcmd_write_nvlist_com(hdl, &zc->zc_nvlist_conf,
+ &zc->zc_nvlist_conf_size, nvl);
}
-int
+void
zcmd_write_src_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, nvlist_t *nvl)
{
- return (zcmd_write_nvlist_com(hdl, &zc->zc_nvlist_src,
- &zc->zc_nvlist_src_size, nvl));
+ zcmd_write_nvlist_com(hdl, &zc->zc_nvlist_src,
+ &zc->zc_nvlist_src_size, nvl);
}
/*
zprop_list_t *entry;
expand_data_t *edp = cb;
- if ((entry = zfs_alloc(edp->hdl, sizeof (zprop_list_t))) == NULL)
- return (ZPROP_INVAL);
+ entry = zfs_alloc(edp->hdl, sizeof (zprop_list_t));
entry->pl_prop = prop;
entry->pl_width = zprop_width(prop, &entry->pl_fixed, edp->type);
{
zfs_cmd_t zc = {"\0"};
nvlist_t *args;
- int error;
args = fnvlist_alloc();
fnvlist_add_uint64(args, ZPOOL_CONFIG_POOL_GUID, pool_guid);
fnvlist_add_uint64(args, ZPOOL_CONFIG_GUID, dev_guid);
fnvlist_add_string(args, "command", command);
- error = zcmd_write_src_nvlist(hdl, &zc, args);
- if (error == 0)
- error = zfs_ioctl(hdl, ZFS_IOC_NEXTBOOT, &zc);
+ zcmd_write_src_nvlist(hdl, &zc, args);
+ int error = zfs_ioctl(hdl, ZFS_IOC_NEXTBOOT, &zc);
zcmd_free_nvlists(&zc);
nvlist_free(args);
return (error);