diff options
author | Brian Behlendorf <[email protected]> | 2010-08-26 09:58:04 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2010-08-31 08:38:43 -0700 |
commit | d4ed667343c3dac114642b9f6cb4f7baa3ff7334 (patch) | |
tree | 16b3f627625f83d0214446fb6f867e100f1a34c5 | |
parent | 1fde1e37208c2f56c72c70a06676676f04b65998 (diff) |
Fix gcc uninitialized variable warnings
Gcc -Wall warn: 'uninitialized variable'
Signed-off-by: Brian Behlendorf <[email protected]>
-rw-r--r-- | cmd/zdb/zdb.c | 2 | ||||
-rw-r--r-- | cmd/zfs/zfs_main.c | 5 | ||||
-rw-r--r-- | cmd/zpool/zpool_main.c | 5 | ||||
-rw-r--r-- | cmd/zpool/zpool_vdev.c | 2 | ||||
-rw-r--r-- | lib/libzfs/libzfs_dataset.c | 9 | ||||
-rw-r--r-- | lib/libzfs/libzfs_import.c | 2 | ||||
-rw-r--r-- | lib/libzfs/libzfs_util.c | 2 | ||||
-rw-r--r-- | module/nvpair/nvpair.c | 4 | ||||
-rw-r--r-- | module/zfs/arc.c | 10 | ||||
-rw-r--r-- | module/zfs/dmu.c | 2 | ||||
-rw-r--r-- | module/zfs/dmu_objset.c | 2 | ||||
-rw-r--r-- | module/zfs/dsl_dataset.c | 2 | ||||
-rw-r--r-- | module/zfs/lzjb.c | 4 | ||||
-rw-r--r-- | module/zfs/refcount.c | 2 | ||||
-rw-r--r-- | module/zfs/sa.c | 6 | ||||
-rw-r--r-- | module/zfs/spa.c | 6 | ||||
-rw-r--r-- | module/zfs/spa_misc.c | 2 | ||||
-rw-r--r-- | module/zfs/vdev_file.c | 2 | ||||
-rw-r--r-- | module/zfs/vdev_label.c | 2 | ||||
-rw-r--r-- | module/zfs/vdev_raidz.c | 9 | ||||
-rw-r--r-- | module/zfs/zap_leaf.c | 2 | ||||
-rw-r--r-- | module/zfs/zfs_byteswap.c | 2 | ||||
-rw-r--r-- | module/zfs/zfs_rlock.c | 2 | ||||
-rw-r--r-- | module/zfs/zil.c | 4 |
24 files changed, 49 insertions, 41 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index 1a458f604..459445bb7 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -2888,7 +2888,7 @@ find_zpool(char **target, nvlist_t **configp, int dirc, char **dirv) nvlist_t *match = NULL; char *name = NULL; char *sepp = NULL; - char sep; + char sep = 0; int count = 0; importargs_t args = { 0 }; diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 22426ebfd..9cb69c1bf 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -671,7 +671,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; @@ -4060,7 +4060,7 @@ int main(int argc, char **argv) { int ret; - int i; + int i = 0; char *progname; char *cmdname; @@ -4139,6 +4139,7 @@ main(int argc, char **argv) (void) fprintf(stderr, gettext("unrecognized " "command '%s'\n"), cmdname); usage(B_FALSE); + ret = 1; } libzfs_mnttab_cache(g_zfs, B_FALSE); } diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 85a51de40..fa16836fe 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -3269,7 +3269,7 @@ print_scan_status(pool_scan_stat_t *ps) */ if (ps->pss_state == DSS_FINISHED) { uint64_t minutes_taken = (end - start) / 60; - char *fmt; + char *fmt = NULL; if (ps->pss_func == POOL_SCAN_SCRUB) { fmt = gettext("scrub repaired %s in %lluh%um with " @@ -4392,7 +4392,7 @@ int main(int argc, char **argv) { int ret; - int i; + int i = 0; char *cmdname; (void) setlocale(LC_ALL, ""); @@ -4450,6 +4450,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 53c2e60b7..0c224903d 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/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index 32cdd636a..a0146b4e4 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -1362,7 +1362,7 @@ zfs_prop_set(zfs_handle_t *zhp, const char *propname, const char *propval) zfs_prop_t prop; boolean_t do_prefix; uint64_t idx; - int added_resv; + int added_resv = 0; (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, "cannot set property for '%s'"), @@ -2791,7 +2791,7 @@ zfs_create_ancestors(libzfs_handle_t *hdl, const char *path) { int prefix; char *path_copy; - int rc; + int rc = 0; if (check_parents(hdl, path, NULL, B_TRUE, &prefix) != 0) return (-1); @@ -3348,8 +3348,8 @@ zfs_rollback(zfs_handle_t *zhp, zfs_handle_t *snap, boolean_t force) int err; zfs_cmd_t zc = { "\0", "\0", "\0", "\0", 0 }; boolean_t restore_resv = 0; - uint64_t old_volsize, new_volsize; - zfs_prop_t resv_prop; + uint64_t old_volsize = 0, new_volsize; + zfs_prop_t resv_prop = { 0 }; assert(zhp->zfs_type == ZFS_TYPE_FILESYSTEM || zhp->zfs_type == ZFS_TYPE_VOLUME); @@ -3579,6 +3579,7 @@ zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive) "child dataset with inherited mountpoint is used " "in a non-global zone")); (void) zfs_error(hdl, EZFS_ZONED, errbuf); + ret = -1; goto error; } diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c index 9629ab083..386ab002f 100644 --- a/lib/libzfs/libzfs_import.c +++ b/lib/libzfs/libzfs_import.c @@ -434,7 +434,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 fbed42f06..8277bdb02 100644 --- a/lib/libzfs/libzfs_util.c +++ b/lib/libzfs/libzfs_util.c @@ -956,7 +956,7 @@ zprop_print_one_property(const char *name, zprop_get_cbdata_t *cbp, const char *source, const char *recvd_value) { int i; - const char *str; + const char *str = NULL; char buf[128]; /* diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c index c675684c8..282e0f8a6 100644 --- a/module/nvpair/nvpair.c +++ b/module/nvpair/nvpair.c @@ -1611,10 +1611,10 @@ nvlist_lookup_nvpair_ei_sep(nvlist_t *nvl, const char *name, const char sep, { nvpair_t *nvp; const char *np; - char *sepp; + char *sepp=NULL; char *idxp, *idxep; nvlist_t **nva; - long idx; + long idx = 0; int n; if (ip) diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 96c3fb702..1d7fd9e4c 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -2678,7 +2678,7 @@ arc_read_nolock(zio_t *pio, spa_t *spa, const blkptr_t *bp, uint32_t *arc_flags, const zbookmark_t *zb) { arc_buf_hdr_t *hdr; - arc_buf_t *buf; + arc_buf_t *buf = NULL; kmutex_t *hash_lock; zio_t *rzio; uint64_t guid = spa_guid(spa); @@ -2760,7 +2760,7 @@ top: uint64_t size = BP_GET_LSIZE(bp); arc_callback_t *acb; vdev_t *vd = NULL; - uint64_t addr; + daddr_t addr = -1; boolean_t devw = B_FALSE; if (hdr == NULL) { @@ -3038,7 +3038,7 @@ arc_release(arc_buf_t *buf, void *tag) arc_buf_hdr_t *hdr; kmutex_t *hash_lock = NULL; l2arc_buf_hdr_t *l2hdr; - uint64_t buf_size; + uint64_t buf_size = 0; /* * It would be nice to assert that if it's DMU metadata (level > @@ -4062,7 +4062,7 @@ l2arc_read_done(zio_t *zio) static list_t * l2arc_list_locked(int list_num, kmutex_t **lock) { - list_t *list; + list_t *list = NULL; ASSERT(list_num >= 0 && list_num <= 3); @@ -4235,7 +4235,7 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz) list_t *list; uint64_t passed_sz, write_sz, buf_sz, headroom; void *buf_data; - kmutex_t *hash_lock, *list_lock; + kmutex_t *hash_lock, *list_lock = NULL; boolean_t have_lock, full; l2arc_write_callback_t *cb; zio_t *pio, *wzio; diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c index f2b3f2ba7..732742f33 100644 --- a/module/zfs/dmu.c +++ b/module/zfs/dmu.c @@ -355,7 +355,7 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset, uint64_t length, uint32_t dbuf_flags; int err; zio_t *zio; - hrtime_t start; + hrtime_t start = 0; ASSERT(length <= DMU_MAX_ACCESS); diff --git a/module/zfs/dmu_objset.c b/module/zfs/dmu_objset.c index b3a830217..2d06897db 100644 --- a/module/zfs/dmu_objset.c +++ b/module/zfs/dmu_objset.c @@ -1331,7 +1331,7 @@ dmu_objset_userquota_get_ids(dnode_t *dn, boolean_t before, dmu_tx_t *tx) objset_t *os = dn->dn_objset; void *data = NULL; dmu_buf_impl_t *db = NULL; - uint64_t *user, *group; + uint64_t *user = NULL, *group = NULL; int flags = dn->dn_id_flags; int error; boolean_t have_spill = B_FALSE; diff --git a/module/zfs/dsl_dataset.c b/module/zfs/dsl_dataset.c index 34fd758c4..226e98828 100644 --- a/module/zfs/dsl_dataset.c +++ b/module/zfs/dsl_dataset.c @@ -387,7 +387,7 @@ dsl_dataset_get_ref(dsl_pool_t *dp, uint64_t dsobj, void *tag, ds = dmu_buf_get_user(dbuf); if (ds == NULL) { - dsl_dataset_t *winner; + dsl_dataset_t *winner = NULL; ds = kmem_zalloc(sizeof (dsl_dataset_t), KM_SLEEP); ds->ds_dbuf = dbuf; diff --git a/module/zfs/lzjb.c b/module/zfs/lzjb.c index ab3de51b7..ad9e423f8 100644 --- a/module/zfs/lzjb.c +++ b/module/zfs/lzjb.c @@ -50,7 +50,7 @@ lzjb_compress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n) { uchar_t *src = s_start; uchar_t *dst = d_start; - uchar_t *cpy, *copymap; + uchar_t *cpy, *copymap = NULL; int copymask = 1 << (NBBY - 1); int mlen, offset, hash; uint16_t *hp; @@ -99,7 +99,7 @@ lzjb_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n) uchar_t *src = s_start; uchar_t *dst = d_start; uchar_t *d_end = (uchar_t *)d_start + d_len; - uchar_t *cpy, copymap; + uchar_t *cpy, copymap = 0; int copymask = 1 << (NBBY - 1); while (dst < d_end) { diff --git a/module/zfs/refcount.c b/module/zfs/refcount.c index a659c0742..a61554606 100644 --- a/module/zfs/refcount.c +++ b/module/zfs/refcount.c @@ -110,7 +110,7 @@ refcount_count(refcount_t *rc) int64_t refcount_add_many(refcount_t *rc, uint64_t number, void *holder) { - reference_t *ref; + reference_t *ref = NULL; int64_t count; if (reference_tracking_enable) { diff --git a/module/zfs/sa.c b/module/zfs/sa.c index 4e71c407f..37b815f94 100644 --- a/module/zfs/sa.c +++ b/module/zfs/sa.c @@ -642,7 +642,7 @@ sa_build_layouts(sa_handle_t *hdl, sa_bulk_attr_t *attr_desc, int attr_count, int buf_space; sa_attr_type_t *attrs, *attrs_start; int i, lot_count; - int hdrsize, spillhdrsize; + int hdrsize, spillhdrsize = 0; int used; dmu_object_type_t bonustype; sa_lot_t *lot; @@ -813,7 +813,7 @@ sa_attr_table_setup(objset_t *os, sa_attr_reg_t *reg_attrs, int count) { sa_os_t *sa = os->os_sa; uint64_t sa_attr_count = 0; - uint64_t sa_reg_count; + uint64_t sa_reg_count = 0; int error = 0; uint64_t attr_value; sa_attr_table_t *tb; @@ -1619,7 +1619,7 @@ sa_modify_attrs(sa_handle_t *hdl, sa_attr_type_t newattr, sa_bulk_attr_t *attr_desc; void *old_data[2]; int bonus_attr_count = 0; - int bonus_data_size, spill_data_size; + int bonus_data_size = 0, spill_data_size = 0; int spill_attr_count = 0; int error; uint16_t length; diff --git a/module/zfs/spa.c b/module/zfs/spa.c index 0711102b4..d11f93dbe 100644 --- a/module/zfs/spa.c +++ b/module/zfs/spa.c @@ -334,7 +334,7 @@ spa_prop_validate(spa_t *spa, nvlist_t *props) { nvpair_t *elem; int error = 0, reset_bootfs = 0; - uint64_t objnum; + uint64_t objnum = 0; elem = NULL; while ((elem = nvlist_next_nvpair(props, elem)) != NULL) { @@ -1144,7 +1144,7 @@ spa_load_l2cache(spa_t *spa) uint_t nl2cache; int i, j, oldnvdevs; uint64_t guid; - vdev_t *vd, **oldvdevs, **newvdevs; + vdev_t *vd, **oldvdevs, **newvdevs = NULL; spa_aux_vdev_t *sav = &spa->spa_l2cache; ASSERT(spa_config_held(spa, SCL_ALL, RW_WRITER) == SCL_ALL); @@ -4019,7 +4019,7 @@ spa_vdev_detach(spa_t *spa, uint64_t guid, uint64_t pguid, int replace_done) ASSERTV(vdev_t *rvd = spa->spa_root_vdev;) vdev_t *vd, *pvd, *cvd, *tvd; boolean_t unspare = B_FALSE; - uint64_t unspare_guid; + uint64_t unspare_guid = 0; char *vdpath; int c, t; diff --git a/module/zfs/spa_misc.c b/module/zfs/spa_misc.c index cd8a6c875..32ef51db1 100644 --- a/module/zfs/spa_misc.c +++ b/module/zfs/spa_misc.c @@ -399,7 +399,7 @@ spa_lookup(const char *name) static spa_t search; /* spa_t is large; don't allocate on stack */ spa_t *spa; avl_index_t where; - char c; + char c = 0; char *cp; ASSERT(MUTEX_HELD(&spa_namespace_lock)); diff --git a/module/zfs/vdev_file.c b/module/zfs/vdev_file.c index 8c22aa531..f31389a6d 100644 --- a/module/zfs/vdev_file.c +++ b/module/zfs/vdev_file.c @@ -143,7 +143,7 @@ vdev_file_io_start(zio_t *zio) { vdev_t *vd = zio->io_vd; vdev_file_t *vf = vd->vdev_tsd; - ssize_t resid; + ssize_t resid = 0; if (zio->io_type == ZIO_TYPE_IOCTL) { /* XXPOLICY */ diff --git a/module/zfs/vdev_label.c b/module/zfs/vdev_label.c index 8b400879b..3774d7152 100644 --- a/module/zfs/vdev_label.c +++ b/module/zfs/vdev_label.c @@ -612,7 +612,7 @@ vdev_label_init(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason) char *buf; size_t buflen; int error; - uint64_t spare_guid, l2cache_guid; + uint64_t spare_guid = 0, l2cache_guid = 0; int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL; int c, l; vdev_t *pvd; diff --git a/module/zfs/vdev_raidz.c b/module/zfs/vdev_raidz.c index af2de40ac..ef2054233 100644 --- a/module/zfs/vdev_raidz.c +++ b/module/zfs/vdev_raidz.c @@ -1189,7 +1189,7 @@ vdev_raidz_matrix_reconstruct(raidz_map_t *rm, int n, int nmissing, uint64_t ccount; uint8_t *dst[VDEV_RAIDZ_MAXPARITY]; uint64_t dcount[VDEV_RAIDZ_MAXPARITY]; - uint8_t log, val; + uint8_t log = 0, val; int ll; uint8_t *invlog[VDEV_RAIDZ_MAXPARITY]; uint8_t *p, *pp; @@ -1638,8 +1638,11 @@ raidz_checksum_verify(zio_t *zio) { zio_bad_cksum_t zbc; raidz_map_t *rm = zio->io_vsd; + int ret; - int ret = zio_checksum_error(zio, &zbc); + bzero(&zbc, sizeof (zio_bad_cksum_t)); + + ret = zio_checksum_error(zio, &zbc); if (ret != 0 && zbc.zbc_injected != 0) rm->rm_ecksuminjected = 1; @@ -1862,7 +1865,7 @@ vdev_raidz_io_done(zio_t *zio) vdev_t *vd = zio->io_vd; vdev_t *cvd; raidz_map_t *rm = zio->io_vsd; - raidz_col_t *rc; + raidz_col_t *rc = NULL; int unexpected_errors = 0; int parity_errors = 0; int parity_untried = 0; diff --git a/module/zfs/zap_leaf.c b/module/zfs/zap_leaf.c index 19a795db8..b867ac407 100644 --- a/module/zfs/zap_leaf.c +++ b/module/zfs/zap_leaf.c @@ -220,7 +220,7 @@ zap_leaf_array_create(zap_leaf_t *l, const char *buf, uint16_t chunk_head; uint16_t *chunkp = &chunk_head; int byten = 0; - uint64_t value; + uint64_t value = 0; int shift = (integer_size-1)*8; int len = num_integers; diff --git a/module/zfs/zfs_byteswap.c b/module/zfs/zfs_byteswap.c index acf632bdb..6048eb124 100644 --- a/module/zfs/zfs_byteswap.c +++ b/module/zfs/zfs_byteswap.c @@ -51,7 +51,7 @@ zfs_ace_byteswap(void *buf, size_t size, boolean_t zfs_layout) { caddr_t end; caddr_t ptr; - zfs_ace_t *zacep; + zfs_ace_t *zacep = NULL; ace_t *acep; uint16_t entry_type; size_t entry_size; diff --git a/module/zfs/zfs_rlock.c b/module/zfs/zfs_rlock.c index 7fd8f6020..4e3c176a3 100644 --- a/module/zfs/zfs_rlock.c +++ b/module/zfs/zfs_rlock.c @@ -460,7 +460,7 @@ static void zfs_range_unlock_reader(znode_t *zp, rl_t *remove) { avl_tree_t *tree = &zp->z_range_avl; - rl_t *rl, *next; + rl_t *rl, *next = NULL; uint64_t len; /* diff --git a/module/zfs/zil.c b/module/zfs/zil.c index 751806d33..3c18d43fa 100644 --- a/module/zfs/zil.c +++ b/module/zfs/zil.c @@ -296,6 +296,8 @@ zil_parse(zilog_t *zilog, zil_parse_blk_func_t *parse_blk_func, char *lrbuf, *lrp; int error = 0; + bzero(&next_blk, sizeof(blkptr_t)); + /* * Old logs didn't record the maximum zh_claim_lr_seq. */ @@ -317,7 +319,7 @@ zil_parse(zilog_t *zilog, zil_parse_blk_func_t *parse_blk_func, for (blk = zh->zh_log; !BP_IS_HOLE(&blk); blk = next_blk) { uint64_t blk_seq = blk.blk_cksum.zc_word[ZIL_ZC_SEQ]; int reclen; - char *end; + char *end = NULL; if (blk_seq > claim_blk_seq) break; |