Skip to content

Commit

Permalink
Fix gcc uninitialized variable warnings
Browse files Browse the repository at this point in the history
Gcc -Wall warn: 'uninitialized variable'

Signed-off-by: Brian Behlendorf <[email protected]>
  • Loading branch information
behlendorf committed Aug 31, 2010
1 parent 1fde1e3 commit d4ed667
Show file tree
Hide file tree
Showing 24 changed files with 49 additions and 41 deletions.
2 changes: 1 addition & 1 deletion cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

Expand Down
5 changes: 3 additions & 2 deletions cmd/zfs/zfs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -4060,7 +4060,7 @@ int
main(int argc, char **argv)
{
int ret;
int i;
int i = 0;
char *progname;
char *cmdname;

Expand Down Expand Up @@ -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);
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/zpool/zpool_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down Expand Up @@ -4392,7 +4392,7 @@ int
main(int argc, char **argv)
{
int ret;
int i;
int i = 0;
char *cmdname;

(void) setlocale(LC_ALL, "");
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion cmd/zpool/zpool_vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
9 changes: 5 additions & 4 deletions lib/libzfs/libzfs_dataset.c
Original file line number Diff line number Diff line change
Expand Up @@ -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'"),
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/libzfs/libzfs_import.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/libzfs/libzfs_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];

/*
Expand Down
4 changes: 2 additions & 2 deletions module/nvpair/nvpair.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions module/zfs/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -2760,7 +2760,7 @@ arc_read_nolock(zio_t *pio, spa_t *spa, const blkptr_t *bp,
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) {
Expand Down Expand Up @@ -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 >
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/dmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion module/zfs/dmu_objset.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/dsl_dataset.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions module/zfs/lzjb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/refcount.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions module/zfs/sa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions module/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion module/zfs/spa_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/vdev_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/vdev_label.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions module/zfs/vdev_raidz.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/zap_leaf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion module/zfs/zfs_byteswap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/zfs_rlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/*
Expand Down
4 changes: 3 additions & 1 deletion module/zfs/zil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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;
Expand Down

0 comments on commit d4ed667

Please sign in to comment.