Skip to content
Permalink
Browse files

3522 zfs module should not allow uninitialized variables

Reviewed by: Sebastien Roy <seb@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Garrett D'Amore <garrett@damore.org>
  • Loading branch information...
grwilson authored and Christopher Siden committed Feb 11, 2013
1 parent 7535ae1 commit d5285cae913f4e01ffa0e6693a6d8ef1fbea30ba
@@ -2784,7 +2784,7 @@ arc_read(zio_t *pio, spa_t *spa, const blkptr_t *bp, arc_done_func_t *done,
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_load_guid(spa);
@@ -2866,7 +2866,7 @@ arc_read(zio_t *pio, spa_t *spa, const blkptr_t *bp, arc_done_func_t *done,
uint64_t size = BP_GET_LSIZE(bp);
arc_callback_t *acb;
vdev_t *vd = NULL;
uint64_t addr;
uint64_t addr = 0;
boolean_t devw = B_FALSE;

if (hdr == NULL) {
@@ -2981,6 +2981,10 @@ arc_read(zio_t *pio, spa_t *spa, const blkptr_t *bp, arc_done_func_t *done,
cb->l2rcb_zb = *zb;
cb->l2rcb_flags = zio_flags;

ASSERT(addr >= VDEV_LABEL_START_SIZE &&
addr + size < vd->vdev_psize -
VDEV_LABEL_END_SIZE);

/*
* l2arc read. The SCL_L2ARC lock will be
* released by l2arc_read_done().
@@ -3172,8 +3176,8 @@ arc_release(arc_buf_t *buf, void *tag)
if (l2hdr) {
mutex_enter(&l2arc_buflist_mtx);
hdr->b_l2hdr = NULL;
buf_size = hdr->b_size;
}
buf_size = hdr->b_size;

/*
* Do we have more than one buf?
@@ -4172,7 +4176,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);

@@ -405,8 +405,7 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset, uint64_t length,

if (dn->dn_objset->os_dsl_dataset)
dp = dn->dn_objset->os_dsl_dataset->ds_dir->dd_pool;
if (dp && dsl_pool_sync_context(dp))
start = gethrtime();
start = gethrtime();
zio = zio_root(dn->dn_objset->os_spa, NULL, NULL, ZIO_FLAG_CANFAIL);
blkid = dbuf_whichblock(dn, offset);
for (i = 0; i < nblks; i++) {
@@ -1372,7 +1372,8 @@ 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;
uint64_t *group = NULL;
int flags = dn->dn_id_flags;
int error;
boolean_t have_spill = B_FALSE;
@@ -375,7 +375,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;
@@ -460,11 +460,8 @@ dsl_dataset_get_ref(dsl_pool_t *dp, uint64_t dsobj, void *tag,
ds->ds_reserved = ds->ds_quota = 0;
}

if (err == 0) {
winner = dmu_buf_set_user_ie(dbuf, ds, &ds->ds_phys,
dsl_dataset_evict);
}
if (err || winner) {
if (err != 0 || (winner = dmu_buf_set_user_ie(dbuf, ds,
&ds->ds_phys, dsl_dataset_evict)) != NULL) {
bplist_destroy(&ds->ds_pending_deadlist);
dsl_deadlist_close(&ds->ds_deadlist);
if (ds->ds_prev)
@@ -1627,7 +1627,8 @@ dsl_scan_scrub_cb(dsl_pool_t *dp,
zio_priority = ZIO_PRIORITY_SCRUB;
needs_io = B_TRUE;
scan_delay = zfs_scrub_delay;
} else if (scn->scn_phys.scn_func == POOL_SCAN_RESILVER) {
} else {
ASSERT3U(scn->scn_phys.scn_func, ==, POOL_SCAN_RESILVER);
zio_flags |= ZIO_FLAG_RESILVER;
zio_priority = ZIO_PRIORITY_RESILVER;
needs_io = B_FALSE;
@@ -37,6 +37,7 @@
*/

#include <sys/types.h>
#include <sys/param.h>

#define MATCH_BITS 6
#define MATCH_MIN 3
@@ -50,7 +51,8 @@ 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;
uchar_t *copymap = NULL;
int copymask = 1 << (NBBY - 1);
int mlen, offset, hash;
uint16_t *hp;
@@ -99,7 +101,8 @@ 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;
uchar_t copymap = 0;
int copymask = 1 << (NBBY - 1);

while (dst < d_end) {
@@ -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) {
@@ -660,7 +660,8 @@ 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;
int spillhdrsize = 0;
int used;
dmu_object_type_t bonustype;
sa_lot_t *lot;
@@ -834,7 +835,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;
@@ -1639,7 +1640,8 @@ 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;
int spill_data_size = 0;
int spill_attr_count = 0;
int error;
uint16_t length;
@@ -374,7 +374,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;
boolean_t has_feature = B_FALSE;

elem = NULL;
@@ -1342,6 +1342,7 @@ spa_load_l2cache(spa_t *spa)
newvdevs = kmem_alloc(nl2cache * sizeof (void *), KM_SLEEP);
} else {
nl2cache = 0;
newvdevs = NULL;
}

oldvdevs = sav->sav_vdevs;
@@ -4446,7 +4447,7 @@ spa_vdev_detach(spa_t *spa, uint64_t guid, uint64_t pguid, int replace_done)
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;

ASSERT(spa_writeable(spa));
@@ -1190,7 +1190,8 @@ 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;
uint8_t val;
int ll;
uint8_t *invlog[VDEV_RAIDZ_MAXPARITY];
uint8_t *p, *pp;
@@ -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;

@@ -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;
@@ -556,9 +556,9 @@ zfs_fuid_create(zfsvfs_t *zfsvfs, uint64_t id, cred_t *cr,
uint32_t fuid_idx = FUID_INDEX(id);
uint32_t rid;
idmap_stat status;
uint64_t idx;
uint64_t idx = 0;
zfs_fuid_t *zfuid = NULL;
zfs_fuid_info_t *fuidp;
zfs_fuid_info_t *fuidp = NULL;

/*
* If POSIX ID, or entry is already a FUID then
@@ -583,6 +583,9 @@ zfs_fuid_create(zfsvfs_t *zfsvfs, uint64_t id, cred_t *cr,
if (fuidp == NULL)
return (UID_NOBODY);

VERIFY3U(type, >=, ZFS_OWNER);
VERIFY3U(type, <=, ZFS_ACE_GROUP);

switch (type) {
case ZFS_ACE_USER:
case ZFS_ACE_GROUP:
@@ -599,7 +602,7 @@ zfs_fuid_create(zfsvfs_t *zfsvfs, uint64_t id, cred_t *cr,
idx = FUID_INDEX(fuidp->z_fuid_group);
break;
};
domain = fuidp->z_domain_table[idx -1];
domain = fuidp->z_domain_table[idx - 1];
} else {
if (type == ZFS_OWNER || type == ZFS_ACE_USER)
status = kidmap_getsidbyuid(crgetzone(cr), id,
@@ -975,7 +975,7 @@ static int
zfs_secpolicy_snapshot(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
nvlist_t *snaps;
int error;
int error = 0;
nvpair_t *pair;

if (nvlist_lookup_nvlist(innvl, "snaps", &snaps) != 0)
@@ -238,7 +238,7 @@ zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
itx_t *itx;
lr_create_t *lr;
lr_acl_create_t *lracl;
size_t aclsize;
size_t aclsize = (vsecp != NULL) ? vsecp->vsa_aclentsz : 0;
size_t xvatsize = 0;
size_t txsize;
xvattr_t *xvap = (xvattr_t *)vap;
@@ -268,7 +268,6 @@ zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
txsize = sizeof (*lr) + namesize + fuidsz + xvatsize;
lrsize = sizeof (*lr);
} else {
aclsize = (vsecp) ? vsecp->vsa_aclentsz : 0;
txsize =
sizeof (lr_acl_create_t) + namesize + fuidsz +
ZIL_ACE_LENGTH(aclsize) + xvatsize;
@@ -463,7 +463,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;

/*
@@ -407,12 +407,18 @@ zfs_register_callbacks(vfs_t *vfsp)
objset_t *os = NULL;
zfsvfs_t *zfsvfs = NULL;
uint64_t nbmand;
int readonly, do_readonly = B_FALSE;
int setuid, do_setuid = B_FALSE;
int exec, do_exec = B_FALSE;
int devices, do_devices = B_FALSE;
int xattr, do_xattr = B_FALSE;
int atime, do_atime = B_FALSE;
boolean_t readonly = B_FALSE;
boolean_t do_readonly = B_FALSE;
boolean_t setuid = B_FALSE;
boolean_t do_setuid = B_FALSE;
boolean_t exec = B_FALSE;
boolean_t do_exec = B_FALSE;
boolean_t devices = B_FALSE;
boolean_t do_devices = B_FALSE;
boolean_t xattr = B_FALSE;
boolean_t do_xattr = B_FALSE;
boolean_t atime = B_FALSE;
boolean_t do_atime = B_FALSE;
int error = 0;

ASSERT(vfsp);
@@ -447,7 +447,7 @@ zfs_read(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
zfsvfs_t *zfsvfs = zp->z_zfsvfs;
objset_t *os;
ssize_t n, nbytes;
int error;
int error = 0;
rl_t *rl;
xuio_t *xuio = NULL;

@@ -599,9 +599,9 @@ zfs_write(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
ssize_t n, nbytes;
rl_t *rl;
int max_blksz = zfsvfs->z_max_blksz;
int error;
int error = 0;
arc_buf_t *abuf;
iovec_t *aiov;
iovec_t *aiov = NULL;
xuio_t *xuio = NULL;
int i_iov = 0;
int iovcnt = uio->uio_iovcnt;
@@ -2186,6 +2186,7 @@ zfs_readdir(vnode_t *vp, uio_t *uio, cred_t *cr, int *eofp,
odp = (struct dirent64 *)outbuf;
} else {
bufsize = bytes_wanted;
outbuf = NULL;
odp = (struct dirent64 *)iovp->iov_base;
}
eodp = (struct edirent *)odp;
@@ -2627,7 +2628,7 @@ zfs_setattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr,
vattr_t oldva;
xvattr_t tmpxvattr;
uint_t mask = vap->va_mask;
uint_t saved_mask;
uint_t saved_mask = 0;
int trim_mask = 0;
uint64_t new_mode;
uint64_t new_uid, new_gid;
@@ -85,7 +85,6 @@ CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-unused-function
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-uninitialized

#
# Default build targets.
@@ -89,7 +89,6 @@ CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-unused-function
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-uninitialized

#
# Default build targets.

0 comments on commit d5285ca

Please sign in to comment.
You can’t perform that action at this time.