diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index 9666023cc1..259a3e16bc 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -691,14 +691,15 @@ libzfs_mnttab_remove(libzfs_handle_t *hdl, const char *fsname) } int -zfs_spa_version(zfs_handle_t *zhp, int *version) +zfs_spa_version(zfs_handle_t *zhp, int *spa_version) { - zpool_handle_t *handle = zhp->zpool_hdl; + zpool_handle_t *zpool_handle = zhp->zpool_hdl; - if (handle == NULL) + if (zpool_handle == NULL) return (-1); - *version = zpool_get_prop_int(handle, ZPOOL_PROP_VERSION, NULL); + *spa_version = zpool_get_prop_int(zpool_handle, + ZPOOL_PROP_VERSION, NULL); return (0); } @@ -708,12 +709,12 @@ zfs_spa_version(zfs_handle_t *zhp, int *version) static int zfs_which_resv_prop(zfs_handle_t *zhp, zfs_prop_t *resv_prop) { - int version; + int spa_version; - if (zfs_spa_version(zhp, &version) < 0) + if (zfs_spa_version(zhp, &spa_version) < 0) return (-1); - if (version >= SPA_VERSION_REFRESERVATION) + if (spa_version >= SPA_VERSION_REFRESERVATION) *resv_prop = ZFS_PROP_REFRESERVATION; else *resv_prop = ZFS_PROP_RESERVATION; @@ -1746,11 +1747,11 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen, */ { val = getprop_uint64(zhp, prop, &source); - time_t local_time = (time_t)val; + time_t time = (time_t)val; struct tm t; if (literal || - localtime_r(&local_time, &t) == NULL || + localtime_r(&time, &t) == NULL || strftime(propbuf, proplen, "%a %b %e %k:%M %Y", &t) == 0) (void) snprintf(propbuf, proplen, "%llu", (u_longlong_t) val); diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index 055b42a5f5..615c5eb378 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -212,12 +212,12 @@ is_shared(libzfs_handle_t *hdl, const char *mountpoint, zfs_share_proto_t proto) * informative error message. */ static boolean_t -dir_is_empty(const char *dirn) +dir_is_empty(const char *dirname) { DIR *dirp; struct dirent64 *dp; - if ((dirp = opendir(dirn)) == NULL) + if ((dirp = opendir(dirname)) == NULL) return (B_TRUE); while ((dp = readdir64(dirp)) != NULL) { diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c index 2419e6b45d..66d2f8ddd0 100644 --- a/lib/libzfs/libzfs_sendrecv.c +++ b/lib/libzfs/libzfs_sendrecv.c @@ -1896,13 +1896,13 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap, */ avl_tree_t *local_avl; nvlist_t *local_nv, *fs; + char *cp = strchr(zc.zc_value, '@'); /* * XXX Do this faster by just iterating over snaps in * this fs. Also if zc_value does not exist, we will * get a strange "does not exist" error message. */ - cp = strchr(zc.zc_value, '@'); *cp = '\0'; if (gather_nvlist(hdl, zc.zc_value, NULL, NULL, &local_nv, &local_avl) == 0) { diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c index 4ff1a3cc27..bf9f2a1973 100644 --- a/lib/libzfs/libzfs_util.c +++ b/lib/libzfs/libzfs_util.c @@ -527,19 +527,19 @@ void zfs_nicenum(uint64_t num, char *buf, size_t buflen) { uint64_t n = num; - int i = 0, j; + int index = 0; char u; while (n >= 1024) { n /= 1024; - i++; + index++; } - u = " KMGTPE"[i]; + u = " KMGTPE"[index]; - if (i == 0) { + if (index == 0) { (void) snprintf(buf, buflen, "%llu", (u_longlong_t) n); - } else if ((num & ((1ULL << 10 * i) - 1)) == 0) { + } else if ((num & ((1ULL << 10 * index) - 1)) == 0) { /* * If this is an even multiple of the base, always display * without any decimal precision. @@ -555,9 +555,10 @@ zfs_nicenum(uint64_t num, char *buf, size_t buflen) * develop some complex heuristics for this, but it's much * easier just to try each combination in turn. */ - for (j = 2; j >= 0; j--) { - if (snprintf(buf, buflen, "%.*f%c", j, - (double)num / (1ULL << 10 * i), u) <= 5) + int i; + for (i = 2; i >= 0; i--) { + if (snprintf(buf, buflen, "%.*f%c", i, + (double)num / (1ULL << 10 * index), u) <= 5) break; } } @@ -1402,7 +1403,7 @@ zprop_expand_list(libzfs_handle_t *hdl, zprop_list_t **plp, zfs_type_t type) { zprop_list_t *entry; zprop_list_t **last; - expand_data_t ed; + expand_data_t exp; if (*plp == NULL) { /* @@ -1412,11 +1413,11 @@ zprop_expand_list(libzfs_handle_t *hdl, zprop_list_t **plp, zfs_type_t type) */ last = plp; - ed.last = last; - ed.hdl = hdl; - ed.type = type; + exp.last = last; + exp.hdl = hdl; + exp.type = type; - if (zprop_iter_common(zprop_expand_list_cb, &ed, B_FALSE, + if (zprop_iter_common(zprop_expand_list_cb, &exp, B_FALSE, B_FALSE, type) == ZPROP_INVAL) return (-1); diff --git a/lib/libzpool/kernel.c b/lib/libzpool/kernel.c index 5a46f2d3d2..b4b4ce4263 100644 --- a/lib/libzpool/kernel.c +++ b/lib/libzpool/kernel.c @@ -324,7 +324,7 @@ vn_open(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3) int fd; vnode_t *vp; int old_umask; - char real_path[MAXPATHLEN]; + char realpath[MAXPATHLEN]; struct stat64 st; int err; @@ -352,14 +352,14 @@ vn_open(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3) return (errno); } close(fd); - (void) sprintf(real_path, "%s", path); + (void) sprintf(realpath, "%s", path); dsk = strstr(path, "/dsk/"); if (dsk != NULL) - (void) sprintf(real_path + (dsk - path) + 1, "r%s", + (void) sprintf(realpath + (dsk - path) + 1, "r%s", dsk + 1); } else { - (void) sprintf(real_path, "%s", path); - if (!(flags & FCREAT) && stat64(real_path, &st) == -1) + (void) sprintf(realpath, "%s", path); + if (!(flags & FCREAT) && stat64(realpath, &st) == -1) return (errno); } @@ -378,7 +378,7 @@ vn_open(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3) * The construct 'flags - FREAD' conveniently maps combinations of * FREAD and FWRITE to the corresponding O_RDONLY, O_WRONLY, and O_RDWR. */ - fd = open64(real_path, flags - FREAD, mode); + fd = open64(realpath, flags - FREAD, mode); if (flags & FCREAT) (void) umask(old_umask); @@ -418,16 +418,16 @@ int vn_openat(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3, vnode_t *startvp, int fd) { - char *real_path = umem_alloc(strlen(path) + 2, UMEM_NOFAIL); + char *realpath = umem_alloc(strlen(path) + 2, UMEM_NOFAIL); int ret; ASSERT(startvp == rootdir); - (void) sprintf(real_path, "/%s", path); + (void) sprintf(realpath, "/%s", path); /* fd ignored for now, need if want to simulate nbmand support */ - ret = vn_open(real_path, x1, flags, mode, vpp, x2, x3); + ret = vn_open(realpath, x1, flags, mode, vpp, x2, x3); - umem_free(real_path, strlen(path) + 2); + umem_free(realpath, strlen(path) + 2); return (ret); } @@ -785,11 +785,11 @@ random_get_pseudo_bytes(uint8_t *ptr, size_t len) } int -ddi_strtoul(const char *serial, char **nptr, int base, unsigned long *result) +ddi_strtoul(const char *hw_serial, char **nptr, int base, unsigned long *result) { char *end; - *result = strtoul(serial, &end, base); + *result = strtoul(hw_serial, &end, base); if (*result == 0) return (errno); return (0); diff --git a/lib/libzpool/util.c b/lib/libzpool/util.c index 67f62d2e18..360bf7beee 100644 --- a/lib/libzpool/util.c +++ b/lib/libzpool/util.c @@ -41,24 +41,24 @@ void nicenum(uint64_t num, char *buf) { uint64_t n = num; - int i = 0; + int index = 0; char u; while (n >= 1024) { n = (n + (1024 / 2)) / 1024; /* Round up or down */ - i++; + index++; } - u = " KMGTPE"[i]; + u = " KMGTPE"[index]; - if (i == 0) { + if (index == 0) { (void) sprintf(buf, "%llu", (u_longlong_t)n); } else if (n < 10 && (num & (num - 1)) != 0) { (void) sprintf(buf, "%.2f%c", - (double)num / (1ULL << 10 * i), u); + (double)num / (1ULL << 10 * index), u); } else if (n < 100 && (num & (num - 1)) != 0) { (void) sprintf(buf, "%.1f%c", - (double)num / (1ULL << 10 * i), u); + (double)num / (1ULL << 10 * index), u); } else { (void) sprintf(buf, "%llu%c", (u_longlong_t)n, u); } diff --git a/module/zcommon/zfs_prop.c b/module/zcommon/zfs_prop.c index bb73e7ee35..1aec17ae9b 100644 --- a/module/zcommon/zfs_prop.c +++ b/module/zcommon/zfs_prop.c @@ -410,15 +410,15 @@ zfs_prop_userquota(const char *name) * (strings) and internal representation (uint64_t). */ int -zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *idx) +zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index) { - return (zprop_string_to_index(prop, string, idx, ZFS_TYPE_DATASET)); + return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET)); } int -zfs_prop_index_to_string(zfs_prop_t prop, uint64_t idx, const char **string) +zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string) { - return (zprop_index_to_string(prop, idx, string, ZFS_TYPE_DATASET)); + return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET)); } /* diff --git a/module/zcommon/zpool_prop.c b/module/zcommon/zpool_prop.c index a873be5d7f..056f8045b8 100644 --- a/module/zcommon/zpool_prop.c +++ b/module/zcommon/zpool_prop.c @@ -154,16 +154,16 @@ zpool_prop_default_numeric(zpool_prop_t prop) int zpool_prop_string_to_index(zpool_prop_t prop, const char *string, - uint64_t *idx) + uint64_t *index) { - return (zprop_string_to_index(prop, string, idx, ZFS_TYPE_POOL)); + return (zprop_string_to_index(prop, string, index, ZFS_TYPE_POOL)); } int -zpool_prop_index_to_string(zpool_prop_t prop, uint64_t idx, +zpool_prop_index_to_string(zpool_prop_t prop, uint64_t index, const char **string) { - return (zprop_index_to_string(prop, idx, string, ZFS_TYPE_POOL)); + return (zprop_index_to_string(prop, index, string, ZFS_TYPE_POOL)); } #ifndef _KERNEL diff --git a/module/zcommon/zprop_common.c b/module/zcommon/zprop_common.c index 329a278f23..ae7668ca2f 100644 --- a/module/zcommon/zprop_common.c +++ b/module/zcommon/zprop_common.c @@ -256,7 +256,7 @@ zprop_name_to_prop(const char *propname, zfs_type_t type) } int -zprop_string_to_index(int prop, const char *string, uint64_t *idx, +zprop_string_to_index(int prop, const char *string, uint64_t *index, zfs_type_t type) { zprop_desc_t *prop_tbl; @@ -273,7 +273,7 @@ zprop_string_to_index(int prop, const char *string, uint64_t *idx, for (i = 0; idx_tbl[i].pi_name != NULL; i++) { if (strcmp(string, idx_tbl[i].pi_name) == 0) { - *idx = idx_tbl[i].pi_value; + *index = idx_tbl[i].pi_value; return (0); } } @@ -282,7 +282,7 @@ zprop_string_to_index(int prop, const char *string, uint64_t *idx, } int -zprop_index_to_string(int prop, uint64_t idx, const char **string, +zprop_index_to_string(int prop, uint64_t index, const char **string, zfs_type_t type) { zprop_desc_t *prop_tbl; @@ -298,7 +298,7 @@ zprop_index_to_string(int prop, uint64_t idx, const char **string, return (-1); for (i = 0; idx_tbl[i].pi_name != NULL; i++) { - if (idx_tbl[i].pi_value == idx) { + if (idx_tbl[i].pi_value == index) { *string = idx_tbl[i].pi_name; return (0); } diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c index 4e015d3404..f09b904f4b 100644 --- a/module/zfs/dmu.c +++ b/module/zfs/dmu.c @@ -184,7 +184,7 @@ dmu_bonus_hold(objset_t *os, uint64_t object, void *tag, dmu_buf_t **dbp) */ static int dmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset, uint64_t length, - int rd, void *tag, int *numbufsp, dmu_buf_t ***dbpp, uint32_t flags) + int read, void *tag, int *numbufsp, dmu_buf_t ***dbpp, uint32_t flags) { dsl_pool_t *dp = NULL; dmu_buf_t **dbp; @@ -235,7 +235,7 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset, uint64_t length, return (EIO); } /* initiate async i/o */ - if (rd) { + if (read) { (void) dbuf_read(db, zio, dbuf_flags); } dbp[i] = &db->db; @@ -253,7 +253,7 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset, uint64_t length, } /* wait for other io to complete */ - if (rd) { + if (read) { for (i = 0; i < nblks; i++) { dmu_buf_impl_t *db = (dmu_buf_impl_t *)dbp[i]; mutex_enter(&db->db_mtx); @@ -277,7 +277,7 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset, uint64_t length, static int dmu_buf_hold_array(objset_t *os, uint64_t object, uint64_t offset, - uint64_t length, int rd, void *tag, int *numbufsp, dmu_buf_t ***dbpp) + uint64_t length, int read, void *tag, int *numbufsp, dmu_buf_t ***dbpp) { dnode_t *dn; int err; @@ -286,7 +286,7 @@ dmu_buf_hold_array(objset_t *os, uint64_t object, uint64_t offset, if (err) return (err); - err = dmu_buf_hold_array_by_dnode(dn, offset, length, rd, tag, + err = dmu_buf_hold_array_by_dnode(dn, offset, length, read, tag, numbufsp, dbpp, DMU_READ_PREFETCH); dnode_rele(dn, FTAG); @@ -296,12 +296,12 @@ dmu_buf_hold_array(objset_t *os, uint64_t object, uint64_t offset, int dmu_buf_hold_array_by_bonus(dmu_buf_t *db, uint64_t offset, - uint64_t length, int rd, void *tag, int *numbufsp, dmu_buf_t ***dbpp) + uint64_t length, int read, void *tag, int *numbufsp, dmu_buf_t ***dbpp) { dnode_t *dn = ((dmu_buf_impl_t *)db)->db_dnode; int err; - err = dmu_buf_hold_array_by_dnode(dn, offset, length, rd, tag, + err = dmu_buf_hold_array_by_dnode(dn, offset, length, read, tag, numbufsp, dbpp, DMU_READ_PREFETCH); return (err); diff --git a/module/zfs/dmu_objset.c b/module/zfs/dmu_objset.c index 30ef576bd4..5bc115321c 100644 --- a/module/zfs/dmu_objset.c +++ b/module/zfs/dmu_objset.c @@ -1180,11 +1180,11 @@ dmu_objset_fsid_guid(objset_t *os) } void -dmu_objset_fast_stat(objset_t *os, dmu_objset_stats_t *st) +dmu_objset_fast_stat(objset_t *os, dmu_objset_stats_t *stat) { - st->dds_type = os->os->os_phys->os_type; + stat->dds_type = os->os->os_phys->os_type; if (os->os->os_dsl_dataset) - dsl_dataset_fast_stat(os->os->os_dsl_dataset, st); + dsl_dataset_fast_stat(os->os->os_dsl_dataset, stat); } void diff --git a/module/zfs/dmu_send.c b/module/zfs/dmu_send.c index 82b28d4cee..df5a8b36a2 100644 --- a/module/zfs/dmu_send.c +++ b/module/zfs/dmu_send.c @@ -901,28 +901,6 @@ restore_free(struct restorearg *ra, objset_t *os, return (err); } -/* - * Compute checksum of drr_begin record - */ -static void -dmu_recv_stream_cksum(dmu_recv_cookie_t *drc, struct restorearg *ra) -{ - dmu_replay_record_t *drr; - - drr = kmem_zalloc(sizeof (dmu_replay_record_t), KM_SLEEP); - - drr->drr_type = DRR_BEGIN; - drr->drr_u.drr_begin = *drc->drc_drrb; - if (ra->byteswap) { - fletcher_4_incremental_byteswap(drr, - sizeof (dmu_replay_record_t), &(ra->cksum)); - } else { - fletcher_4_incremental_native(drr, - sizeof (dmu_replay_record_t), &(ra->cksum)); - } - kmem_free(drr, sizeof (dmu_replay_record_t)); -} - /* * NB: callers *must* call dmu_recv_end() if this succeeds. */ @@ -937,7 +915,22 @@ dmu_recv_stream(dmu_recv_cookie_t *drc, vnode_t *vp, offset_t *voffp) if (drc->drc_drrb->drr_magic == BSWAP_64(DMU_BACKUP_MAGIC)) ra.byteswap = TRUE; - dmu_recv_stream_cksum(drc, &ra); + { + /* compute checksum of drr_begin record */ + dmu_replay_record_t *drr; + drr = kmem_zalloc(sizeof (dmu_replay_record_t), KM_SLEEP); + + drr->drr_type = DRR_BEGIN; + drr->drr_u.drr_begin = *drc->drc_drrb; + if (ra.byteswap) { + fletcher_4_incremental_byteswap(drr, + sizeof (dmu_replay_record_t), &ra.cksum); + } else { + fletcher_4_incremental_native(drr, + sizeof (dmu_replay_record_t), &ra.cksum); + } + kmem_free(drr, sizeof (dmu_replay_record_t)); + } if (ra.byteswap) { struct drr_begin *drrb = drc->drc_drrb; diff --git a/module/zfs/dmu_zfetch.c b/module/zfs/dmu_zfetch.c index 3e33527c4c..a01d56b098 100644 --- a/module/zfs/dmu_zfetch.c +++ b/module/zfs/dmu_zfetch.c @@ -444,7 +444,7 @@ top: if (zs) { if (reset) { - zstream_t *rm = zs; + zstream_t *remove = zs; rc = 0; mutex_exit(&zs->zst_lock); @@ -456,7 +456,7 @@ top: */ for (zs = list_head(&zf->zf_stream); zs; zs = list_next(&zf->zf_stream, zs)) { - if (zs == rm) { + if (zs == remove) { dmu_zfetch_stream_remove(zf, zs); mutex_destroy(&zs->zst_lock); kmem_free(zs, sizeof (zstream_t)); diff --git a/module/zfs/dnode.c b/module/zfs/dnode.c index c07b2528ea..35b6ee8b7a 100644 --- a/module/zfs/dnode.c +++ b/module/zfs/dnode.c @@ -659,10 +659,10 @@ dnode_hold_impl(objset_impl_t *os, uint64_t object, int flag, } if ((dn = children_dnodes[idx]) == NULL) { - dnode_phys_t *dnpp = (dnode_phys_t *)db->db.db_data+idx; + dnode_phys_t *dnp = (dnode_phys_t *)db->db.db_data+idx; dnode_t *winner; - dn = dnode_create(os, dnpp, db, object); + dn = dnode_create(os, dnp, db, object); winner = atomic_cas_ptr(&children_dnodes[idx], NULL, dn); if (winner != NULL) { dnode_destroy(dn); diff --git a/module/zfs/txg.c b/module/zfs/txg.c index acca41075e..76f8f47cb7 100644 --- a/module/zfs/txg.c +++ b/module/zfs/txg.c @@ -154,12 +154,12 @@ txg_thread_exit(tx_state_t *tx, callb_cpr_t *cpr, kthread_t **tpp) } static void -txg_thread_wait(tx_state_t *tx, callb_cpr_t *cpr, kcondvar_t *cv, uint64_t wt) +txg_thread_wait(tx_state_t *tx, callb_cpr_t *cpr, kcondvar_t *cv, uint64_t time) { CALLB_CPR_SAFE_BEGIN(cpr); - if (wt) - (void) cv_timedwait(cv, &tx->tx_sync_lock, lbolt + wt); + if (time) + (void) cv_timedwait(cv, &tx->tx_sync_lock, lbolt + time); else cv_wait(cv, &tx->tx_sync_lock); diff --git a/module/zfs/vdev_raidz.c b/module/zfs/vdev_raidz.c index 483009d7d0..6d9c6f995d 100644 --- a/module/zfs/vdev_raidz.c +++ b/module/zfs/vdev_raidz.c @@ -1506,7 +1506,7 @@ vdev_raidz_combrec(zio_t *zio, int total_errors, int data_errors) void *orig[VDEV_RAIDZ_MAXPARITY]; int tstore[VDEV_RAIDZ_MAXPARITY + 2]; int *tgts = &tstore[1]; - int curr, next, i, c, n; + int current, next, i, c, n; int code, ret = 0; ASSERT(total_errors < rm->rm_firstdatacol); @@ -1554,12 +1554,12 @@ vdev_raidz_combrec(zio_t *zio, int total_errors, int data_errors) orig[n - 1] = zio_buf_alloc(rm->rm_col[0].rc_size); - curr = 0; - next = tgts[curr]; + current = 0; + next = tgts[current]; - while (curr != n) { - tgts[curr] = next; - curr = 0; + while (current != n) { + tgts[current] = next; + current = 0; /* * Save off the original data that we're going to @@ -1606,34 +1606,34 @@ vdev_raidz_combrec(zio_t *zio, int total_errors, int data_errors) do { /* - * Find the next valid column after the curr + * Find the next valid column after the current * position.. */ - for (next = tgts[curr] + 1; + for (next = tgts[current] + 1; next < rm->rm_cols && rm->rm_col[next].rc_error != 0; next++) continue; - ASSERT(next <= tgts[curr + 1]); + ASSERT(next <= tgts[current + 1]); /* * If that spot is available, we're done here. */ - if (next != tgts[curr + 1]) + if (next != tgts[current + 1]) break; /* * Otherwise, find the next valid column after * the previous position. */ - for (c = tgts[curr - 1] + 1; + for (c = tgts[current - 1] + 1; rm->rm_col[c].rc_error != 0; c++) continue; - tgts[curr] = c; - curr++; + tgts[current] = c; + current++; - } while (curr != n); + } while (current != n); } } n--;