From cabd4a69c4127de2ce491aa84cfe46eec9a4c105 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 12 Mar 2009 10:30:41 -0700 Subject: [PATCH] Resolve remaining uninitialized variables 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 | 2 +- cmd/zfs/zfs_main.c | 3 ++- cmd/zpool/zpool_main.c | 3 ++- cmd/zpool/zpool_vdev.c | 2 +- cmd/ztest/ztest.c | 2 +- lib/libzfs/libzfs_dataset.c | 2 +- lib/libzfs/libzfs_import.c | 2 +- lib/libzfs/libzfs_util.c | 2 +- module/zfs/arc.c | 2 +- module/zfs/dmu.c | 2 +- 10 files changed, 12 insertions(+), 10 deletions(-) diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index 0ced258656..455e78a752 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -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); diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 1f7f47d08a..cf30df7d82 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -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; } } diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 42c6aabb63..aeeff50fda 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -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); diff --git a/cmd/zpool/zpool_vdev.c b/cmd/zpool/zpool_vdev.c index 10007c1492..9fa227c102 100644 --- a/cmd/zpool/zpool_vdev.c +++ b/cmd/zpool/zpool_vdev.c @@ -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)); diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c index 4503a3d028..56873ce3f7 100644 --- a/cmd/ztest/ztest.c +++ b/cmd/ztest/ztest.c @@ -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); diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index 1c36b3b1b9..c28460b0a1 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -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)); diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c index d67776889d..b7e1333382 100644 --- a/lib/libzfs/libzfs_import.c +++ b/lib/libzfs/libzfs_import.c @@ -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; diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c index 259f5fd496..cc4e6bc5c8 100644 --- a/lib/libzfs/libzfs_util.c +++ b/lib/libzfs/libzfs_util.c @@ -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]; /* diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 444ca863d9..c46a5aeddf 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -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) { diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c index b6205bd500..1f49284370 100644 --- a/module/zfs/dmu.c +++ b/module/zfs/dmu.c @@ -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);