]> granicus.if.org Git - zfs/commitdiff
Resolve remaining uninitialized variables
authorBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 12 Mar 2009 17:30:41 +0000 (10:30 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 12 Mar 2009 17:30:41 +0000 (10:30 -0700)
Most of these fixes appear to be harmless and should never occur.
However, there were a few cases in this patch which do concern me,
I doubt we're seeing them but they look possible... mainly in the
user tools.

cmd/zdb/zdb.c
cmd/zfs/zfs_main.c
cmd/zpool/zpool_main.c
cmd/zpool/zpool_vdev.c
cmd/ztest/ztest.c
lib/libzfs/libzfs_dataset.c
lib/libzfs/libzfs_import.c
lib/libzfs/libzfs_util.c
module/zfs/arc.c
module/zfs/dmu.c

index 0ced258656bc41f276809762b0941451017797d4..455e78a75253f80611428ebd14160ddf9a511814 100644 (file)
@@ -647,7 +647,7 @@ static int
 visit_indirect(spa_t *spa, const dnode_phys_t *dnp,
     blkptr_t *bp, const zbookmark_t *zb)
 {
-       int err;
+       int err = 0;
 
        if (bp->blk_birth == 0)
                return (0);
index 1f7f47d08a64791e14ace9df5199d5e1f6f660d7..cf30df7d82bf7723d4193fc1398ed6445a84f31d 100644 (file)
@@ -542,7 +542,7 @@ zfs_do_create(int argc, char **argv)
 {
        zfs_type_t type = ZFS_TYPE_FILESYSTEM;
        zfs_handle_t *zhp = NULL;
-       uint64_t volsize;
+       uint64_t volsize = 0;
        int c;
        boolean_t noreserve = B_FALSE;
        boolean_t bflag = B_FALSE;
@@ -4208,6 +4208,7 @@ main(int argc, char **argv)
                        (void) fprintf(stderr, gettext("unrecognized "
                            "command '%s'\n"), cmdname);
                        usage(B_FALSE);
+                       ret = 1;
                }
        }
 
index 42c6aabb63fdff98ac77abd052c35459be72c326..aeeff50fda06cf5c50a6444b7a2dbed573ec8211 100644 (file)
@@ -1373,7 +1373,7 @@ zpool_do_import(int argc, char **argv)
        char **searchdirs = NULL;
        int nsearch = 0;
        int c;
-       int err;
+       int err = 1;
        nvlist_t *pools = NULL;
        boolean_t do_all = B_FALSE;
        boolean_t do_destroyed = B_FALSE;
@@ -3942,6 +3942,7 @@ main(int argc, char **argv)
                (void) fprintf(stderr, gettext("unrecognized "
                    "command '%s'\n"), cmdname);
                usage(B_FALSE);
+               ret = 1;
        }
 
        libzfs_fini(g_zfs);
index 10007c14927f6961051c68e0eed420e6e958b454..9fa227c1028a1eed8cfd7dab9766ff7b7c59b29c 100644 (file)
@@ -548,7 +548,7 @@ get_replication(nvlist_t *nvroot, boolean_t fatal)
        uint_t c, children;
        nvlist_t *nv;
        char *type;
-       replication_level_t lastrep, rep, *ret;
+       replication_level_t lastrep = { 0 }, rep, *ret;
        boolean_t dontreport;
 
        ret = safe_malloc(sizeof (replication_level_t));
index 4503a3d02802104262b458430f54318b7901ae92..56873ce3f76a2b63069d488433b09c6c7f499c35 100644 (file)
@@ -1343,7 +1343,7 @@ ztest_dmu_objset_create_destroy(ztest_args_t *za)
        objects = ztest_random(20);
        seq = 0;
        while (objects-- != 0) {
-               uint64_t object;
+               uint64_t object = 0;
                dmu_tx_t *tx = dmu_tx_create(os);
                dmu_tx_hold_write(tx, DMU_NEW_OBJECT, 0, sizeof (name));
                error = dmu_tx_assign(tx, TXG_WAIT);
index 1c36b3b1b9a5f437e5f298c1349be5ba6c700c3c..c28460b0a123797ee16c19a4b750c56dd0ad9e75 100644 (file)
@@ -1606,7 +1606,7 @@ zfs_perm_get(zfs_handle_t *zhp, zfs_allow_t **zfs_perms)
        char *nvpname;
        uid_t   uid;
        gid_t   gid;
-       avl_tree_t *tree;
+       avl_tree_t *tree = NULL;
        avl_index_t where;
 
        (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
index d67776889d3501faecf2ccddefb025cc21967f41..b7e1333382d9b336402cea1ebf0d2ca76330946c 100644 (file)
@@ -416,7 +416,7 @@ get_configs(libzfs_handle_t *hdl, pool_list_t *pl, boolean_t active_ok)
        pool_entry_t *pe;
        vdev_entry_t *ve;
        config_entry_t *ce;
-       nvlist_t *ret = NULL, *config = NULL, *tmp, *nvtop, *nvroot;
+       nvlist_t *ret = NULL, *config = NULL, *tmp = NULL, *nvtop, *nvroot;
        nvlist_t **spares, **l2cache;
        uint_t i, nspares, nl2cache;
        boolean_t config_seen;
index 259f5fd4961572542014b7e6ebfd933ee74d3167..cc4e6bc5c8b2d4e7dce9e7f0c49a35599ab0d176 100644 (file)
@@ -891,7 +891,7 @@ zprop_print_one_property(const char *name, zprop_get_cbdata_t *cbp,
     const char *source)
 {
        int i;
-       const char *str;
+       const char *str = NULL;
        char buf[128];
 
        /*
index 444ca863d9746031269d2ce3238983c219fb591a..c46a5aeddf365ce08a5695d800e42a0a0569ce2b 100644 (file)
@@ -2604,7 +2604,7 @@ top:
                uint64_t size = BP_GET_LSIZE(bp);
                arc_callback_t  *acb;
                vdev_t *vd = NULL;
-               daddr_t addr;
+               daddr_t addr = -1;
                boolean_t devw = B_FALSE;
 
                if (hdr == NULL) {
index b6205bd500a870bb90c24341f24901a0e8da60e8..1f49284370ace77d519bb45072d50e6156640f37 100644 (file)
@@ -189,7 +189,7 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset,
        uint32_t flags;
        int err;
        zio_t *zio;
-       hrtime_t start;
+       hrtime_t start = 0;
 
        ASSERT(length <= DMU_MAX_ACCESS);