libzfs: don't NULL-check infallible allocations

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13229
This commit is contained in:
наб
2022-03-16 19:51:28 +01:00
committed by Brian Behlendorf
parent bc3f12bfac
commit 18dbf5c8c3
13 changed files with 105 additions and 262 deletions
+8 -26
View File
@@ -126,8 +126,7 @@ namespace_reload(libzfs_handle_t *hdl)
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;
@@ -141,10 +140,7 @@ namespace_reload(libzfs_handle_t *hdl)
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:
@@ -181,18 +177,8 @@ namespace_reload(libzfs_handle_t *hdl)
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);
@@ -273,8 +259,7 @@ zpool_refresh_stats(zpool_handle_t *zhp, boolean_t *missing)
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,
@@ -286,12 +271,9 @@ zpool_refresh_stats(zpool_handle_t *zhp, boolean_t *missing)
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;