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>
References:
https://www.illumos.org/issues/3522
illumos/illumos-gate@
d5285cae913f4e01ffa0e6693a6d8ef1fbea30ba
Ported-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Porting notes:
1. ZFSOnLinux had already addressed many of these issues because of
its use of -Wall. However, the manner in which they were addressed
differed. The illumos fixes replace the ones previously made in
ZFSOnLinux to reduce code differences.
2. Part of the upstream patch made a small change to arc.c that might
address zfsonlinux/zfs#1334.
3. The initialization of aclsize in zfs_log_create() differs because
vsecp is a NULL pointer on ZFSOnLinux.
4. The changes to zfs_register_callbacks() were dropped because it
has diverged and needs to be resynced.
uint64_t size = BP_GET_LSIZE(bp);
arc_callback_t *acb;
vdev_t *vd = NULL;
- uint64_t addr = -1;
+ uint64_t addr = 0;
boolean_t devw = B_FALSE;
if (hdr == NULL) {
cb->l2rcb_flags = zio_flags;
cb->l2rcb_compress = hdr->b_l2hdr->b_compress;
+ 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().
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?
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++) {
objset_t *os = dn->dn_objset;
void *data = NULL;
dmu_buf_impl_t *db = NULL;
- uint64_t *user = NULL, *group = NULL;
+ uint64_t *user = NULL;
+ uint64_t *group = NULL;
int flags = dn->dn_id_flags;
int error;
boolean_t have_spill = B_FALSE;
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)
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;
{
uchar_t *src = s_start;
uchar_t *dst = d_start;
- uchar_t *cpy, *copymap = NULL;
+ uchar_t *cpy;
+ uchar_t *copymap = NULL;
int copymask = 1 << (NBBY - 1);
int mlen, offset, hash;
uint16_t *hp;
uchar_t *src = s_start;
uchar_t *dst = d_start;
uchar_t *d_end = (uchar_t *)d_start + d_len;
- uchar_t *cpy, copymap = 0;
+ uchar_t *cpy;
+ uchar_t copymap = 0;
int copymask = 1 << (NBBY - 1);
while (dst < d_end) {
int buf_space;
sa_attr_type_t *attrs, *attrs_start;
int i, lot_count;
- int hdrsize, spillhdrsize = 0;
+ int hdrsize;
+ int spillhdrsize = 0;
int used;
dmu_object_type_t bonustype;
sa_lot_t *lot;
uint_t nl2cache;
int i, j, oldnvdevs;
uint64_t guid;
- vdev_t *vd, **oldvdevs, **newvdevs = NULL;
+ vdev_t *vd, **oldvdevs, **newvdevs;
spa_aux_vdev_t *sav = &spa->spa_l2cache;
ASSERT(spa_config_held(spa, SCL_ALL, RW_WRITER) == SCL_ALL);
newvdevs = kmem_alloc(nl2cache * sizeof (void *), KM_PUSHPAGE);
} else {
nl2cache = 0;
+ newvdevs = NULL;
}
oldvdevs = sav->sav_vdevs;
uint64_t ccount;
uint8_t *dst[VDEV_RAIDZ_MAXPARITY];
uint64_t dcount[VDEV_RAIDZ_MAXPARITY];
- uint8_t log = 0, val;
+ uint8_t log = 0;
+ uint8_t val;
int ll;
uint8_t *invlog[VDEV_RAIDZ_MAXPARITY];
uint8_t *p, *pp;
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
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:
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,
itx_t *itx;
lr_create_t *lr;
lr_acl_create_t *lracl;
- xvattr_t *xvap = (xvattr_t *)vap;
size_t aclsize = 0;
size_t xvatsize = 0;
size_t txsize;
+ xvattr_t *xvap = (xvattr_t *)vap;
void *end;
size_t lrsize;
size_t namesize = strlen(name) + 1;
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;
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;