]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Illumos 6659 - nvlist_free(NULL) is a no-op
authorJosef 'Jeff' Sipek <jeffpc@josefsipek.net>
Fri, 1 Apr 2016 03:54:07 +0000 (23:54 -0400)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 27 Apr 2016 22:58:23 +0000 (15:58 -0700)
6659 nvlist_free(NULL) is a no-op
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Marcel Telka <marcel@telka.sk>
Approved by: Robert Mustacchi <rm@joyent.com>

References:
  https://www.illumos.org/issues/6659
  https://github.com/illumos/illumos-gate/commit/aab83bb

Ported-by: David Quigley <dpquigl@davequigley.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4566

cmd/zfs/zfs_main.c
cmd/zpool/zpool_main.c
cmd/zpool/zpool_vdev.c
lib/libzfs/libzfs_config.c
lib/libzfs/libzfs_dataset.c
lib/libzfs/libzfs_import.c
lib/libzfs/libzfs_pool.c
lib/libzfs/libzfs_sendrecv.c
module/zfs/spa.c
module/zfs/spa_config.c
module/zfs/zfs_ioctl.c

index 57960745134f4e0fecc622a7b4375aa047dcce04..7525afcbfd6df6cb098b7b5e80ae54e10565199e 100644 (file)
@@ -5294,8 +5294,7 @@ zfs_do_allow_unallow_impl(int argc, char **argv, boolean_t un)
 
 cleanup0:
        nvlist_free(perm_nvl);
-       if (update_perm_nvl != NULL)
-               nvlist_free(update_perm_nvl);
+       nvlist_free(update_perm_nvl);
 cleanup1:
        fs_perm_set_fini(&fs_perm_set);
 cleanup2:
index d6b9f49148499353c08df1f4b6f08be0c8da2943..0c48805d11ef76859edd84d4e27c7c5d19602330 100644 (file)
@@ -3674,8 +3674,7 @@ zpool_do_split(int argc, char **argv)
                        if (add_prop_list(
                            zpool_prop_to_name(ZPOOL_PROP_ALTROOT), optarg,
                            &props, B_TRUE) != 0) {
-                               if (props)
-                                       nvlist_free(props);
+                               nvlist_free(props);
                                usage(B_FALSE);
                        }
                        break;
@@ -3688,8 +3687,7 @@ zpool_do_split(int argc, char **argv)
                                propval++;
                                if (add_prop_list(optarg, propval,
                                    &props, B_TRUE) != 0) {
-                                       if (props)
-                                               nvlist_free(props);
+                                       nvlist_free(props);
                                        usage(B_FALSE);
                                }
                        } else {
index cf87554d5d8bf4ad93fd0c53950a9eb1b90c34ae..587aa7fd4861f027faaa1e0d289410a9bc179fe9 100644 (file)
@@ -1675,8 +1675,7 @@ split_mirror_vdev(zpool_handle_t *zhp, char *newname, nvlist_t *props,
        }
 
        if (zpool_vdev_split(zhp, newname, &newroot, props, flags) != 0) {
-               if (newroot != NULL)
-                       nvlist_free(newroot);
+               nvlist_free(newroot);
                return (NULL);
        }
 
index 849a13051b1eb78c47a6d430067004b78472866c..6ecfe98ff739194cc072b63cc7895fee27081695 100644 (file)
@@ -311,8 +311,7 @@ zpool_refresh_stats(zpool_handle_t *zhp, boolean_t *missing)
        zhp->zpool_config_size = zc.zc_nvlist_dst_size;
 
        if (zhp->zpool_config != NULL) {
-               if (zhp->zpool_old_config != NULL)
-                       nvlist_free(zhp->zpool_old_config);
+               nvlist_free(zhp->zpool_old_config);
 
                zhp->zpool_old_config = zhp->zpool_config;
        }
index d2489c11a44522c781d1021f336b36176d0f6710..1d9e5156a34af895ae88abf9618c5396f14b511a 100644 (file)
@@ -2079,8 +2079,7 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
                        zcmd_free_nvlists(&zc);
                        return (-1);
                }
-               if (zplprops)
-                       nvlist_free(zplprops);
+               nvlist_free(zplprops);
                zcmd_free_nvlists(&zc);
                break;
 
@@ -4269,8 +4268,7 @@ zfs_smb_acl_mgmt(libzfs_handle_t *hdl, char *dataset, char *path,
                return (-1);
        }
        error = ioctl(hdl->libzfs_fd, ZFS_IOC_SMB_ACL, &zc);
-       if (nvlist)
-               nvlist_free(nvlist);
+       nvlist_free(nvlist);
        return (error);
 }
 
index fa51b6d0def25fac24b6cf237fdf1c6a592acb49..25f369db96228f4df7103052748c3d100e7a81e1 100644 (file)
@@ -1973,8 +1973,7 @@ error:
                        venext = ve->ve_next;
                        for (ce = ve->ve_configs; ce != NULL; ce = cenext) {
                                cenext = ce->ce_next;
-                               if (ce->ce_config)
-                                       nvlist_free(ce->ce_config);
+                               nvlist_free(ce->ce_config);
                                free(ce);
                        }
                        free(ve);
index c405abe3edf13c9d3b349715ab2d8ac223eb1460..80ed010c1fee620a94729814eff69d3565d34c4f 100644 (file)
@@ -1146,12 +1146,9 @@ zpool_open(libzfs_handle_t *hdl, const char *pool)
 void
 zpool_close(zpool_handle_t *zhp)
 {
-       if (zhp->zpool_config)
-               nvlist_free(zhp->zpool_config);
-       if (zhp->zpool_old_config)
-               nvlist_free(zhp->zpool_old_config);
-       if (zhp->zpool_props)
-               nvlist_free(zhp->zpool_props);
+       nvlist_free(zhp->zpool_config);
+       nvlist_free(zhp->zpool_old_config);
+       nvlist_free(zhp->zpool_props);
        free(zhp);
 }
 
@@ -1688,8 +1685,7 @@ zpool_import(libzfs_handle_t *hdl, nvlist_t *config, const char *newname,
 
        ret = zpool_import_props(hdl, config, newname, props,
            ZFS_IMPORT_NORMAL);
-       if (props)
-               nvlist_free(props);
+       nvlist_free(props);
        return (ret);
 }
 
@@ -2959,8 +2955,7 @@ zpool_vdev_split(zpool_handle_t *zhp, char *newname, nvlist_t **newroot,
            &children) != 0) {
                zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
                    "Source pool is missing vdev tree"));
-               if (zc_props)
-                       nvlist_free(zc_props);
+               nvlist_free(zc_props);
                return (-1);
        }
 
@@ -3108,10 +3103,8 @@ out:
                free(varray);
        }
        zcmd_free_nvlists(&zc);
-       if (zc_props)
-               nvlist_free(zc_props);
-       if (newconfig)
-               nvlist_free(newconfig);
+       nvlist_free(zc_props);
+       nvlist_free(newconfig);
        if (freelist) {
                nvlist_free(*newroot);
                *newroot = NULL;
index 2adcb0c0f532c517ca2b388f55dd2f2ba0c5519d..92a55f77cf191cad6de55eba2d7eb27b272c6d0a 100644 (file)
@@ -2545,8 +2545,7 @@ zfs_receive_package(libzfs_handle_t *hdl, int fd, const char *destname,
 
 out:
        fsavl_destroy(stream_avl);
-       if (stream_nv)
-               nvlist_free(stream_nv);
+       nvlist_free(stream_nv);
        if (softerr)
                error = -2;
        if (anyerr)
index 01048bfe90273ea3f0d257a6680f265a16b44c5f..63425d3d03eaaddd06befed7b5739f350a7025ee 100644 (file)
@@ -6132,8 +6132,7 @@ spa_sync_config_object(spa_t *spa, dmu_tx_t *tx)
 
        spa_config_exit(spa, SCL_STATE, FTAG);
 
-       if (spa->spa_config_syncing)
-               nvlist_free(spa->spa_config_syncing);
+       nvlist_free(spa->spa_config_syncing);
        spa->spa_config_syncing = config;
 
        spa_sync_nvlist(spa, spa->spa_config_object, config, tx);
index a62d25bd3ababd1aab20b305104c97e82a85ec3a..904940a651eabb754f5b16ef4b0c52a6e14e7b46 100644 (file)
@@ -376,8 +376,7 @@ void
 spa_config_set(spa_t *spa, nvlist_t *config)
 {
        mutex_enter(&spa->spa_props_lock);
-       if (spa->spa_config != NULL)
-               nvlist_free(spa->spa_config);
+       nvlist_free(spa->spa_config);
        spa->spa_config = config;
        mutex_exit(&spa->spa_props_lock);
 }
index 5c84d238f245bdd93ebc5b3ed92f061881721958..50f6a7a2c2f56462f26c741fb60a8ec8d5200662 100644 (file)
@@ -1536,9 +1536,7 @@ zfs_ioc_pool_import(zfs_cmd_t *zc)
        }
 
        nvlist_free(config);
-
-       if (props)
-               nvlist_free(props);
+       nvlist_free(props);
 
        return (error);
 }