diff options
111 files changed, 724 insertions, 538 deletions
@@ -1,6 +1,8 @@ From: Brian Behlendorf <[email protected]> -Subject: [PATCH] gcc no parenthesis +Subject: [PATCH] gcc error c90 -Gcc -Wall warn: 'missing parenthesis' +Gcc non-c90 compliant code Signed-off-by: Brian Behlendorf <[email protected]> + +--- diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index a310fc38b..332c6fce8 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -72,7 +72,7 @@ int zdb_sig_cksumalg = ZIO_CHECKSUM_SHA256; * debugging facilities. */ const char * -_umem_debug_init() +_umem_debug_init(void) { return ("default,verbose"); /* $UMEM_DEBUG setting */ } @@ -565,6 +565,7 @@ dump_dtl(vdev_t *vd, int indent) boolean_t required; char *name[DTL_TYPES] = { "missing", "partial", "scrub", "outage" }; char prefix[256]; + int c, t; spa_vdev_state_enter(spa); required = vdev_dtl_required(vd); @@ -578,7 +579,7 @@ dump_dtl(vdev_t *vd, int indent) vd->vdev_parent ? vd->vdev_ops->vdev_op_type : spa_name(spa), required ? "DTL-required" : "DTL-expendable"); - for (int t = 0; t < DTL_TYPES; t++) { + for (t = 0; t < DTL_TYPES; t++) { space_map_t *sm = &vd->vdev_dtl[t]; if (sm->sm_space == 0) continue; @@ -592,7 +593,7 @@ dump_dtl(vdev_t *vd, int indent) &vd->vdev_dtl_smo, sm); } - for (int c = 0; c < vd->vdev_children; c++) + for (c = 0; c < vd->vdev_children; c++) dump_dtl(vd->vdev_child[c], indent + 4); } @@ -673,7 +674,7 @@ static int visit_indirect(spa_t *spa, const dnode_phys_t *dnp, blkptr_t *bp, const zbookmark_t *zb) { - int err; + int err = 0; if (bp->blk_birth == 0) return (0); @@ -843,7 +844,7 @@ dump_dsl_dataset(objset_t *os, uint64_t object, void *data, size_t size) static void dump_bplist(objset_t *mos, uint64_t object, char *name) { - bplist_t bpl = { 0 }; + bplist_t bpl; blkptr_t blk, *bp = &blk; uint64_t itor = 0; char bytes[6]; @@ -853,6 +854,7 @@ dump_bplist(objset_t *mos, uint64_t object, char *name) if (dump_opt['d'] < 3) return; + bzero(&bpl, sizeof(bplist_t)); mutex_init(&bpl.bpl_lock, NULL, MUTEX_DEFAULT, NULL); VERIFY(0 == bplist_open(&bpl, mos, object)); if (bplist_empty(&bpl)) { @@ -899,7 +901,7 @@ static avl_tree_t domain_tree; static boolean_t fuid_table_loaded; static void -fuid_table_destroy() +fuid_table_destroy(void) { if (fuid_table_loaded) { zfs_fuid_table_destroy(&idx_tree, &domain_tree); @@ -1447,10 +1449,11 @@ static void zdb_leak_init(spa_t *spa) { vdev_t *rvd = spa->spa_root_vdev; + int c, m; - for (int c = 0; c < rvd->vdev_children; c++) { + for (c = 0; c < rvd->vdev_children; c++) { vdev_t *vd = rvd->vdev_child[c]; - for (int m = 0; m < vd->vdev_ms_count; m++) { + for (m = 0; m < vd->vdev_ms_count; m++) { metaslab_t *msp = vd->vdev_ms[m]; mutex_enter(&msp->ms_lock); VERIFY(space_map_load(&msp->ms_map, &zdb_space_map_ops, @@ -1465,10 +1468,11 @@ static void zdb_leak_fini(spa_t *spa) { vdev_t *rvd = spa->spa_root_vdev; + int c, m; - for (int c = 0; c < rvd->vdev_children; c++) { + for (c = 0; c < rvd->vdev_children; c++) { vdev_t *vd = rvd->vdev_child[c]; - for (int m = 0; m < vd->vdev_ms_count; m++) { + for (m = 0; m < vd->vdev_ms_count; m++) { metaslab_t *msp = vd->vdev_ms[m]; mutex_enter(&msp->ms_lock); space_map_unload(&msp->ms_map); @@ -1503,7 +1507,9 @@ typedef struct zdb_cb { static void zdb_count_block(spa_t *spa, zdb_cb_t *zcb, blkptr_t *bp, dmu_object_type_t type) { - for (int i = 0; i < 4; i++) { + int i; + + for (i = 0; i < 4; i++) { int l = (i < 2) ? BP_GET_LEVEL(bp) : ZB_TOTAL; int t = (i & 1) ? type : DMU_OT_TOTAL; zdb_blkstats_t *zb = &zcb->zcb_type[l][t]; @@ -1620,13 +1626,15 @@ zdb_blkptr_cb(spa_t *spa, blkptr_t *bp, const zbookmark_t *zb, static int dump_block_stats(spa_t *spa) { - zdb_cb_t zcb = { 0 }; + zdb_cb_t zcb; zdb_blkstats_t *zb, *tzb; uint64_t alloc, space, logalloc; vdev_t *rvd = spa->spa_root_vdev; int leaks = 0; int c, e; + bzero(&zcb, sizeof(zdb_cb_t)); + if (!dump_opt['S']) { (void) printf("\nTraversing all blocks %s%s%s%s%s...\n", (dump_opt['c'] || !dump_opt['L']) ? "to verify " : "", @@ -1936,7 +1944,7 @@ zdb_dump_block_raw(void *buf, uint64_t size, int flags) { if (flags & ZDB_FLAG_BSWAP) byteswap_uint64_array(buf, size); - (void) write(2, buf, size); + VERIFY(write(fileno(stderr), buf, size) == size); } static void diff --git a/cmd/zdb/zdb_il.c b/cmd/zdb/zdb_il.c index cc08ef514..61914a67b 100644 --- a/cmd/zdb/zdb_il.c +++ b/cmd/zdb/zdb_il.c @@ -223,7 +223,7 @@ zil_prt_rec_acl(zilog_t *zilog, int txtype, lr_acl_t *lr) (u_longlong_t)lr->lr_foid, (u_longlong_t)lr->lr_aclcnt); } -typedef void (*zil_prt_rec_func_t)(); +typedef void (*zil_prt_rec_func_t)(zilog_t *, int, void *); typedef struct zil_rec_info { zil_prt_rec_func_t zri_print; char *zri_name; @@ -231,26 +231,26 @@ typedef struct zil_rec_info { } zil_rec_info_t; static zil_rec_info_t zil_rec_info[TX_MAX_TYPE] = { - { NULL, "Total " }, - { zil_prt_rec_create, "TX_CREATE " }, - { zil_prt_rec_create, "TX_MKDIR " }, - { zil_prt_rec_create, "TX_MKXATTR " }, - { zil_prt_rec_create, "TX_SYMLINK " }, - { zil_prt_rec_remove, "TX_REMOVE " }, - { zil_prt_rec_remove, "TX_RMDIR " }, - { zil_prt_rec_link, "TX_LINK " }, - { zil_prt_rec_rename, "TX_RENAME " }, - { zil_prt_rec_write, "TX_WRITE " }, - { zil_prt_rec_truncate, "TX_TRUNCATE " }, - { zil_prt_rec_setattr, "TX_SETATTR " }, - { zil_prt_rec_acl, "TX_ACL_V0 " }, - { zil_prt_rec_acl, "TX_ACL_ACL " }, - { zil_prt_rec_create, "TX_CREATE_ACL " }, - { zil_prt_rec_create, "TX_CREATE_ATTR " }, - { zil_prt_rec_create, "TX_CREATE_ACL_ATTR " }, - { zil_prt_rec_create, "TX_MKDIR_ACL " }, - { zil_prt_rec_create, "TX_MKDIR_ATTR " }, - { zil_prt_rec_create, "TX_MKDIR_ACL_ATTR " }, + { NULL, "Total " }, + { (zil_prt_rec_func_t)zil_prt_rec_create, "TX_CREATE " }, + { (zil_prt_rec_func_t)zil_prt_rec_create, "TX_MKDIR " }, + { (zil_prt_rec_func_t)zil_prt_rec_create, "TX_MKXATTR " }, + { (zil_prt_rec_func_t)zil_prt_rec_create, "TX_SYMLINK " }, + { (zil_prt_rec_func_t)zil_prt_rec_remove, "TX_REMOVE " }, + { (zil_prt_rec_func_t)zil_prt_rec_remove, "TX_RMDIR " }, + { (zil_prt_rec_func_t)zil_prt_rec_link, "TX_LINK " }, + { (zil_prt_rec_func_t)zil_prt_rec_rename, "TX_RENAME " }, + { (zil_prt_rec_func_t)zil_prt_rec_write, "TX_WRITE " }, + { (zil_prt_rec_func_t)zil_prt_rec_truncate, "TX_TRUNCATE " }, + { (zil_prt_rec_func_t)zil_prt_rec_setattr, "TX_SETATTR " }, + { (zil_prt_rec_func_t)zil_prt_rec_acl, "TX_ACL_V0 " }, + { (zil_prt_rec_func_t)zil_prt_rec_acl, "TX_ACL_ACL " }, + { (zil_prt_rec_func_t)zil_prt_rec_create, "TX_CREATE_ACL " }, + { (zil_prt_rec_func_t)zil_prt_rec_create, "TX_CREATE_ATTR " }, + { (zil_prt_rec_func_t)zil_prt_rec_create, "TX_CREATE_ACL_ATTR " }, + { (zil_prt_rec_func_t)zil_prt_rec_create, "TX_MKDIR_ACL " }, + { (zil_prt_rec_func_t)zil_prt_rec_create, "TX_MKDIR_ATTR " }, + { (zil_prt_rec_func_t)zil_prt_rec_create, "TX_MKDIR_ACL_ATTR " }, }; /* ARGSUSED */ diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 25949e171..a68f5ddae 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -582,7 +582,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; @@ -1497,7 +1497,6 @@ upgrade_set_callback(zfs_handle_t *zhp, void *data) {0, 0} }; - for (i = 0; table[i].zplver; i++) { if (cb->cb_version >= table[i].zplver) { int spa_version; @@ -1521,7 +1520,7 @@ upgrade_set_callback(zfs_handle_t *zhp, void *data) if (version < cb->cb_version) { char verstr[16]; (void) snprintf(verstr, sizeof (verstr), - "%llu", cb->cb_version); + "%llu", (u_longlong_t)cb->cb_version); if (cb->cb_lastfs[0] && !same_pool(zhp, cb->cb_lastfs)) { /* * If they did "zfs upgrade -a", then we could @@ -1559,7 +1558,7 @@ zfs_do_upgrade(int argc, char **argv) boolean_t showversions = B_FALSE; int ret; upgrade_cbdata_t cb = { 0 }; - char c; + signed char c; int flags = ZFS_ITER_ARGS_CAN_BE_PATHS; /* check options */ @@ -1629,11 +1628,11 @@ zfs_do_upgrade(int argc, char **argv) ret = zfs_for_each(argc, argv, flags, ZFS_TYPE_FILESYSTEM, NULL, NULL, 0, upgrade_set_callback, &cb); (void) printf(gettext("%llu filesystems upgraded\n"), - cb.cb_numupgraded); + (u_longlong_t)cb.cb_numupgraded); if (cb.cb_numsamegraded) { (void) printf(gettext("%llu filesystems already at " "this version\n"), - cb.cb_numsamegraded); + (u_longlong_t)cb.cb_numsamegraded); } if (cb.cb_numfailed != 0) ret = 1; @@ -1797,9 +1796,9 @@ print_header(zprop_list_t *pl) if (pl->pl_next == NULL && !right_justify) (void) printf("%s", header); else if (right_justify) - (void) printf("%*s", pl->pl_width, header); + (void) printf("%*s", (int)pl->pl_width, header); else - (void) printf("%-*s", pl->pl_width, header); + (void) printf("%-*s", (int)pl->pl_width, header); } (void) printf("\n"); @@ -2390,7 +2389,7 @@ zfs_do_set(int argc, char **argv) usage(B_FALSE); } - ret = zfs_for_each(argc - 2, argv + 2, NULL, + ret = zfs_for_each(argc - 2, argv + 2, 0, ZFS_TYPE_DATASET, NULL, NULL, 0, set_callback, &cb); return (ret); @@ -2407,7 +2406,7 @@ zfs_do_snapshot(int argc, char **argv) { boolean_t recursive = B_FALSE; int ret; - char c; + signed char c; nvlist_t *props; if (nvlist_alloc(&props, NV_UNIQUE_NAME, 0) != 0) { @@ -3055,7 +3054,7 @@ append_options(char *mntopts, char *newopts) /* original length plus new string to append plus 1 for the comma */ if (len + 1 + strlen(newopts) >= MNT_LINE_MAX) { (void) fprintf(stderr, gettext("the opts argument for " - "'%c' option is too long (more than %d chars)\n"), + "'%s' option is too long (more than %d chars)\n"), "-o", MNT_LINE_MAX); usage(B_FALSE); } @@ -3990,6 +3989,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/zfs/zfs_util.h b/cmd/zfs/zfs_util.h index c7f2f1618..b9632b2ba 100644 --- a/cmd/zfs/zfs_util.h +++ b/cmd/zfs/zfs_util.h @@ -26,7 +26,7 @@ #ifndef _ZFS_UTIL_H #define _ZFS_UTIL_H -#pragma ident "%Z%%M% %I% %E% SMI" + #include <libzfs.h> diff --git a/cmd/zinject/translate.c b/cmd/zinject/translate.c index c85e024b6..d8654594d 100644 --- a/cmd/zinject/translate.c +++ b/cmd/zinject/translate.c @@ -221,6 +221,8 @@ calculate_range(const char *dataset, err_type_t type, int level, char *range, } switch (type) { + default: + break; case TYPE_DATA: break; @@ -335,6 +337,8 @@ translate_record(err_type_t type, const char *object, const char *range, * MOS objects are treated specially. */ switch (type) { + default: + break; case TYPE_MOS: record->zi_type = 0; break; @@ -461,6 +465,8 @@ translate_device(const char *pool, const char *device, err_type_t label_type, } switch (label_type) { + default: + break; case TYPE_LABEL_UBERBLOCK: record->zi_start = offsetof(vdev_label_t, vl_uberblock[0]); record->zi_end = record->zi_start + VDEV_UBERBLOCK_RING - 1; diff --git a/cmd/zinject/zinject.h b/cmd/zinject/zinject.h index adc3efe80..fc366b6be 100644 --- a/cmd/zinject/zinject.h +++ b/cmd/zinject/zinject.h @@ -26,7 +26,7 @@ #ifndef _ZINJECT_H #define _ZINJECT_H -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/zfs_ioctl.h> diff --git a/cmd/zpool/zpool_iter.c b/cmd/zpool/zpool_iter.c index 37cc46801..952d19172 100644 --- a/cmd/zpool/zpool_iter.c +++ b/cmd/zpool/zpool_iter.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include <libintl.h> #include <libuutil.h> diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index c8a33df4d..21297e9fd 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -1581,7 +1581,7 @@ zpool_do_import(int argc, char **argv) char **searchdirs = NULL; int nsearch = 0; int c; - int err; + int err = 1; nvlist_t *pools = NULL; boolean_t do_all = B_FALSE; boolean_t do_destroyed = B_FALSE; @@ -2278,9 +2278,9 @@ print_header(zprop_list_t *pl) if (pl->pl_next == NULL && !right_justify) (void) printf("%s", header); else if (right_justify) - (void) printf("%*s", pl->pl_width, header); + (void) printf("%*s", (int)pl->pl_width, header); else - (void) printf("%-*s", pl->pl_width, header); + (void) printf("%-*s", (int)pl->pl_width, header); } (void) printf("\n"); @@ -3413,7 +3413,7 @@ upgrade_one(zpool_handle_t *zhp, void *data) if (cur_version > cbp->cb_version) { (void) printf(gettext("Pool '%s' is already formatted " "using more current version '%llu'.\n"), - zpool_get_name(zhp), cur_version); + zpool_get_name(zhp), (u_longlong_t) cur_version); return (0); } if (cur_version == cbp->cb_version) { @@ -3682,8 +3682,8 @@ get_history_one(zpool_handle_t *zhp, void *data) continue; (void) snprintf(internalstr, sizeof (internalstr), - "[internal %s txg:%lld] %s", - hist_event_table[ievent], txg, + "[internal %s txg:%llu] %s", + hist_event_table[ievent], (u_longlong_t)txg, pathstr); cmdstr = internalstr; } @@ -3984,6 +3984,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_util.c b/cmd/zpool/zpool_util.c index f44da4ff6..7e8ab1dbb 100644 --- a/cmd/zpool/zpool_util.c +++ b/cmd/zpool/zpool_util.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include <errno.h> #include <libgen.h> diff --git a/cmd/zpool/zpool_vdev.c b/cmd/zpool/zpool_vdev.c index 10007c149..9fa227c10 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/cmd/ztest/ztest.c b/cmd/ztest/ztest.c index 746db0c07..b4c288df1 100644 --- a/cmd/ztest/ztest.c +++ b/cmd/ztest/ztest.c @@ -268,7 +268,7 @@ static void usage(boolean_t) __NORETURN; * debugging facilities. */ const char * -_umem_debug_init() +_umem_debug_init(void) { return ("default,verbose"); /* $UMEM_DEBUG setting */ } @@ -764,19 +764,19 @@ ztest_replay_remove(objset_t *os, lr_remove_t *lr, boolean_t byteswap) } zil_replay_func_t *ztest_replay_vector[TX_MAX_TYPE] = { - NULL, /* 0 no such transaction type */ - ztest_replay_create, /* TX_CREATE */ - NULL, /* TX_MKDIR */ - NULL, /* TX_MKXATTR */ - NULL, /* TX_SYMLINK */ - ztest_replay_remove, /* TX_REMOVE */ - NULL, /* TX_RMDIR */ - NULL, /* TX_LINK */ - NULL, /* TX_RENAME */ - NULL, /* TX_WRITE */ - NULL, /* TX_TRUNCATE */ - NULL, /* TX_SETATTR */ - NULL, /* TX_ACL */ + NULL, /* 0 no such transaction type */ + (zil_replay_func_t *)ztest_replay_create,/* TX_CREATE */ + NULL, /* TX_MKDIR */ + NULL, /* TX_MKXATTR */ + NULL, /* TX_SYMLINK */ + (zil_replay_func_t *)ztest_replay_remove,/* TX_REMOVE */ + NULL, /* TX_RMDIR */ + NULL, /* TX_LINK */ + NULL, /* TX_RENAME */ + NULL, /* TX_WRITE */ + NULL, /* TX_TRUNCATE */ + NULL, /* TX_SETATTR */ + NULL, /* TX_ACL */ }; /* @@ -835,11 +835,12 @@ static vdev_t * vdev_lookup_by_path(vdev_t *vd, const char *path) { vdev_t *mvd; + int c; if (vd->vdev_path != NULL && strcmp(path, vd->vdev_path) == 0) return (vd); - for (int c = 0; c < vd->vdev_children; c++) + for (c = 0; c < vd->vdev_children; c++) if ((mvd = vdev_lookup_by_path(vd->vdev_child[c], path)) != NULL) return (mvd); @@ -1149,7 +1150,7 @@ ztest_vdev_attach_detach(ztest_args_t *za) vdev_t * grow_vdev(vdev_t *vd, void *arg) { - spa_t *spa = vd->vdev_spa; + ASSERTV(spa_t *spa = vd->vdev_spa); size_t *newsize = arg; size_t fsize; int fd; @@ -1217,6 +1218,8 @@ online_vdev(vdev_t *vd, void *arg) vdev_t * vdev_walk_tree(vdev_t *vd, vdev_t *(*func)(vdev_t *, void *), void *arg) { + uint_t c; + if (vd->vdev_ops->vdev_op_leaf) { if (func == NULL) return (vd); @@ -1224,7 +1227,7 @@ vdev_walk_tree(vdev_t *vd, vdev_t *(*func)(vdev_t *, void *), void *arg) return (func(vd, arg)); } - for (uint_t c = 0; c < vd->vdev_children; c++) { + for (c = 0; c < vd->vdev_children; c++) { vdev_t *cvd = vd->vdev_child[c]; if ((cvd = vdev_walk_tree(cvd, func, arg)) != NULL) return (cvd); @@ -1504,7 +1507,7 @@ ztest_dmu_objset_create_destroy(ztest_args_t *za) objects = ztest_random(20); seq = 0; while (objects-- != 0) { - uint64_t object; + uint64_t object = 0; dmu_tx_t *tx = dmu_tx_create(os); dmu_tx_hold_write(tx, DMU_NEW_OBJECT, 0, sizeof (name)); error = dmu_tx_assign(tx, TXG_WAIT); @@ -1608,11 +1611,16 @@ ztest_dsl_dataset_cleanup(char *osname, uint64_t curval) char snap3name[100]; int error; - (void) snprintf(snap1name, 100, "%s@s1_%llu", osname, curval); - (void) snprintf(clone1name, 100, "%s/c1_%llu", osname, curval); - (void) snprintf(snap2name, 100, "%s@s2_%llu", clone1name, curval); - (void) snprintf(clone2name, 100, "%s/c2_%llu", osname, curval); - (void) snprintf(snap3name, 100, "%s@s3_%llu", clone1name, curval); + (void) snprintf(snap1name, 100, "%s@s1_%llu", + osname, (u_longlong_t)curval); + (void) snprintf(clone1name, 100, "%s/c1_%llu", + osname, (u_longlong_t)curval); + (void) snprintf(snap2name, 100, "%s@s2_%llu", + clone1name, (u_longlong_t)curval); + (void) snprintf(clone2name, 100, "%s/c2_%llu", + osname, (u_longlong_t)curval); + (void) snprintf(snap3name, 100, "%s@s3_%llu", + clone1name, (u_longlong_t)curval); error = dmu_objset_destroy(clone2name); if (error && error != ENOENT) @@ -1654,11 +1662,16 @@ ztest_dsl_dataset_promote_busy(ztest_args_t *za) dmu_objset_name(os, osname); ztest_dsl_dataset_cleanup(osname, curval); - (void) snprintf(snap1name, 100, "%s@s1_%llu", osname, curval); - (void) snprintf(clone1name, 100, "%s/c1_%llu", osname, curval); - (void) snprintf(snap2name, 100, "%s@s2_%llu", clone1name, curval); - (void) snprintf(clone2name, 100, "%s/c2_%llu", osname, curval); - (void) snprintf(snap3name, 100, "%s@s3_%llu", clone1name, curval); + (void) snprintf(snap1name, 100, "%s@s1_%llu", + osname, (u_longlong_t)curval); + (void) snprintf(clone1name, 100, "%s/c1_%llu", + osname, (u_longlong_t)curval); + (void) snprintf(snap2name, 100, "%s@s2_%llu", + clone1name, (u_longlong_t)curval); + (void) snprintf(clone2name, 100, "%s/c2_%llu", + osname, (u_longlong_t)curval); + (void) snprintf(snap3name, 100, "%s@s3_%llu", + clone1name, (u_longlong_t)curval); error = dmu_objset_snapshot(osname, strchr(snap1name, '@')+1, NULL, FALSE); @@ -2545,13 +2558,14 @@ ztest_dmu_write_parallel(ztest_args_t *za) mutex_t *lp; char osname[MAXNAMELEN]; char iobuf[SPA_MAXBLOCKSIZE]; - blkptr_t blk = { 0 }; + blkptr_t blk; uint64_t blkoff; zbookmark_t zb; dmu_tx_t *tx = dmu_tx_create(os); dmu_buf_t *bonus_db; arc_buf_t *abuf = NULL; + bzero(&blk, sizeof(blkptr_t)); dmu_objset_name(os, osname); /* @@ -3129,7 +3143,7 @@ ztest_fault_inject(ztest_args_t *za) int fd; uint64_t offset; uint64_t leaves = MAX(zopt_mirrors, 1) * zopt_raidz; - uint64_t bad = 0x1990c0ffeedecade; + uint64_t bad = 0x1990c0ffeedecadeull; uint64_t top, leaf; char path0[MAXPATHLEN]; char pathrand[MAXPATHLEN]; diff --git a/lib/libnvpair/include/libnvpair.h b/lib/libnvpair/include/libnvpair.h index e655e0d40..10306e34f 100644 --- a/lib/libnvpair/include/libnvpair.h +++ b/lib/libnvpair/include/libnvpair.h @@ -26,7 +26,7 @@ #ifndef _LIBNVPAIR_H #define _LIBNVPAIR_H -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/nvpair.h> #include <stdlib.h> diff --git a/lib/libnvpair/libnvpair.c b/lib/libnvpair/libnvpair.c index 0845cb08c..9815f5b5e 100644 --- a/lib/libnvpair/libnvpair.c +++ b/lib/libnvpair/libnvpair.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include <unistd.h> #include <strings.h> @@ -141,7 +141,7 @@ nvlist_print_with_indent(FILE *fp, nvlist_t *nvl, int depth) case DATA_TYPE_DOUBLE: { double val; (void) nvpair_value_double(nvp, &val); - (void) fprintf(fp, " 0x%llf", val); + (void) fprintf(fp, " %f", val); break; } case DATA_TYPE_STRING: { @@ -565,7 +565,7 @@ nvpair_value_match_regex(nvpair_t *nvp, int ai, boolean_t val, val_arg; /* scanf boolean_t from value and check for match */ - sr = sscanf(value, "%"SCNi32, &val_arg); + sr = sscanf(value, "%"SCNi32, (int32_t *)&val_arg); if ((sr == 1) && (nvpair_value_boolean_value(nvp, &val) == 0) && (val == val_arg)) @@ -576,7 +576,7 @@ nvpair_value_match_regex(nvpair_t *nvp, int ai, boolean_t *val_array, val_arg; /* check indexed value of array for match */ - sr = sscanf(value, "%"SCNi32, &val_arg); + sr = sscanf(value, "%"SCNi32, (int32_t *)&val_arg); if ((sr == 1) && (nvpair_value_boolean_array(nvp, &val_array, &a_len) == 0) && diff --git a/lib/libnvpair/nvpair_alloc_system.c b/lib/libnvpair/nvpair_alloc_system.c index e76557795..f45dc5f0b 100644 --- a/lib/libnvpair/nvpair_alloc_system.c +++ b/lib/libnvpair/nvpair_alloc_system.c @@ -24,7 +24,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include <rpc/types.h> #include <sys/nvpair.h> diff --git a/lib/libuutil/include/libuutil_common.h b/lib/libuutil/include/libuutil_common.h index 9ebaaedfd..52ac4887f 100644 --- a/lib/libuutil/include/libuutil_common.h +++ b/lib/libuutil/include/libuutil_common.h @@ -27,7 +27,7 @@ #ifndef _LIBUUTIL_COMMON_H #define _LIBUUTIL_COMMON_H -#pragma ident "%Z%%M% %I% %E% SMI" + #include <libuutil.h> #include <libuutil_impl.h> diff --git a/lib/libuutil/include/libuutil_impl.h b/lib/libuutil/include/libuutil_impl.h index 9466e5974..f978b475e 100644 --- a/lib/libuutil/include/libuutil_impl.h +++ b/lib/libuutil/include/libuutil_impl.h @@ -27,7 +27,7 @@ #ifndef _LIBUUTIL_IMPL_H #define _LIBUUTIL_IMPL_H -#pragma ident "%Z%%M% %I% %E% SMI" + #include <libuutil.h> #include <pthread.h> @@ -40,11 +40,11 @@ extern "C" { #endif void uu_set_error(uint_t); -#pragma rarely_called(uu_set_error) + /*PRINTFLIKE1*/ void uu_panic(const char *format, ...); -#pragma rarely_called(uu_panic) + struct uu_dprintf { char *uud_name; diff --git a/lib/libuutil/uu_avl.c b/lib/libuutil/uu_avl.c index 308e9208f..040008883 100644 --- a/lib/libuutil/uu_avl.c +++ b/lib/libuutil/uu_avl.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include "libuutil_common.h" diff --git a/lib/libuutil/uu_dprintf.c b/lib/libuutil/uu_dprintf.c index 5b990a52b..5d5fb84a8 100644 --- a/lib/libuutil/uu_dprintf.c +++ b/lib/libuutil/uu_dprintf.c @@ -24,7 +24,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include "libuutil_common.h" diff --git a/lib/libuutil/uu_ident.c b/lib/libuutil/uu_ident.c index 9a643845f..382139316 100644 --- a/lib/libuutil/uu_ident.c +++ b/lib/libuutil/uu_ident.c @@ -24,7 +24,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include "libuutil_common.h" diff --git a/lib/libuutil/uu_list.c b/lib/libuutil/uu_list.c index 35c7ba800..c3a447d01 100644 --- a/lib/libuutil/uu_list.c +++ b/lib/libuutil/uu_list.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include "libuutil_common.h" diff --git a/lib/libuutil/uu_misc.c b/lib/libuutil/uu_misc.c index 74ec177c1..a4ae4a1e7 100644 --- a/lib/libuutil/uu_misc.c +++ b/lib/libuutil/uu_misc.c @@ -24,7 +24,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include "libuutil_common.h" @@ -211,7 +211,11 @@ uu_panic(const char *format, ...) int assfail(const char *astring, const char *file, int line) { +#if defined(__STDC__) && __STDC_VERSION__ - 0 >= 199901L + __assert_c99(astring, file, line, "unknown func"); +#else __assert(astring, file, line); +#endif /*NOTREACHED*/ return (0); } @@ -247,7 +251,13 @@ uu_release_child(void) uu_release(); } +#ifdef __GNUC__ +static void +uu_init(void) __attribute__((constructor)); +#else #pragma init(uu_init) +#endif + static void uu_init(void) { diff --git a/lib/libuutil/uu_open.c b/lib/libuutil/uu_open.c index 7256662e3..cf5c5450b 100644 --- a/lib/libuutil/uu_open.c +++ b/lib/libuutil/uu_open.c @@ -24,7 +24,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include "libuutil_common.h" diff --git a/lib/libuutil/uu_pname.c b/lib/libuutil/uu_pname.c index 3307a26dc..a6a0f2266 100644 --- a/lib/libuutil/uu_pname.c +++ b/lib/libuutil/uu_pname.c @@ -24,7 +24,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include "libuutil_common.h" diff --git a/lib/libuutil/uu_strtoint.c b/lib/libuutil/uu_strtoint.c index 8fd114836..494e0a5b9 100644 --- a/lib/libuutil/uu_strtoint.c +++ b/lib/libuutil/uu_strtoint.c @@ -24,7 +24,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include "libuutil_common.h" diff --git a/lib/libzfs/libzfs_changelist.c b/lib/libzfs/libzfs_changelist.c index 6fa196710..11fee7518 100644 --- a/lib/libzfs/libzfs_changelist.c +++ b/lib/libzfs/libzfs_changelist.c @@ -140,6 +140,8 @@ changelist_prefix(prop_changelist_t *clp) */ (void) zfs_unshare_iscsi(cn->cn_handle); break; + default: + break; } } else { /* @@ -156,6 +158,8 @@ changelist_prefix(prop_changelist_t *clp) case ZFS_PROP_SHARESMB: (void) zfs_unshare_smb(cn->cn_handle, NULL); break; + default: + break; } } } diff --git a/lib/libzfs/libzfs_config.c b/lib/libzfs/libzfs_config.c index 94640d1b1..875af8d33 100644 --- a/lib/libzfs/libzfs_config.c +++ b/lib/libzfs/libzfs_config.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + /* * The pool configuration repository is stored in /etc/zfs/zpool.cache as a @@ -103,7 +103,7 @@ namespace_reload(libzfs_handle_t *hdl) nvlist_t *config; config_node_t *cn; nvpair_t *elem; - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; void *cookie; if (hdl->libzfs_ns_gen == 0) { @@ -228,7 +228,7 @@ zpool_get_config(zpool_handle_t *zhp, nvlist_t **oldconfig) int zpool_refresh_stats(zpool_handle_t *zhp, boolean_t *missing) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; int error; nvlist_t *config; libzfs_handle_t *hdl = zhp->zpool_hdl; diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index bc0ae653e..d34ab5aa1 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -75,6 +75,8 @@ zfs_type_to_name(zfs_type_t type) return (dgettext(TEXT_DOMAIN, "snapshot")); case ZFS_TYPE_VOLUME: return (dgettext(TEXT_DOMAIN, "volume")); + default: + break; } return (NULL); @@ -183,6 +185,8 @@ zfs_validate_name(libzfs_handle_t *hdl, const char *path, int type, zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "reserved disk name")); break; + default: + break; } } @@ -372,7 +376,7 @@ static int get_stats(zfs_handle_t *zhp) { int rc = 0; - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; if (zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0) != 0) return (-1); @@ -419,7 +423,7 @@ top: if (zhp->zfs_dmustats.dds_inconsistent) { - zfs_cmd_t zc2 = { 0 }; + zfs_cmd_t zc2 = { "\0", "\0", "\0", 0 }; /* * If it is dds_inconsistent, then we've caught it in @@ -493,7 +497,7 @@ top: zfs_handle_t * make_dataset_handle(libzfs_handle_t *hdl, const char *path) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; zfs_handle_t *zhp = calloc(sizeof (zfs_handle_t), 1); @@ -727,15 +731,14 @@ libzfs_mnttab_remove(libzfs_handle_t *hdl, const char *fsname) } int -zfs_spa_version(zfs_handle_t *zhp, int *spa_version) +zfs_spa_version(zfs_handle_t *zhp, int *version) { - zpool_handle_t *zpool_handle = zhp->zpool_hdl; + zpool_handle_t *handle = zhp->zpool_hdl; - if (zpool_handle == NULL) + if (handle == NULL) return (-1); - *spa_version = zpool_get_prop_int(zpool_handle, - ZPOOL_PROP_VERSION, NULL); + *version = zpool_get_prop_int(handle, ZPOOL_PROP_VERSION, NULL); return (0); } @@ -745,12 +748,12 @@ zfs_spa_version(zfs_handle_t *zhp, int *spa_version) static int zfs_which_resv_prop(zfs_handle_t *zhp, zfs_prop_t *resv_prop) { - int spa_version; + int version; - if (zfs_spa_version(zhp, &spa_version) < 0) + if (zfs_spa_version(zhp, &version) < 0) return (-1); - if (spa_version >= SPA_VERSION_REFRESERVATION) + if (version >= SPA_VERSION_REFRESERVATION) *resv_prop = ZFS_PROP_REFRESERVATION; else *resv_prop = ZFS_PROP_RESERVATION; @@ -994,6 +997,8 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl, "component of '%s' is too long"), propname); break; + default: + break; } (void) zfs_error(hdl, EZFS_BADPROP, errbuf); goto error; @@ -1118,6 +1123,8 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl, case ZFS_PROP_NORMALIZE: chosen_normal = (int)intval; break; + default: + break; } /* @@ -1166,6 +1173,8 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl, goto error; } break; + default: + break; } } } @@ -1231,7 +1240,7 @@ error: int zfs_prop_set(zfs_handle_t *zhp, const char *propname, const char *propval) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; int ret = -1; prop_changelist_t *cl = NULL; char errbuf[1024]; @@ -1392,7 +1401,7 @@ error: int zfs_prop_inherit(zfs_handle_t *zhp, const char *propname) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; int ret; prop_changelist_t *cl; libzfs_handle_t *hdl = zhp->zfs_hdl; @@ -1546,7 +1555,7 @@ static int get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src, char **source, uint64_t *val) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; nvlist_t *zplprops = NULL; struct mnttab mnt; char *mntopt_on = NULL; @@ -1589,6 +1598,8 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src, mntopt_on = MNTOPT_NBMAND; mntopt_off = MNTOPT_NONBMAND; break; + default: + break; } /* @@ -1781,14 +1792,14 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen, */ { val = getprop_uint64(zhp, prop, &source); - time_t time = (time_t)val; + time_t local_time = (time_t)val; struct tm t; if (literal || - localtime_r(&time, &t) == NULL || + localtime_r(&local_time, &t) == NULL || strftime(propbuf, proplen, "%a %b %e %k:%M %Y", &t) == 0) - (void) snprintf(propbuf, proplen, "%llu", val); + (void) snprintf(propbuf, proplen, "%llu", (u_longlong_t) val); } break; @@ -2173,7 +2184,7 @@ zfs_prop_get_userquota_common(zfs_handle_t *zhp, const char *propname, uint64_t *propvalue, zfs_userquota_prop_t *typep) { int err; - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; (void) strncpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name)); @@ -2217,7 +2228,8 @@ zfs_prop_get_userquota(zfs_handle_t *zhp, const char *propname, return (err); if (literal) { - (void) snprintf(propbuf, proplen, "%llu", propvalue); + (void) snprintf(propbuf, proplen, "%llu", + (u_longlong_t)propvalue); } else if (propvalue == 0 && (type == ZFS_PROP_USERQUOTA || type == ZFS_PROP_GROUPQUOTA)) { (void) strlcpy(propbuf, "none", proplen); @@ -2291,7 +2303,7 @@ top: int zfs_iter_filesystems(zfs_handle_t *zhp, zfs_iter_f func, void *data) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; zfs_handle_t *nzhp; int ret; @@ -2327,7 +2339,7 @@ zfs_iter_filesystems(zfs_handle_t *zhp, zfs_iter_f func, void *data) int zfs_iter_snapshots(zfs_handle_t *zhp, zfs_iter_f func, void *data) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; zfs_handle_t *nzhp; int ret; @@ -2397,7 +2409,7 @@ static int check_parents(libzfs_handle_t *hdl, const char *path, uint64_t *zoned, boolean_t accept_ancestor, int *prefixlen) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; char parent[ZFS_MAXNAMELEN]; char *slash; zfs_handle_t *zhp; @@ -2602,7 +2614,7 @@ int zfs_create(libzfs_handle_t *hdl, const char *path, zfs_type_t type, nvlist_t *props) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; int ret; uint64_t size = 0; uint64_t blocksize = zfs_prop_default_numeric(ZFS_PROP_VOLBLOCKSIZE); @@ -2765,7 +2777,7 @@ zfs_create(libzfs_handle_t *hdl, const char *path, zfs_type_t type, int zfs_destroy(zfs_handle_t *zhp) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name)); @@ -2845,7 +2857,7 @@ zfs_remove_link_cb(zfs_handle_t *zhp, void *arg) int zfs_destroy_snaps(zfs_handle_t *zhp, char *snapname) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; int ret; struct destroydata dd = { 0 }; @@ -2889,7 +2901,7 @@ zfs_destroy_snaps(zfs_handle_t *zhp, char *snapname) int zfs_clone(zfs_handle_t *zhp, const char *target, nvlist_t *props) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; char parent[ZFS_MAXNAMELEN]; int ret; char errbuf[1024]; @@ -3038,7 +3050,7 @@ int zfs_promote(zfs_handle_t *zhp) { libzfs_handle_t *hdl = zhp->zfs_hdl; - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; char parent[MAXPATHLEN]; char *cp; int ret; @@ -3161,7 +3173,7 @@ zfs_snapshot(libzfs_handle_t *hdl, const char *path, boolean_t recursive, const char *delim; char parent[ZFS_MAXNAMELEN]; zfs_handle_t *zhp; - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; int ret; char errbuf[1024]; @@ -3313,10 +3325,10 @@ zfs_rollback(zfs_handle_t *zhp, zfs_handle_t *snap, boolean_t force) { rollback_data_t cb = { 0 }; int err; - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\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); @@ -3435,7 +3447,7 @@ int zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive) { int ret; - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; char *delim; prop_changelist_t *cl = NULL; zfs_handle_t *zhrp = NULL; @@ -3566,6 +3578,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; } @@ -3656,7 +3669,7 @@ zvol_create_link(libzfs_handle_t *hdl, const char *dataset) static int zvol_create_link_common(libzfs_handle_t *hdl, const char *dataset, int ifexists) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; di_devlink_handle_t dhdl; priv_set_t *priv_effective; int privileged; @@ -3752,7 +3765,7 @@ zvol_create_link_common(libzfs_handle_t *hdl, const char *dataset, int ifexists) int zvol_remove_link(libzfs_handle_t *hdl, const char *dataset) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; (void) strlcpy(zc.zc_name, dataset, sizeof (zc.zc_name)); @@ -3880,7 +3893,7 @@ zfs_expand_proplist(zfs_handle_t *zhp, zprop_list_t **plp) int zfs_iscsi_perm_check(libzfs_handle_t *hdl, char *dataset, ucred_t *cred) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; nvlist_t *nvp; gid_t gid; uid_t uid; @@ -3928,7 +3941,7 @@ zfs_deleg_share_nfs(libzfs_handle_t *hdl, char *dataset, char *path, char *resource, void *export, void *sharetab, int sharemax, zfs_share_op_t operation) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; int error; (void) strlcpy(zc.zc_name, dataset, sizeof (zc.zc_name)); @@ -3976,7 +3989,7 @@ static int zfs_smb_acl_mgmt(libzfs_handle_t *hdl, char *dataset, char *path, zfs_smb_acl_op_t cmd, char *resource1, char *resource2) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; nvlist_t *nvlist = NULL; int error; @@ -4058,7 +4071,7 @@ int zfs_userspace(zfs_handle_t *zhp, zfs_userquota_prop_t type, zfs_userspace_cb_t func, void *arg) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; int error; zfs_useracct_t buf[100]; diff --git a/lib/libzfs/libzfs_graph.c b/lib/libzfs/libzfs_graph.c index bc21c51ae..48e722edb 100644 --- a/lib/libzfs/libzfs_graph.c +++ b/lib/libzfs/libzfs_graph.c @@ -379,7 +379,7 @@ zfs_graph_add(libzfs_handle_t *hdl, zfs_graph_t *zgp, const char *source, static int iterate_children(libzfs_handle_t *hdl, zfs_graph_t *zgp, const char *dataset) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; zfs_vertex_t *zvp; /* @@ -473,7 +473,7 @@ iterate_children(libzfs_handle_t *hdl, zfs_graph_t *zgp, const char *dataset) static boolean_t external_dependents(libzfs_handle_t *hdl, zfs_graph_t *zgp, const char *dataset) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; /* * Check whether this dataset is a clone or has clones since diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c index d67776889..4a7634a63 100644 --- a/lib/libzfs/libzfs_import.c +++ b/lib/libzfs/libzfs_import.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + /* * Pool import support functions. @@ -367,7 +367,7 @@ static nvlist_t * refresh_config(libzfs_handle_t *hdl, nvlist_t *config) { nvlist_t *nvl; - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; int err; if (zcmd_write_conf_nvlist(hdl, &zc, config) != 0) @@ -416,7 +416,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_mount.c b/lib/libzfs/libzfs_mount.c index 7810e5d68..1dd345a27 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -92,7 +92,7 @@ zfs_share_type_t zfs_is_shared_proto(zfs_handle_t *, char **, static int (*iscsitgt_zfs_share)(const char *); static int (*iscsitgt_zfs_unshare)(const char *); static int (*iscsitgt_zfs_is_shared)(const char *); -static int (*iscsitgt_svc_online)(); +static int (*iscsitgt_svc_online)(void); /* * The share protocols table must be in the same order as the zfs_share_prot_t @@ -125,7 +125,13 @@ zfs_share_proto_t share_all_proto[] = { PROTO_END }; +#ifdef __GNUC__ +static void +zfs_iscsi_init(void) __attribute__((constructor)); +#else #pragma init(zfs_iscsi_init) +#endif + static void zfs_iscsi_init(void) { @@ -139,7 +145,7 @@ zfs_iscsi_init(void) "iscsitgt_zfs_unshare")) == NULL || (iscsitgt_zfs_is_shared = (int (*)(const char *))dlsym(libiscsitgt, "iscsitgt_zfs_is_shared")) == NULL || - (iscsitgt_svc_online = (int (*)(const char *))dlsym(libiscsitgt, + (iscsitgt_svc_online = (int (*)(void))dlsym(libiscsitgt, "iscsitgt_svc_online")) == NULL) { iscsitgt_zfs_share = NULL; iscsitgt_zfs_unshare = NULL; @@ -205,12 +211,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 *dirname) +dir_is_empty(const char *dirn) { DIR *dirp; struct dirent64 *dp; - if ((dirp = opendir(dirname)) == NULL) + if ((dirp = opendir(dirn)) == NULL) return (B_TRUE); while ((dp = readdir64(dirp)) != NULL) { @@ -536,8 +542,12 @@ static void (*_sa_update_sharetab_ts)(sa_handle_t); * values to be used later. This is triggered by the runtime loader. * Make sure the correct ISA version is loaded. */ - +#ifdef __GNUC__ +static void +_zfs_init_libshare(void) __attribute__((constructor)); +#else #pragma init(_zfs_init_libshare) +#endif static void _zfs_init_libshare(void) { diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index fd734d8b4..b8989a026 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -69,7 +69,7 @@ static int read_efi_label(nvlist_t *config, diskaddr_t *sb); static int zpool_get_all_props(zpool_handle_t *zhp) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; libzfs_handle_t *hdl = zhp->zpool_hdl; (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); @@ -185,6 +185,8 @@ char * zpool_state_to_name(vdev_state_t state, vdev_aux_t aux) { switch (state) { + default: + break; case VDEV_STATE_CLOSED: case VDEV_STATE_OFFLINE: return (gettext("OFFLINE")); @@ -233,7 +235,7 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len, case ZPOOL_PROP_GUID: intval = zpool_get_prop_int(zhp, prop, &src); - (void) snprintf(buf, len, "%llu", intval); + (void) snprintf(buf, len, "%llu", (u_longlong_t)intval); break; case ZPOOL_PROP_ALTROOT: @@ -293,7 +295,7 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len, vs->vs_aux), len); break; default: - (void) snprintf(buf, len, "%llu", intval); + (void) snprintf(buf, len, "%llu", (u_longlong_t)intval); } break; @@ -419,6 +421,8 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname, * Perform additional checking for specific properties. */ switch (prop) { + default: + break; case ZPOOL_PROP_VERSION: if (intval < version || intval > SPA_VERSION) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, @@ -553,7 +557,7 @@ error: int zpool_set_prop(zpool_handle_t *zhp, const char *propname, const char *propval) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; int ret = -1; char errbuf[1024]; nvlist_t *nvl = NULL; @@ -717,7 +721,10 @@ zpool_name_valid(libzfs_handle_t *hdl, boolean_t isopen, const char *pool) zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "multiple '@' delimiters in name")); break; - + case NAME_ERR_NO_AT: + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "permission set is missing '@'")); + break; } } return (B_FALSE); @@ -864,7 +871,7 @@ int zpool_create(libzfs_handle_t *hdl, const char *pool, nvlist_t *nvroot, nvlist_t *props, nvlist_t *fsprops) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; nvlist_t *zc_fsprops = NULL; nvlist_t *zc_props = NULL; char msg[1024]; @@ -994,7 +1001,7 @@ create_failed: int zpool_destroy(zpool_handle_t *zhp) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; zfs_handle_t *zfp = NULL; libzfs_handle_t *hdl = zhp->zpool_hdl; char msg[1024]; @@ -1041,7 +1048,7 @@ zpool_destroy(zpool_handle_t *zhp) int zpool_add(zpool_handle_t *zhp, nvlist_t *nvroot) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; int ret; libzfs_handle_t *hdl = zhp->zpool_hdl; char msg[1024]; @@ -1164,7 +1171,7 @@ zpool_add(zpool_handle_t *zhp, nvlist_t *nvroot) int zpool_export_common(zpool_handle_t *zhp, boolean_t force, boolean_t hardforce) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; char msg[1024]; if (zpool_remove_zvol_links(zhp) != 0) @@ -1256,7 +1263,7 @@ int zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname, nvlist_t *props, boolean_t importfaulted) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; char *thename; char *origname; int ret; @@ -1360,7 +1367,7 @@ zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname, int zpool_scrub(zpool_handle_t *zhp, pool_scrub_type_t type) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; char msg[1024]; libzfs_handle_t *hdl = zhp->zpool_hdl; @@ -1795,7 +1802,7 @@ int zpool_vdev_online(zpool_handle_t *zhp, const char *path, int flags, vdev_state_t *newstate) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; char msg[1024]; nvlist_t *tgt; boolean_t avail_spare, l2cache, islog; @@ -1861,7 +1868,7 @@ zpool_vdev_online(zpool_handle_t *zhp, const char *path, int flags, int zpool_vdev_offline(zpool_handle_t *zhp, const char *path, boolean_t istmp) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; char msg[1024]; nvlist_t *tgt; boolean_t avail_spare, l2cache; @@ -1912,12 +1919,12 @@ zpool_vdev_offline(zpool_handle_t *zhp, const char *path, boolean_t istmp) int zpool_vdev_fault(zpool_handle_t *zhp, uint64_t guid) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; char msg[1024]; libzfs_handle_t *hdl = zhp->zpool_hdl; (void) snprintf(msg, sizeof (msg), - dgettext(TEXT_DOMAIN, "cannot fault %llu"), guid); + dgettext(TEXT_DOMAIN, "cannot fault %llu"), (u_longlong_t)guid); (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); zc.zc_guid = guid; @@ -1946,12 +1953,12 @@ zpool_vdev_fault(zpool_handle_t *zhp, uint64_t guid) int zpool_vdev_degrade(zpool_handle_t *zhp, uint64_t guid) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; char msg[1024]; libzfs_handle_t *hdl = zhp->zpool_hdl; (void) snprintf(msg, sizeof (msg), - dgettext(TEXT_DOMAIN, "cannot degrade %llu"), guid); + dgettext(TEXT_DOMAIN, "cannot degrade %llu"), (u_longlong_t)guid); (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); zc.zc_guid = guid; @@ -1999,7 +2006,7 @@ int zpool_vdev_attach(zpool_handle_t *zhp, const char *old_disk, const char *new_disk, nvlist_t *nvroot, int replacing) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; char msg[1024]; int ret; nvlist_t *tgt; @@ -2190,7 +2197,7 @@ zpool_vdev_attach(zpool_handle_t *zhp, int zpool_vdev_detach(zpool_handle_t *zhp, const char *path) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; char msg[1024]; nvlist_t *tgt; boolean_t avail_spare, l2cache; @@ -2247,7 +2254,7 @@ zpool_vdev_detach(zpool_handle_t *zhp, const char *path) int zpool_vdev_remove(zpool_handle_t *zhp, const char *path) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; char msg[1024]; nvlist_t *tgt; boolean_t avail_spare, l2cache; @@ -2282,7 +2289,7 @@ zpool_vdev_remove(zpool_handle_t *zhp, const char *path) int zpool_clear(zpool_handle_t *zhp, const char *path) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; char msg[1024]; nvlist_t *tgt; boolean_t avail_spare, l2cache; @@ -2326,13 +2333,13 @@ zpool_clear(zpool_handle_t *zhp, const char *path) int zpool_vdev_clear(zpool_handle_t *zhp, uint64_t guid) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; char msg[1024]; libzfs_handle_t *hdl = zhp->zpool_hdl; (void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN, "cannot clear errors for %llx"), - guid); + (u_longlong_t)guid); (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); zc.zc_guid = guid; @@ -2576,7 +2583,7 @@ path_to_devid(const char *path) static void set_path(zpool_handle_t *zhp, nvlist_t *nv, const char *path) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; (void) strncpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); (void) strncpy(zc.zc_value, path, sizeof (zc.zc_value)); @@ -2699,7 +2706,7 @@ zbookmark_compare(const void *a, const void *b) int zpool_get_errlog(zpool_handle_t *zhp, nvlist_t **nverrlistp) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; uint64_t count; zbookmark_t *zb = NULL; int i; @@ -2795,7 +2802,7 @@ nomem: int zpool_upgrade(zpool_handle_t *zhp, uint64_t new_version) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; libzfs_handle_t *hdl = zhp->zpool_hdl; (void) strcpy(zc.zc_name, zhp->zpool_name); @@ -2857,7 +2864,7 @@ zpool_stage_history(libzfs_handle_t *hdl, const char *history_str) static int get_history(zpool_handle_t *zhp, char *buf, uint64_t *off, uint64_t *len) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; libzfs_handle_t *hdl = zhp->zpool_hdl; (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); @@ -2984,14 +2991,14 @@ void zpool_obj_to_path(zpool_handle_t *zhp, uint64_t dsobj, uint64_t obj, char *pathname, size_t len) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; boolean_t mounted = B_FALSE; char *mntpnt = NULL; char dsname[MAXNAMELEN]; if (dsobj == 0) { /* special case for the MOS */ - (void) snprintf(pathname, len, "<metadata>:<0x%llx>", obj); + (void) snprintf(pathname, len, "<metadata>:<0x%llx>", (longlong_t)obj); return; } @@ -3002,7 +3009,7 @@ zpool_obj_to_path(zpool_handle_t *zhp, uint64_t dsobj, uint64_t obj, ZFS_IOC_DSOBJ_TO_DSNAME, &zc) != 0) { /* just write out a path of two object numbers */ (void) snprintf(pathname, len, "<0x%llx>:<0x%llx>", - dsobj, obj); + (longlong_t)dsobj, (longlong_t)obj); return; } (void) strlcpy(dsname, zc.zc_value, sizeof (dsname)); @@ -3023,7 +3030,7 @@ zpool_obj_to_path(zpool_handle_t *zhp, uint64_t dsobj, uint64_t obj, dsname, zc.zc_value); } } else { - (void) snprintf(pathname, len, "%s:<0x%llx>", dsname, obj); + (void) snprintf(pathname, len, "%s:<0x%llx>", dsname, (longlong_t)obj); } free(mntpnt); } diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c index 612a09914..a81b04396 100644 --- a/lib/libzfs/libzfs_sendrecv.c +++ b/lib/libzfs/libzfs_sendrecv.c @@ -453,7 +453,7 @@ static int dump_ioctl(zfs_handle_t *zhp, const char *fromsnap, boolean_t fromorigin, int outfd) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; libzfs_handle_t *hdl = zhp->zfs_hdl; assert(zhp->zfs_type == ZFS_TYPE_SNAPSHOT); @@ -554,7 +554,7 @@ dump_filesystem(zfs_handle_t *zhp, void *arg) int rv = 0; send_dump_data_t *sdd = arg; boolean_t missingfrom = B_FALSE; - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; (void) snprintf(zc.zc_name, sizeof (zc.zc_name), "%s@%s", zhp->zfs_name, sdd->tosnap); @@ -717,7 +717,7 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap, dmu_replay_record_t drr = { 0 }; char *packbuf = NULL; size_t buflen = 0; - zio_cksum_t zc = { 0 }; + zio_cksum_t zc = { { 0 } }; assert(fromsnap || doall); @@ -883,7 +883,7 @@ recv_rename(libzfs_handle_t *hdl, const char *name, const char *tryname, int baselen, char *newname, recvflags_t flags) { static int seq; - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; int err; prop_changelist_t *clp; zfs_handle_t *zhp; @@ -923,7 +923,7 @@ recv_rename(libzfs_handle_t *hdl, const char *name, const char *tryname, (void) strncpy(newname, name, baselen); (void) snprintf(newname+baselen, ZFS_MAXNAMELEN-baselen, - "recv-%u-%u", getpid(), seq); + "recv-%ld-%u", (long) getpid(), seq); (void) strlcpy(zc.zc_value, newname, sizeof (zc.zc_value)); if (flags.verbose) { @@ -955,7 +955,7 @@ static int recv_destroy(libzfs_handle_t *hdl, const char *name, int baselen, char *newname, recvflags_t flags) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; int err = 0; prop_changelist_t *clp; zfs_handle_t *zhp; @@ -1166,7 +1166,7 @@ again: stream_originguid, originguid)) { case 1: { /* promote it! */ - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; nvlist_t *origin_nvfs; char *origin_fsname; @@ -1238,7 +1238,7 @@ again: if (0 == nvlist_lookup_nvlist(stream_nvfs, "snapprops", &props) && 0 == nvlist_lookup_nvlist(props, stream_snapname, &props)) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; zc.zc_cookie = B_TRUE; /* clear current props */ (void) snprintf(zc.zc_name, sizeof (zc.zc_name), @@ -1564,7 +1564,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap, dmu_replay_record_t *drr_noswap, avl_tree_t *stream_avl, char **top_zfs) { - zfs_cmd_t zc = { 0 }; + zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; time_t begin_time; int ioctl_err, ioctl_errno, err, choplen; char *cp; @@ -1673,7 +1673,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap, (void) printf("found clone origin %s\n", zc.zc_string); } - stream_wantsnewfs = (drrb->drr_fromguid == NULL || + stream_wantsnewfs = (drrb->drr_fromguid == 0 || (drrb->drr_flags & DRR_FLAG_CLONE)); if (stream_wantsnewfs) { @@ -1843,7 +1843,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap, zcmd_free_nvlists(&zc); if (err == 0 && snapprops_nvlist) { - zfs_cmd_t zc2 = { 0 }; + zfs_cmd_t zc2 = { "\0", "\0", "\0", 0 }; (void) strcpy(zc2.zc_name, zc.zc_value); if (zcmd_write_src_nvlist(hdl, &zc2, snapprops_nvlist) == 0) { @@ -1860,13 +1860,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) { @@ -1998,7 +1998,7 @@ zfs_receive_impl(libzfs_handle_t *hdl, const char *tosnap, recvflags_t flags, dmu_replay_record_t drr, drr_noswap; struct drr_begin *drrb = &drr.drr_u.drr_begin; char errbuf[1024]; - zio_cksum_t zcksum = { 0 }; + zio_cksum_t zcksum = { { 0 } }; (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, "cannot receive")); diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c index 30829d50d..66ec8a2df 100644 --- a/lib/libzfs/libzfs_util.c +++ b/lib/libzfs/libzfs_util.c @@ -521,24 +521,24 @@ void zfs_nicenum(uint64_t num, char *buf, size_t buflen) { uint64_t n = num; - int index = 0; + int i = 0, j; char u; while (n >= 1024) { n /= 1024; - index++; + i++; } - u = " KMGTPE"[index]; + u = " KMGTPE"[i]; - if (index == 0) { - (void) snprintf(buf, buflen, "%llu", n); - } else if ((num & ((1ULL << 10 * index) - 1)) == 0) { + if (i == 0) { + (void) snprintf(buf, buflen, "%llu", (u_longlong_t) n); + } else if ((num & ((1ULL << 10 * i) - 1)) == 0) { /* * If this is an even multiple of the base, always display * without any decimal precision. */ - (void) snprintf(buf, buflen, "%llu%c", n, u); + (void) snprintf(buf, buflen, "%llu%c", (u_longlong_t) n, u); } else { /* * We want to choose a precision that reflects the best choice @@ -549,10 +549,9 @@ 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. */ - int i; - for (i = 2; i >= 0; i--) { - if (snprintf(buf, buflen, "%.*f%c", i, - (double)num / (1ULL << 10 * index), u) <= 5) + for (j = 2; j >= 0; j--) { + if (snprintf(buf, buflen, "%.*f%c", j, + (double)num / (1ULL << 10 * j), u) <= 5) break; } } @@ -684,7 +683,7 @@ zcmd_alloc_dst_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, size_t len) len = 2048; zc->zc_nvlist_dst_size = len; if ((zc->zc_nvlist_dst = (uint64_t)(uintptr_t) - zfs_alloc(hdl, zc->zc_nvlist_dst_size)) == NULL) + zfs_alloc(hdl, zc->zc_nvlist_dst_size)) == 0) return (-1); return (0); @@ -700,8 +699,7 @@ zcmd_expand_dst_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc) { free((void *)(uintptr_t)zc->zc_nvlist_dst); if ((zc->zc_nvlist_dst = (uint64_t)(uintptr_t) - zfs_alloc(hdl, zc->zc_nvlist_dst_size)) - == NULL) + zfs_alloc(hdl, zc->zc_nvlist_dst_size)) == 0) return (-1); return (0); @@ -906,7 +904,7 @@ zprop_print_one_property(const char *name, zprop_get_cbdata_t *cbp, const char *source) { int i; - const char *str; + const char *str = NULL; char buf[128]; /* @@ -1381,7 +1379,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 exp; + expand_data_t ed; if (*plp == NULL) { /* @@ -1391,11 +1389,11 @@ zprop_expand_list(libzfs_handle_t *hdl, zprop_list_t **plp, zfs_type_t type) */ last = plp; - exp.last = last; - exp.hdl = hdl; - exp.type = type; + ed.last = last; + ed.hdl = hdl; + ed.type = type; - if (zprop_iter_common(zprop_expand_list_cb, &exp, B_FALSE, + if (zprop_iter_common(zprop_expand_list_cb, &ed, B_FALSE, B_FALSE, type) == ZPROP_INVAL) return (-1); diff --git a/lib/libzpool/kernel.c b/lib/libzpool/kernel.c index 89108fe5b..f43c8c644 100644 --- a/lib/libzpool/kernel.c +++ b/lib/libzpool/kernel.c @@ -323,7 +323,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 realpath[MAXPATHLEN]; + char real_path[MAXPATHLEN]; struct stat64 st; /* @@ -346,14 +346,14 @@ vn_open(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3) return (errno); } close(fd); - (void) sprintf(realpath, "%s", path); + (void) sprintf(real_path, "%s", path); dsk = strstr(path, "/dsk/"); if (dsk != NULL) - (void) sprintf(realpath + (dsk - path) + 1, "r%s", + (void) sprintf(real_path + (dsk - path) + 1, "r%s", dsk + 1); } else { - (void) sprintf(realpath, "%s", path); - if (!(flags & FCREAT) && stat64(realpath, &st) == -1) + (void) sprintf(real_path, "%s", path); + if (!(flags & FCREAT) && stat64(real_path, &st) == -1) return (errno); } @@ -364,7 +364,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(realpath, flags - FREAD, mode); + fd = open64(real_path, flags - FREAD, mode); if (flags & FCREAT) (void) umask(old_umask); @@ -393,16 +393,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 *realpath = umem_alloc(strlen(path) + 2, UMEM_NOFAIL); + char *real_path = umem_alloc(strlen(path) + 2, UMEM_NOFAIL); int ret; ASSERT(startvp == rootdir); - (void) sprintf(realpath, "/%s", path); + (void) sprintf(real_path, "/%s", path); /* fd ignored for now, need if want to simulate nbmand support */ - ret = vn_open(realpath, x1, flags, mode, vpp, x2, x3); + ret = vn_open(real_path, x1, flags, mode, vpp, x2, x3); - umem_free(realpath, strlen(path) + 2); + umem_free(real_path, strlen(path) + 2); return (ret); } @@ -744,11 +744,11 @@ random_get_pseudo_bytes(uint8_t *ptr, size_t len) } int -ddi_strtoul(const char *hw_serial, char **nptr, int base, unsigned long *result) +ddi_strtoul(const char *serial, char **nptr, int base, unsigned long *result) { char *end; - *result = strtoul(hw_serial, &end, base); + *result = strtoul(serial, &end, base); if (*result == 0) return (errno); return (0); @@ -764,7 +764,7 @@ umem_out_of_memory(void) { char errmsg[] = "out of memory -- generating core dump\n"; - write(fileno(stderr), errmsg, sizeof (errmsg)); + (void) fprintf(stderr, "%s", errmsg); abort(); return (0); } diff --git a/lib/libzpool/util.c b/lib/libzpool/util.c index 781edb6e8..67f62d2e1 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 index = 0; + int i = 0; char u; while (n >= 1024) { n = (n + (1024 / 2)) / 1024; /* Round up or down */ - index++; + i++; } - u = " KMGTPE"[index]; + u = " KMGTPE"[i]; - if (index == 0) { + if (i == 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 * index), u); + (double)num / (1ULL << 10 * i), u); } else if (n < 100 && (num & (num - 1)) != 0) { (void) sprintf(buf, "%.1f%c", - (double)num / (1ULL << 10 * index), u); + (double)num / (1ULL << 10 * i), u); } else { (void) sprintf(buf, "%llu%c", (u_longlong_t)n, u); } @@ -109,7 +109,7 @@ show_vdev_stats(const char *desc, const char *ctype, nvlist_t *nv, int indent) (void) printf("%*s%s%*s%*s%*s %5s %5s %5s %5s %5s %5s %5s\n", indent, "", prefix, - indent + strlen(prefix) - 25 - (vs->vs_space ? 0 : 12), + (int)(indent+strlen(prefix)-25-(vs->vs_space ? 0 : 12)), desc, vs->vs_space ? 6 : 0, vs->vs_space ? used : "", vs->vs_space ? 6 : 0, vs->vs_space ? avail : "", diff --git a/module/avl/avl.c b/module/avl/avl.c index c9727c643..a9634d701 100644 --- a/module/avl/avl.c +++ b/module/avl/avl.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + /* diff --git a/module/avl/include/sys/avl.h b/module/avl/include/sys/avl.h index 02263a5a0..b2f35f79a 100644 --- a/module/avl/include/sys/avl.h +++ b/module/avl/include/sys/avl.h @@ -26,7 +26,7 @@ #ifndef _AVL_H #define _AVL_H -#pragma ident "%Z%%M% %I% %E% SMI" + /* * This is a private header file. Applications should not directly include diff --git a/module/avl/include/sys/avl_impl.h b/module/avl/include/sys/avl_impl.h index 620685f37..fddf76906 100644 --- a/module/avl/include/sys/avl_impl.h +++ b/module/avl/include/sys/avl_impl.h @@ -27,7 +27,7 @@ #ifndef _AVL_IMPL_H #define _AVL_IMPL_H -#pragma ident "%Z%%M% %I% %E% SMI" + /* * This is a private header file. Applications should not directly include diff --git a/module/nvpair/include/sys/nvpair.h b/module/nvpair/include/sys/nvpair.h index 9e768541f..14a45956f 100644 --- a/module/nvpair/include/sys/nvpair.h +++ b/module/nvpair/include/sys/nvpair.h @@ -26,7 +26,7 @@ #ifndef _SYS_NVPAIR_H #define _SYS_NVPAIR_H -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/types.h> #include <sys/errno.h> diff --git a/module/nvpair/include/sys/nvpair_impl.h b/module/nvpair/include/sys/nvpair_impl.h index f12dbbfe6..b851ddd54 100644 --- a/module/nvpair/include/sys/nvpair_impl.h +++ b/module/nvpair/include/sys/nvpair_impl.h @@ -27,7 +27,7 @@ #ifndef _NVPAIR_IMPL_H #define _NVPAIR_IMPL_H -#pragma ident "%Z%%M% %I% %E% SMI" + #ifdef __cplusplus extern "C" { diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c index cee02a04b..f9d99b11f 100644 --- a/module/nvpair/nvpair.c +++ b/module/nvpair/nvpair.c @@ -24,7 +24,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/stropts.h> #include <sys/debug.h> @@ -1560,10 +1560,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/unicode/include/sys/u8_textprep.h b/module/unicode/include/sys/u8_textprep.h index e30f064b2..f8b5bed6e 100644 --- a/module/unicode/include/sys/u8_textprep.h +++ b/module/unicode/include/sys/u8_textprep.h @@ -26,7 +26,7 @@ #ifndef _SYS_U8_TEXTPREP_H #define _SYS_U8_TEXTPREP_H -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/isa_defs.h> #include <sys/types.h> diff --git a/module/unicode/include/sys/u8_textprep_data.h b/module/unicode/include/sys/u8_textprep_data.h index de6866096..03f71f26c 100644 --- a/module/unicode/include/sys/u8_textprep_data.h +++ b/module/unicode/include/sys/u8_textprep_data.h @@ -68,7 +68,7 @@ #ifndef _SYS_U8_TEXTPREP_DATA_H #define _SYS_U8_TEXTPREP_DATA_H -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/types.h> diff --git a/module/unicode/u8_textprep.c b/module/unicode/u8_textprep.c index 635f00d44..2532769c8 100644 --- a/module/unicode/u8_textprep.c +++ b/module/unicode/u8_textprep.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + /* diff --git a/module/unicode/uconv.c b/module/unicode/uconv.c index fd65fc99b..b996e1f60 100644 --- a/module/unicode/uconv.c +++ b/module/unicode/uconv.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + /* * Unicode encoding conversion functions among UTF-8, UTF-16, and UTF-32. diff --git a/module/zcommon/include/zfs_comutil.h b/module/zcommon/include/zfs_comutil.h index f517044a8..b52e31e88 100644 --- a/module/zcommon/include/zfs_comutil.h +++ b/module/zcommon/include/zfs_comutil.h @@ -26,7 +26,7 @@ #ifndef _ZFS_COMUTIL_H #define _ZFS_COMUTIL_H -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/fs/zfs.h> #include <sys/types.h> diff --git a/module/zcommon/include/zfs_prop.h b/module/zcommon/include/zfs_prop.h index da5ae4309..bcc1b50c3 100644 --- a/module/zcommon/include/zfs_prop.h +++ b/module/zcommon/include/zfs_prop.h @@ -26,7 +26,7 @@ #ifndef _ZFS_PROP_H #define _ZFS_PROP_H -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/fs/zfs.h> #include <sys/types.h> diff --git a/module/zcommon/zfs_comutil.c b/module/zcommon/zfs_comutil.c index 74517a3f6..2b9869f18 100644 --- a/module/zcommon/zfs_comutil.c +++ b/module/zcommon/zfs_comutil.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + /* * This file is intended for functions that ought to be common between user diff --git a/module/zcommon/zfs_prop.c b/module/zcommon/zfs_prop.c index 05d830633..750f7d01c 100644 --- a/module/zcommon/zfs_prop.c +++ b/module/zcommon/zfs_prop.c @@ -405,15 +405,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 *index) +zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *idx) { - return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET)); + return (zprop_string_to_index(prop, string, idx, ZFS_TYPE_DATASET)); } int -zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string) +zfs_prop_index_to_string(zfs_prop_t prop, uint64_t idx, const char **string) { - return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET)); + return (zprop_index_to_string(prop, idx, string, ZFS_TYPE_DATASET)); } /* diff --git a/module/zcommon/zpool_prop.c b/module/zcommon/zpool_prop.c index d57dcfb63..fd24c34d4 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 *index) + uint64_t *idx) { - return (zprop_string_to_index(prop, string, index, ZFS_TYPE_POOL)); + return (zprop_string_to_index(prop, string, idx, ZFS_TYPE_POOL)); } int -zpool_prop_index_to_string(zpool_prop_t prop, uint64_t index, +zpool_prop_index_to_string(zpool_prop_t prop, uint64_t idx, const char **string) { - return (zprop_index_to_string(prop, index, string, ZFS_TYPE_POOL)); + return (zprop_index_to_string(prop, idx, string, ZFS_TYPE_POOL)); } #ifndef _KERNEL diff --git a/module/zcommon/zprop_common.c b/module/zcommon/zprop_common.c index 85f55c276..5f968e695 100644 --- a/module/zcommon/zprop_common.c +++ b/module/zcommon/zprop_common.c @@ -156,7 +156,7 @@ int zprop_iter_common(zprop_func func, void *cb, boolean_t show_all, boolean_t ordered, zfs_type_t type) { - int i, num_props, size, prop; + int i, j, num_props, size, prop; zprop_desc_t *prop_tbl; zprop_desc_t **order; @@ -171,7 +171,7 @@ zprop_iter_common(zprop_func func, void *cb, boolean_t show_all, return (ZPROP_CONT); #endif - for (int j = 0; j < num_props; j++) + for (j = 0; j < num_props; j++) order[j] = &prop_tbl[j]; if (ordered) { @@ -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 *index, +zprop_string_to_index(int prop, const char *string, uint64_t *idx, zfs_type_t type) { zprop_desc_t *prop_tbl; @@ -273,7 +273,7 @@ zprop_string_to_index(int prop, const char *string, uint64_t *index, for (i = 0; idx_tbl[i].pi_name != NULL; i++) { if (strcmp(string, idx_tbl[i].pi_name) == 0) { - *index = idx_tbl[i].pi_value; + *idx = idx_tbl[i].pi_value; return (0); } } @@ -282,7 +282,7 @@ zprop_string_to_index(int prop, const char *string, uint64_t *index, } int -zprop_index_to_string(int prop, uint64_t index, const char **string, +zprop_index_to_string(int prop, uint64_t idx, const char **string, zfs_type_t type) { zprop_desc_t *prop_tbl; @@ -298,7 +298,7 @@ zprop_index_to_string(int prop, uint64_t index, const char **string, return (-1); for (i = 0; idx_tbl[i].pi_name != NULL; i++) { - if (idx_tbl[i].pi_value == index) { + if (idx_tbl[i].pi_value == idx) { *string = idx_tbl[i].pi_name; return (0); } diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 6d23d4398..153081678 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -1112,6 +1112,8 @@ arc_space_consume(uint64_t space, arc_space_type_t type) ASSERT(type >= 0 && type < ARC_SPACE_NUMTYPES); switch (type) { + default: + break; case ARC_SPACE_DATA: ARCSTAT_INCR(arcstat_data_size, space); break; @@ -1136,6 +1138,8 @@ arc_space_return(uint64_t space, arc_space_type_t type) ASSERT(type >= 0 && type < ARC_SPACE_NUMTYPES); switch (type) { + default: + break; case ARC_SPACE_DATA: ARCSTAT_INCR(arcstat_data_size, -space); break; @@ -1646,12 +1650,12 @@ arc_evict(arc_state_t *state, uint64_t spa, int64_t bytes, boolean_t recycle, if (mru_over > 0 && arc_mru_ghost->arcs_lsize[type] > 0) { int64_t todelete = MIN(arc_mru_ghost->arcs_lsize[type], mru_over); - arc_evict_ghost(arc_mru_ghost, NULL, todelete); + arc_evict_ghost(arc_mru_ghost, 0, todelete); } else if (arc_mfu_ghost->arcs_lsize[type] > 0) { int64_t todelete = MIN(arc_mfu_ghost->arcs_lsize[type], arc_mru_ghost->arcs_size + arc_mfu_ghost->arcs_size - arc_c); - arc_evict_ghost(arc_mfu_ghost, NULL, todelete); + arc_evict_ghost(arc_mfu_ghost, 0, todelete); } } @@ -1743,13 +1747,13 @@ arc_adjust(void) if (adjustment > 0 && arc_mru->arcs_lsize[ARC_BUFC_DATA] > 0) { delta = MIN(arc_mru->arcs_lsize[ARC_BUFC_DATA], adjustment); - (void) arc_evict(arc_mru, NULL, delta, FALSE, ARC_BUFC_DATA); + (void) arc_evict(arc_mru, 0, delta, FALSE, ARC_BUFC_DATA); adjustment -= delta; } if (adjustment > 0 && arc_mru->arcs_lsize[ARC_BUFC_METADATA] > 0) { delta = MIN(arc_mru->arcs_lsize[ARC_BUFC_METADATA], adjustment); - (void) arc_evict(arc_mru, NULL, delta, FALSE, + (void) arc_evict(arc_mru, 0, delta, FALSE, ARC_BUFC_METADATA); } @@ -1761,14 +1765,14 @@ arc_adjust(void) if (adjustment > 0 && arc_mfu->arcs_lsize[ARC_BUFC_DATA] > 0) { delta = MIN(adjustment, arc_mfu->arcs_lsize[ARC_BUFC_DATA]); - (void) arc_evict(arc_mfu, NULL, delta, FALSE, ARC_BUFC_DATA); + (void) arc_evict(arc_mfu, 0, delta, FALSE, ARC_BUFC_DATA); adjustment -= delta; } if (adjustment > 0 && arc_mfu->arcs_lsize[ARC_BUFC_METADATA] > 0) { int64_t delta = MIN(adjustment, arc_mfu->arcs_lsize[ARC_BUFC_METADATA]); - (void) arc_evict(arc_mfu, NULL, delta, FALSE, + (void) arc_evict(arc_mfu, 0, delta, FALSE, ARC_BUFC_METADATA); } @@ -1780,7 +1784,7 @@ arc_adjust(void) if (adjustment > 0 && arc_mru_ghost->arcs_size > 0) { delta = MIN(arc_mru_ghost->arcs_size, adjustment); - arc_evict_ghost(arc_mru_ghost, NULL, delta); + arc_evict_ghost(arc_mru_ghost, 0, delta); } adjustment = @@ -1788,7 +1792,7 @@ arc_adjust(void) if (adjustment > 0 && arc_mfu_ghost->arcs_size > 0) { delta = MIN(arc_mfu_ghost->arcs_size, adjustment); - arc_evict_ghost(arc_mfu_ghost, NULL, delta); + arc_evict_ghost(arc_mfu_ghost, 0, delta); } } @@ -1889,9 +1893,8 @@ arc_shrink(void) static int arc_reclaim_needed(void) { - uint64_t extra; - #ifdef _KERNEL + uint64_t extra; if (needfree) return (1); @@ -2208,7 +2211,7 @@ arc_get_data_buf(arc_buf_t *buf) state = (arc_mru->arcs_lsize[type] >= size && mfu_space > arc_mfu->arcs_size) ? arc_mru : arc_mfu; } - if ((buf->b_data = arc_evict(state, NULL, size, TRUE, type)) == NULL) { + if ((buf->b_data = arc_evict(state, 0, size, TRUE, type)) == NULL) { if (type == ARC_BUFC_METADATA) { buf->b_data = zio_buf_alloc(size); arc_space_consume(size, ARC_SPACE_DATA); @@ -2559,7 +2562,7 @@ arc_read_nolock(zio_t *pio, spa_t *spa, 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); @@ -2639,7 +2642,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) { @@ -2955,9 +2958,9 @@ void arc_release(arc_buf_t *buf, void *tag) { arc_buf_hdr_t *hdr; - kmutex_t *hash_lock; + kmutex_t *hash_lock = NULL; l2arc_buf_hdr_t *l2hdr; - uint64_t buf_size; + uint64_t buf_size = 0; boolean_t released = B_FALSE; rw_enter(&buf->b_lock, RW_WRITER); @@ -3912,7 +3915,7 @@ out: * Free buffers that were tagged for destruction. */ static void -l2arc_do_free_on_write() +l2arc_do_free_on_write(void) { list_t *buflist; l2arc_data_free_t *df, *df_prev; @@ -4092,7 +4095,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); @@ -4265,11 +4268,12 @@ 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; uint64_t guid = spa_guid(spa); + int try; ASSERT(dev->l2ad_vdev != NULL); @@ -4283,7 +4287,7 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz) * Copy buffers for L2ARC writing. */ mutex_enter(&l2arc_buflist_mtx); - for (int try = 0; try <= 3; try++) { + for (try = 0; try <= 3; try++) { list = l2arc_list_locked(try, &list_lock); passed_sz = 0; diff --git a/module/zfs/dbuf.c b/module/zfs/dbuf.c index c62ebfa25..01ce2808e 100644 --- a/module/zfs/dbuf.c +++ b/module/zfs/dbuf.c @@ -110,11 +110,13 @@ dbuf_find(dnode_t *dn, uint8_t level, uint64_t blkid) { dbuf_hash_table_t *h = &dbuf_hash_table; objset_impl_t *os = dn->dn_objset; - uint64_t obj = dn->dn_object; - uint64_t hv = DBUF_HASH(os, obj, level, blkid); - uint64_t idx = hv & h->hash_table_mask; + uint64_t obj, hv, idx; dmu_buf_impl_t *db; + obj = dn->dn_object; + hv = DBUF_HASH(os, obj, level, blkid); + idx = hv & h->hash_table_mask; + mutex_enter(DBUF_HASH_MUTEX(h, idx)); for (db = h->hash_table[idx]; db != NULL; db = db->db_hash_next) { if (DBUF_EQUAL(db, os, obj, level, blkid)) { @@ -143,11 +145,13 @@ dbuf_hash_insert(dmu_buf_impl_t *db) objset_impl_t *os = db->db_objset; uint64_t obj = db->db.db_object; int level = db->db_level; - uint64_t blkid = db->db_blkid; - uint64_t hv = DBUF_HASH(os, obj, level, blkid); - uint64_t idx = hv & h->hash_table_mask; + uint64_t blkid, hv, idx; dmu_buf_impl_t *dbf; + blkid = db->db_blkid; + hv = DBUF_HASH(os, obj, level, blkid); + idx = hv & h->hash_table_mask; + mutex_enter(DBUF_HASH_MUTEX(h, idx)); for (dbf = h->hash_table[idx]; dbf != NULL; dbf = dbf->db_hash_next) { if (DBUF_EQUAL(dbf, os, obj, level, blkid)) { @@ -177,11 +181,13 @@ static void dbuf_hash_remove(dmu_buf_impl_t *db) { dbuf_hash_table_t *h = &dbuf_hash_table; - uint64_t hv = DBUF_HASH(db->db_objset, db->db.db_object, - db->db_level, db->db_blkid); - uint64_t idx = hv & h->hash_table_mask; + uint64_t hv, idx; dmu_buf_impl_t *dbf, **dbp; + hv = DBUF_HASH(db->db_objset, db->db.db_object, + db->db_level, db->db_blkid); + idx = hv & h->hash_table_mask; + /* * We musn't hold db_mtx to maintin lock ordering: * DBUF_HASH_MUTEX > db_mtx. @@ -316,7 +322,7 @@ dbuf_verify(dmu_buf_impl_t *db) * dnode_set_blksz(). */ if (db->db_level == 0 && db->db.db_object == DMU_META_DNODE_OBJECT) { - dbuf_dirty_record_t *dr = db->db_data_pending; + ASSERTV(dbuf_dirty_record_t *dr = db->db_data_pending); /* * It should only be modified in syncing context, so * make sure we only have one copy of the data. @@ -337,7 +343,8 @@ dbuf_verify(dmu_buf_impl_t *db) &dn->dn_phys->dn_blkptr[db->db_blkid]); } else { /* db is pointed to by an indirect block */ - int epb = db->db_parent->db.db_size >> SPA_BLKPTRSHIFT; + ASSERTV(int epb = db->db_parent->db.db_size >> + SPA_BLKPTRSHIFT); ASSERT3U(db->db_parent->db_level, ==, db->db_level+1); ASSERT3U(db->db_parent->db.db_object, ==, db->db.db_object); @@ -362,7 +369,7 @@ dbuf_verify(dmu_buf_impl_t *db) * data when we evict this buffer. */ if (db->db_dirtycnt == 0) { - uint64_t *buf = db->db.db_data; + ASSERTV(uint64_t *buf = db->db.db_data); int i; for (i = 0; i < db->db.db_size >> 3; i++) { @@ -1793,7 +1800,7 @@ dbuf_create_bonus(dnode_t *dn) void dbuf_add_ref(dmu_buf_impl_t *db, void *tag) { - int64_t holds = refcount_add(&db->db_holds, tag); + ASSERTV(int64_t holds = refcount_add(&db->db_holds, tag)); ASSERT(holds > 1); } @@ -2388,13 +2395,13 @@ dbuf_write_done(zio_t *zio, arc_buf_t *buf, void *vdb) ASSERT(arc_released(db->db_buf)); } } else { - dnode_t *dn = db->db_dnode; + ASSERTV(dnode_t *dn = db->db_dnode); ASSERT(list_head(&dr->dt.di.dr_children) == NULL); ASSERT3U(db->db.db_size, ==, 1<<dn->dn_phys->dn_indblkshift); if (!BP_IS_HOLE(db->db_blkptr)) { - int epbs = - dn->dn_phys->dn_indblkshift - SPA_BLKPTRSHIFT; + ASSERTV(int epbs = dn->dn_phys->dn_indblkshift - + SPA_BLKPTRSHIFT); ASSERT3U(BP_GET_LSIZE(db->db_blkptr), ==, db->db.db_size); ASSERT3U(dn->dn_phys->dn_maxblkid diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c index 785c7c621..19bf695f1 100644 --- a/module/zfs/dmu.c +++ b/module/zfs/dmu.c @@ -183,7 +183,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 read, void *tag, int *numbufsp, dmu_buf_t ***dbpp, uint32_t flags) + int rd, void *tag, int *numbufsp, dmu_buf_t ***dbpp, uint32_t flags) { dsl_pool_t *dp = NULL; dmu_buf_t **dbp; @@ -191,7 +191,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); @@ -233,7 +233,7 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset, uint64_t length, return (EIO); } /* initiate async i/o */ - if (read) { + if (rd) { rw_exit(&dn->dn_struct_rwlock); (void) dbuf_read(db, zio, dbuf_flags); rw_enter(&dn->dn_struct_rwlock, RW_READER); @@ -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 (read) { + if (rd) { 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 read, void *tag, int *numbufsp, dmu_buf_t ***dbpp) + uint64_t length, int rd, 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, read, tag, + err = dmu_buf_hold_array_by_dnode(dn, offset, length, rd, 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 read, void *tag, int *numbufsp, dmu_buf_t ***dbpp) + uint64_t length, int rd, 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, read, tag, + err = dmu_buf_hold_array_by_dnode(dn, offset, length, rd, tag, numbufsp, dbpp, DMU_READ_PREFETCH); return (err); @@ -879,9 +879,9 @@ dmu_sync_ready(zio_t *zio, arc_buf_t *buf, void *varg) blkptr_t *bp = zio->io_bp; if (!BP_IS_HOLE(bp)) { - dmu_sync_arg_t *in = varg; - dbuf_dirty_record_t *dr = in->dr; - dmu_buf_impl_t *db = dr->dr_dbuf; + ASSERTV(dmu_sync_arg_t *in = varg); + ASSERTV(dbuf_dirty_record_t *dr = in->dr); + ASSERTV(dmu_buf_impl_t *db = dr->dr_dbuf); ASSERT(BP_GET_TYPE(bp) == db->db_dnode->dn_type); ASSERT(BP_GET_LEVEL(bp) == 0); bp->blk_fill = 1; diff --git a/module/zfs/dmu_objset.c b/module/zfs/dmu_objset.c index 622cc4620..d6ad530fd 100644 --- a/module/zfs/dmu_objset.c +++ b/module/zfs/dmu_objset.c @@ -890,10 +890,12 @@ dmu_objset_sync_dnodes(list_t *list, list_t *newlist, dmu_tx_t *tx) static void ready(zio_t *zio, arc_buf_t *abuf, void *arg) { + int i; + blkptr_t *bp = zio->io_bp; - blkptr_t *bp_orig = &zio->io_bp_orig; objset_impl_t *os = arg; dnode_phys_t *dnp = &os->os_phys->os_meta_dnode; + ASSERTV(blkptr_t *bp_orig = &zio->io_bp_orig); ASSERT(bp == os->os_rootbp); ASSERT(BP_GET_TYPE(bp) == DMU_OT_OBJSET); @@ -906,7 +908,7 @@ ready(zio_t *zio, arc_buf_t *abuf, void *arg) * dnode and user/group accounting objects). */ bp->blk_fill = 0; - for (int i = 0; i < dnp->dn_nblkptr; i++) + for (i = 0; i < dnp->dn_nblkptr; i++) bp->blk_fill += dnp->dn_blkptr[i].blk_fill; if (zio->io_flags & ZIO_FLAG_IO_REWRITE) { @@ -1038,7 +1040,7 @@ dmu_objset_do_userquota_callbacks(objset_impl_t *os, dmu_tx_t *tx) { dnode_t *dn; list_t *list = &os->os_synced_dnodes; - static const char zerobuf[DN_MAX_BONUSLEN] = {0}; + ASSERTV(static const char zerobuf[DN_MAX_BONUSLEN] = {0}); ASSERT(list_head(list) == NULL || dmu_objset_userused_enabled(os)); @@ -1171,11 +1173,11 @@ dmu_objset_fsid_guid(objset_t *os) } void -dmu_objset_fast_stat(objset_t *os, dmu_objset_stats_t *stat) +dmu_objset_fast_stat(objset_t *os, dmu_objset_stats_t *st) { - stat->dds_type = os->os->os_phys->os_type; + st->dds_type = os->os->os_phys->os_type; if (os->os->os_dsl_dataset) - dsl_dataset_fast_stat(os->os->os_dsl_dataset, stat); + dsl_dataset_fast_stat(os->os->os_dsl_dataset, st); } void diff --git a/module/zfs/dmu_send.c b/module/zfs/dmu_send.c index 9ca3999dd..21e1d91d1 100644 --- a/module/zfs/dmu_send.c +++ b/module/zfs/dmu_send.c @@ -952,6 +952,28 @@ dmu_recv_abort_cleanup(dmu_recv_cookie_t *drc) } /* + * 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. */ int @@ -965,22 +987,7 @@ 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; - { - /* 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)); - } + dmu_recv_stream_cksum(drc, &ra); if (ra.byteswap) { struct drr_begin *drrb = drc->drc_drrb; diff --git a/module/zfs/dmu_traverse.c b/module/zfs/dmu_traverse.c index 89cbfad29..569bf0a3c 100644 --- a/module/zfs/dmu_traverse.c +++ b/module/zfs/dmu_traverse.c @@ -323,7 +323,7 @@ traverse_impl(spa_t *spa, uint64_t objset, blkptr_t *rootbp, uint64_t txg_start, int flags, blkptr_cb_t func, void *arg) { struct traverse_data td; - struct prefetch_data pd = { 0 }; + struct prefetch_data pd; zbookmark_t czb; int err; @@ -337,7 +337,10 @@ traverse_impl(spa_t *spa, uint64_t objset, blkptr_t *rootbp, td.td_flags = flags; pd.pd_blks_max = 100; + pd.pd_blks_fetched = 0; pd.pd_flags = flags; + pd.pd_cancel = B_FALSE; + pd.pd_exited = B_FALSE; mutex_init(&pd.pd_mtx, NULL, MUTEX_DEFAULT, NULL); cv_init(&pd.pd_cv, NULL, CV_DEFAULT, NULL); diff --git a/module/zfs/dmu_zfetch.c b/module/zfs/dmu_zfetch.c index 4d79fe98e..6b5d58528 100644 --- a/module/zfs/dmu_zfetch.c +++ b/module/zfs/dmu_zfetch.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/zfs_context.h> #include <sys/dnode.h> @@ -411,7 +411,7 @@ top: if (zs) { if (reset) { - zstream_t *remove = zs; + zstream_t *rm = zs; rc = 0; mutex_exit(&zs->zst_lock); @@ -423,7 +423,7 @@ top: */ for (zs = list_head(&zf->zf_stream); zs; zs = list_next(&zf->zf_stream, zs)) { - if (zs == remove) { + if (zs == rm) { 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 34e96cf82..5d7f1099f 100644 --- a/module/zfs/dnode.c +++ b/module/zfs/dnode.c @@ -40,7 +40,7 @@ static int free_range_compar(const void *node1, const void *node2); static kmem_cache_t *dnode_cache; -static dnode_phys_t dnode_phys_zero; +ASSERTV(static dnode_phys_t dnode_phys_zero); int zfs_default_bs = SPA_MINBLOCKSHIFT; int zfs_default_ibs = DN_MAX_INDBLKSHIFT; @@ -133,7 +133,6 @@ dnode_verify(dnode_t *dn) } if (dn->dn_phys->dn_type != DMU_OT_NONE || dn->dn_allocated_txg != 0) { int i; - ASSERT3U(dn->dn_indblkshift, >=, 0); ASSERT3U(dn->dn_indblkshift, <=, SPA_MAXBLOCKSHIFT); if (dn->dn_datablkshift) { ASSERT3U(dn->dn_datablkshift, >=, SPA_MINBLOCKSHIFT); @@ -504,11 +503,12 @@ dnode_buf_pageout(dmu_buf_t *db, void *arg) for (i = 0; i < epb; i++) { dnode_t *dn = children_dnodes[i]; - int n; if (dn == NULL) continue; #ifdef ZFS_DEBUG + { + int n; /* * If there are holds on this dnode, then there should * be holds on the dnode's containing dbuf as well; thus @@ -521,6 +521,7 @@ dnode_buf_pageout(dmu_buf_t *db, void *arg) for (n = 0; n < TXG_SIZE; n++) ASSERT(!list_link_active(&dn->dn_dirty_link[n])); + } #endif children_dnodes[i] = NULL; dnode_destroy(dn); @@ -611,10 +612,10 @@ dnode_hold_impl(objset_impl_t *os, uint64_t object, int flag, } if ((dn = children_dnodes[idx]) == NULL) { - dnode_phys_t *dnp = (dnode_phys_t *)db->db.db_data+idx; + dnode_phys_t *dnpp = (dnode_phys_t *)db->db.db_data+idx; dnode_t *winner; - dn = dnode_create(os, dnp, db, object); + dn = dnode_create(os, dnpp, db, object); winner = atomic_cas_ptr(&children_dnodes[idx], NULL, dn); if (winner != NULL) { dnode_destroy(dn); diff --git a/module/zfs/dnode_sync.c b/module/zfs/dnode_sync.c index 511552ba4..7f853af2e 100644 --- a/module/zfs/dnode_sync.c +++ b/module/zfs/dnode_sync.c @@ -317,8 +317,8 @@ dnode_sync_free_range(dnode_t *dn, uint64_t blkid, uint64_t nblks, dmu_tx_t *tx) ASSERT3U(blkid + nblks, <=, dn->dn_phys->dn_nblkptr); (void) free_blocks(dn, bp + blkid, nblks, tx); if (trunc) { - uint64_t off = (dn->dn_phys->dn_maxblkid + 1) * - (dn->dn_phys->dn_datablkszsec << SPA_MINBLOCKSHIFT); + ASSERTV(uint64_t off = (dn->dn_phys->dn_maxblkid + 1) * + (dn->dn_phys->dn_datablkszsec<<SPA_MINBLOCKSHIFT)); dn->dn_phys->dn_maxblkid = (blkid ? blkid - 1 : 0); ASSERT(off < dn->dn_phys->dn_maxblkid || dn->dn_phys->dn_maxblkid == 0 || @@ -347,8 +347,8 @@ dnode_sync_free_range(dnode_t *dn, uint64_t blkid, uint64_t nblks, dmu_tx_t *tx) dbuf_rele(db, FTAG); } if (trunc) { - uint64_t off = (dn->dn_phys->dn_maxblkid + 1) * - (dn->dn_phys->dn_datablkszsec << SPA_MINBLOCKSHIFT); + ASSERTV(uint64_t off = (dn->dn_phys->dn_maxblkid + 1) * + (dn->dn_phys->dn_datablkszsec << SPA_MINBLOCKSHIFT)); dn->dn_phys->dn_maxblkid = (blkid ? blkid - 1 : 0); ASSERT(off < dn->dn_phys->dn_maxblkid || dn->dn_phys->dn_maxblkid == 0 || @@ -512,7 +512,7 @@ dnode_sync(dnode_t *dn, dmu_tx_t *tx) dnode_phys_t *dnp = dn->dn_phys; int txgoff = tx->tx_txg & TXG_MASK; list_t *list = &dn->dn_dirty_records[txgoff]; - static const dnode_phys_t zerodn = { 0 }; + ASSERTV(static const dnode_phys_t zerodn = { 0 }); ASSERT(dmu_tx_is_syncing(tx)); ASSERT(dnp->dn_type != DMU_OT_NONE || dn->dn_allocated_txg); diff --git a/module/zfs/dsl_dataset.c b/module/zfs/dsl_dataset.c index 27b8a42f1..0999eee15 100644 --- a/module/zfs/dsl_dataset.c +++ b/module/zfs/dsl_dataset.c @@ -78,11 +78,13 @@ parent_delta(dsl_dataset_t *ds, int64_t delta) void dsl_dataset_block_born(dsl_dataset_t *ds, blkptr_t *bp, dmu_tx_t *tx) { - int used = bp_get_dasize(tx->tx_pool->dp_spa, bp); - int compressed = BP_GET_PSIZE(bp); - int uncompressed = BP_GET_UCSIZE(bp); + int used, compressed, uncompressed; int64_t delta; + used = bp_get_dasize(tx->tx_pool->dp_spa, bp); + compressed = BP_GET_PSIZE(bp); + uncompressed = BP_GET_UCSIZE(bp); + dprintf_bp(bp, "born, ds=%p\n", ds); ASSERT(dmu_tx_is_syncing(tx)); @@ -351,7 +353,7 @@ dsl_dataset_get_ref(dsl_pool_t *dp, uint64_t dsobj, void *tag, return (err); 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; @@ -988,7 +990,7 @@ dsl_dataset_destroy(dsl_dataset_t *ds, void *tag) */ if (ds->ds_phys->ds_bp.blk_fill == 0 && dmu_objset_userused_enabled(os->os)) { - uint64_t count; + ASSERTV(uint64_t count); ASSERT(zap_count(os, DMU_USERUSED_OBJECT, &count) != 0 || count == 0); @@ -1725,7 +1727,7 @@ dsl_dataset_destroy_sync(void *arg1, void *tag, cred_t *cr, dmu_tx_t *tx) cr, "dataset = %llu", ds->ds_object); if (ds->ds_phys->ds_next_clones_obj != 0) { - uint64_t count; + ASSERTV(uint64_t count); ASSERT(0 == zap_count(mos, ds->ds_phys->ds_next_clones_obj, &count) && count == 0); VERIFY(0 == dmu_object_free(mos, @@ -2027,7 +2029,7 @@ dsl_dataset_space(dsl_dataset_t *ds, boolean_t dsl_dataset_modified_since_lastsnap(dsl_dataset_t *ds) { - dsl_pool_t *dp = ds->ds_dir->dd_pool; + ASSERTV(dsl_pool_t *dp = ds->ds_dir->dd_pool); ASSERT(RW_LOCK_HELD(&dp->dp_config_rwlock) || dsl_pool_sync_context(dp)); @@ -2640,10 +2642,11 @@ dsl_dataset_promote(const char *name) dsl_dir_t *dd; dsl_pool_t *dp; dmu_object_info_t doi; - struct promotearg pa = { 0 }; + struct promotearg pa; struct promotenode *snap; int err; + bzero(&pa, sizeof(struct promotearg)); err = dsl_dataset_hold(name, FTAG, &ds); if (err) return (err); diff --git a/module/zfs/dsl_deleg.c b/module/zfs/dsl_deleg.c index 24f68b89d..0c522fbfa 100644 --- a/module/zfs/dsl_deleg.c +++ b/module/zfs/dsl_deleg.c @@ -66,7 +66,7 @@ * The ZAP OBJ is referred to as the jump object. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/dmu.h> #include <sys/dmu_objset.h> diff --git a/module/zfs/dsl_dir.c b/module/zfs/dsl_dir.c index 5d19a88fe..e3be20d80 100644 --- a/module/zfs/dsl_dir.c +++ b/module/zfs/dsl_dir.c @@ -48,7 +48,7 @@ static void dsl_dir_evict(dmu_buf_t *db, void *arg) { dsl_dir_t *dd = arg; - dsl_pool_t *dp = dd->dd_pool; + ASSERTV(dsl_pool_t *dp = dd->dd_pool;) int t; for (t = 0; t < TXG_SIZE; t++) { @@ -940,11 +940,13 @@ dsl_dir_diduse_space(dsl_dir_t *dd, dd_used_t type, dd->dd_phys->dd_used_breakdown[type] >= -used); dd->dd_phys->dd_used_breakdown[type] += used; #ifdef DEBUG - dd_used_t t; - uint64_t u = 0; - for (t = 0; t < DD_USED_NUM; t++) - u += dd->dd_phys->dd_used_breakdown[t]; - ASSERT3U(u, ==, dd->dd_phys->dd_used_bytes); + { + dd_used_t t; + uint64_t u = 0; + for (t = 0; t < DD_USED_NUM; t++) + u += dd->dd_phys->dd_used_breakdown[t]; + ASSERT3U(u, ==, dd->dd_phys->dd_used_bytes); + } #endif } if (needlock) diff --git a/module/zfs/dsl_prop.c b/module/zfs/dsl_prop.c index 7efef987d..526fb5cc4 100644 --- a/module/zfs/dsl_prop.c +++ b/module/zfs/dsl_prop.c @@ -368,7 +368,7 @@ dsl_prop_set_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx) if (psa->numints == 0) { int err = zap_remove(mos, zapobj, psa->name, tx); - ASSERT(err == 0 || err == ENOENT); + VERIFY(err == 0 || err == ENOENT); if (isint) { VERIFY(0 == dsl_prop_get_ds(ds, psa->name, 8, 1, &intval, NULL)); diff --git a/module/zfs/dsl_scrub.c b/module/zfs/dsl_scrub.c index 8a802b53a..d1d1e42d3 100644 --- a/module/zfs/dsl_scrub.c +++ b/module/zfs/dsl_scrub.c @@ -947,6 +947,7 @@ dsl_pool_scrub_clean_cb(dsl_pool_t *dp, boolean_t needs_io; int zio_flags = ZIO_FLAG_SCRUB_THREAD | ZIO_FLAG_RAW | ZIO_FLAG_CANFAIL; int zio_priority; + int d; ASSERT(bp->blk_birth > dp->dp_scrub_min_txg); @@ -971,7 +972,7 @@ dsl_pool_scrub_clean_cb(dsl_pool_t *dp, if (zb->zb_level == -1 && BP_GET_TYPE(bp) != DMU_OT_OBJSET) zio_flags |= ZIO_FLAG_SPECULATIVE; - for (int d = 0; d < BP_GET_NDVAS(bp); d++) { + for (d = 0; d < BP_GET_NDVAS(bp); d++) { vdev_t *vd = vdev_lookup_top(spa, DVA_GET_VDEV(&bp->blk_dva[d])); diff --git a/module/zfs/dsl_synctask.c b/module/zfs/dsl_synctask.c index 9bb9c4580..828911170 100644 --- a/module/zfs/dsl_synctask.c +++ b/module/zfs/dsl_synctask.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/dmu.h> #include <sys/dmu_tx.h> diff --git a/module/zfs/gzip.c b/module/zfs/gzip.c index b257d4af7..aa0254806 100644 --- a/module/zfs/gzip.c +++ b/module/zfs/gzip.c @@ -24,7 +24,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/debug.h> #include <sys/types.h> diff --git a/module/zfs/include/sys/dmu_tx.h b/module/zfs/include/sys/dmu_tx.h index 2727daaaa..2fc1fee17 100644 --- a/module/zfs/include/sys/dmu_tx.h +++ b/module/zfs/include/sys/dmu_tx.h @@ -26,7 +26,7 @@ #ifndef _SYS_DMU_TX_H #define _SYS_DMU_TX_H -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/inttypes.h> #include <sys/dmu.h> diff --git a/module/zfs/include/sys/dmu_zfetch.h b/module/zfs/include/sys/dmu_zfetch.h index c94bced93..f65209c28 100644 --- a/module/zfs/include/sys/dmu_zfetch.h +++ b/module/zfs/include/sys/dmu_zfetch.h @@ -26,7 +26,7 @@ #ifndef _DFETCH_H #define _DFETCH_H -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/zfs_context.h> diff --git a/module/zfs/include/sys/dsl_synctask.h b/module/zfs/include/sys/dsl_synctask.h index 4995bfe5a..b02243e85 100644 --- a/module/zfs/include/sys/dsl_synctask.h +++ b/module/zfs/include/sys/dsl_synctask.h @@ -26,7 +26,7 @@ #ifndef _SYS_DSL_SYNCTASK_H #define _SYS_DSL_SYNCTASK_H -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/txg.h> #include <sys/zfs_context.h> diff --git a/module/zfs/include/sys/refcount.h b/module/zfs/include/sys/refcount.h index d3fe7b1f8..c58ee8f55 100644 --- a/module/zfs/include/sys/refcount.h +++ b/module/zfs/include/sys/refcount.h @@ -26,7 +26,7 @@ #ifndef _SYS_REFCOUNT_H #define _SYS_REFCOUNT_H -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/inttypes.h> #include <sys/list.h> diff --git a/module/zfs/include/sys/rrwlock.h b/module/zfs/include/sys/rrwlock.h index 19a43c97f..798a015d1 100644 --- a/module/zfs/include/sys/rrwlock.h +++ b/module/zfs/include/sys/rrwlock.h @@ -26,7 +26,7 @@ #ifndef _SYS_RR_RW_LOCK_H #define _SYS_RR_RW_LOCK_H -#pragma ident "%Z%%M% %I% %E% SMI" + #ifdef __cplusplus extern "C" { diff --git a/module/zfs/include/sys/spa.h b/module/zfs/include/sys/spa.h index c7ae4022e..f306c7fa3 100644 --- a/module/zfs/include/sys/spa.h +++ b/module/zfs/include/sys/spa.h @@ -525,7 +525,7 @@ extern void vdev_cache_stat_fini(void); /* Initialization and termination */ extern void spa_init(int flags); extern void spa_fini(void); -extern void spa_boot_init(); +extern void spa_boot_init(void); /* properties */ extern int spa_prop_set(spa_t *spa, nvlist_t *nvp); diff --git a/module/zfs/include/sys/txg.h b/module/zfs/include/sys/txg.h index 23bdff211..ccc2cc5c6 100644 --- a/module/zfs/include/sys/txg.h +++ b/module/zfs/include/sys/txg.h @@ -26,7 +26,7 @@ #ifndef _SYS_TXG_H #define _SYS_TXG_H -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/spa.h> #include <sys/zfs_context.h> diff --git a/module/zfs/include/sys/uberblock.h b/module/zfs/include/sys/uberblock.h index 93d936ae4..7fef35541 100644 --- a/module/zfs/include/sys/uberblock.h +++ b/module/zfs/include/sys/uberblock.h @@ -27,7 +27,7 @@ #ifndef _SYS_UBERBLOCK_H #define _SYS_UBERBLOCK_H -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/spa.h> #include <sys/vdev.h> diff --git a/module/zfs/include/sys/unique.h b/module/zfs/include/sys/unique.h index 2ef3093ed..d97175286 100644 --- a/module/zfs/include/sys/unique.h +++ b/module/zfs/include/sys/unique.h @@ -26,7 +26,7 @@ #ifndef _SYS_UNIQUE_H #define _SYS_UNIQUE_H -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/zfs_context.h> diff --git a/module/zfs/include/sys/vdev_file.h b/module/zfs/include/sys/vdev_file.h index cd4967357..b4d40f9df 100644 --- a/module/zfs/include/sys/vdev_file.h +++ b/module/zfs/include/sys/vdev_file.h @@ -27,7 +27,7 @@ #ifndef _SYS_VDEV_FILE_H #define _SYS_VDEV_FILE_H -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/vdev.h> diff --git a/module/zfs/include/sys/zap_leaf.h b/module/zfs/include/sys/zap_leaf.h index 14144e059..e47987e5a 100644 --- a/module/zfs/include/sys/zap_leaf.h +++ b/module/zfs/include/sys/zap_leaf.h @@ -26,7 +26,7 @@ #ifndef _SYS_ZAP_LEAF_H #define _SYS_ZAP_LEAF_H -#pragma ident "%Z%%M% %I% %E% SMI" + #ifdef __cplusplus extern "C" { diff --git a/module/zfs/include/sys/zfs_debug.h b/module/zfs/include/sys/zfs_debug.h index 450ac1c81..02d9da131 100644 --- a/module/zfs/include/sys/zfs_debug.h +++ b/module/zfs/include/sys/zfs_debug.h @@ -26,7 +26,7 @@ #ifndef _SYS_ZFS_DEBUG_H #define _SYS_ZFS_DEBUG_H -#pragma ident "%Z%%M% %I% %E% SMI" + #ifdef __cplusplus extern "C" { diff --git a/module/zfs/include/sys/zfs_rlock.h b/module/zfs/include/sys/zfs_rlock.h index f302b663e..722c341e2 100644 --- a/module/zfs/include/sys/zfs_rlock.h +++ b/module/zfs/include/sys/zfs_rlock.h @@ -26,7 +26,7 @@ #ifndef _SYS_FS_ZFS_RLOCK_H #define _SYS_FS_ZFS_RLOCK_H -#pragma ident "%Z%%M% %I% %E% SMI" + #ifdef __cplusplus extern "C" { diff --git a/module/zfs/include/sys/zfs_znode.h b/module/zfs/include/sys/zfs_znode.h index 69f4b50f5..5d06bcd28 100644 --- a/module/zfs/include/sys/zfs_znode.h +++ b/module/zfs/include/sys/zfs_znode.h @@ -46,17 +46,17 @@ extern "C" { * Additional file level attributes, that are stored * in the upper half of zp_flags */ -#define ZFS_READONLY 0x0000000100000000 -#define ZFS_HIDDEN 0x0000000200000000 -#define ZFS_SYSTEM 0x0000000400000000 -#define ZFS_ARCHIVE 0x0000000800000000 -#define ZFS_IMMUTABLE 0x0000001000000000 -#define ZFS_NOUNLINK 0x0000002000000000 -#define ZFS_APPENDONLY 0x0000004000000000 -#define ZFS_NODUMP 0x0000008000000000 -#define ZFS_OPAQUE 0x0000010000000000 -#define ZFS_AV_QUARANTINED 0x0000020000000000 -#define ZFS_AV_MODIFIED 0x0000040000000000 +#define ZFS_READONLY 0x0000000100000000ull +#define ZFS_HIDDEN 0x0000000200000000ull +#define ZFS_SYSTEM 0x0000000400000000ull +#define ZFS_ARCHIVE 0x0000000800000000ull +#define ZFS_IMMUTABLE 0x0000001000000000ull +#define ZFS_NOUNLINK 0x0000002000000000ull +#define ZFS_APPENDONLY 0x0000004000000000ull +#define ZFS_NODUMP 0x0000008000000000ull +#define ZFS_OPAQUE 0x0000010000000000ull +#define ZFS_AV_QUARANTINED 0x0000020000000000ull +#define ZFS_AV_MODIFIED 0x0000040000000000ull #define ZFS_ATTR_SET(zp, attr, value) \ { \ @@ -307,8 +307,8 @@ extern int zfs_rezget(znode_t *); extern void zfs_zinactive(znode_t *); extern void zfs_znode_delete(znode_t *, dmu_tx_t *); extern void zfs_znode_free(znode_t *); -extern void zfs_remove_op_tables(); -extern int zfs_create_op_tables(); +extern void zfs_remove_op_tables(void); +extern int zfs_create_op_tables(void); extern int zfs_sync(vfs_t *vfsp, short flag, cred_t *cr); extern dev_t zfs_cmpldev(uint64_t); extern int zfs_get_zplprop(objset_t *os, zfs_prop_t prop, uint64_t *value); diff --git a/module/zfs/include/sys/zil.h b/module/zfs/include/sys/zil.h index 2aff8cd68..9ee9e84a0 100644 --- a/module/zfs/include/sys/zil.h +++ b/module/zfs/include/sys/zil.h @@ -360,7 +360,7 @@ typedef void zil_parse_blk_func_t(zilog_t *zilog, blkptr_t *bp, void *arg, uint64_t txg); typedef void zil_parse_lr_func_t(zilog_t *zilog, lr_t *lr, void *arg, uint64_t txg); -typedef int zil_replay_func_t(); +typedef int zil_replay_func_t(void *, char *, boolean_t); typedef int zil_get_data_t(void *arg, lr_write_t *lr, char *dbuf, zio_t *zio); extern uint64_t zil_parse(zilog_t *zilog, zil_parse_blk_func_t *parse_blk_func, diff --git a/module/zfs/include/sys/zio_compress.h b/module/zfs/include/sys/zio_compress.h index 66ee8d45b..9470eccb4 100644 --- a/module/zfs/include/sys/zio_compress.h +++ b/module/zfs/include/sys/zio_compress.h @@ -27,7 +27,7 @@ #ifndef _SYS_ZIO_COMPRESS_H #define _SYS_ZIO_COMPRESS_H -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/zio.h> diff --git a/module/zfs/include/sys/zvol.h b/module/zfs/include/sys/zvol.h index 06adc667e..74ebc83e0 100644 --- a/module/zfs/include/sys/zvol.h +++ b/module/zfs/include/sys/zvol.h @@ -27,7 +27,7 @@ #ifndef _SYS_ZVOL_H #define _SYS_ZVOL_H -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/zfs_context.h> diff --git a/module/zfs/lzjb.c b/module/zfs/lzjb.c index 7fcde8475..ea8fabd6f 100644 --- a/module/zfs/lzjb.c +++ b/module/zfs/lzjb.c @@ -24,7 +24,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + /* * We keep our own copy of this algorithm for 2 main reasons: @@ -51,7 +51,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; uint16_t *hp; @@ -104,7 +104,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/metaslab.c b/module/zfs/metaslab.c index 77556ac5d..91ab791f0 100644 --- a/module/zfs/metaslab.c +++ b/module/zfs/metaslab.c @@ -258,6 +258,7 @@ metaslab_block_picker(avl_tree_t *t, uint64_t *cursor, uint64_t size, return (metaslab_block_picker(t, cursor, size, align)); } +#if 0 /* * ========================================================================== * The first-fit block allocator @@ -310,6 +311,7 @@ static space_map_ops_t metaslab_ff_ops = { metaslab_ff_free, NULL /* maxsize */ }; +#endif /* * Dynamic block allocator - @@ -1154,7 +1156,7 @@ metaslab_alloc(spa_t *spa, metaslab_class_t *mc, uint64_t psize, blkptr_t *bp, { dva_t *dva = bp->blk_dva; dva_t *hintdva = hintbp->blk_dva; - int error = 0; + int d, error = 0; ASSERT(bp->blk_birth == 0); @@ -1169,7 +1171,7 @@ metaslab_alloc(spa_t *spa, metaslab_class_t *mc, uint64_t psize, blkptr_t *bp, ASSERT(BP_GET_NDVAS(bp) == 0); ASSERT(hintbp == NULL || ndvas <= BP_GET_NDVAS(hintbp)); - for (int d = 0; d < ndvas; d++) { + for (d = 0; d < ndvas; d++) { error = metaslab_alloc_dva(spa, mc, psize, dva, d, hintdva, txg, flags); if (error) { @@ -1195,14 +1197,14 @@ void metaslab_free(spa_t *spa, const blkptr_t *bp, uint64_t txg, boolean_t now) { const dva_t *dva = bp->blk_dva; - int ndvas = BP_GET_NDVAS(bp); + int d, ndvas = BP_GET_NDVAS(bp); ASSERT(!BP_IS_HOLE(bp)); ASSERT(!now || bp->blk_birth >= spa->spa_syncing_txg); spa_config_enter(spa, SCL_FREE, FTAG, RW_READER); - for (int d = 0; d < ndvas; d++) + for (d = 0; d < ndvas; d++) metaslab_free_dva(spa, &dva[d], txg, now); spa_config_exit(spa, SCL_FREE, FTAG); @@ -1213,7 +1215,7 @@ metaslab_claim(spa_t *spa, const blkptr_t *bp, uint64_t txg) { const dva_t *dva = bp->blk_dva; int ndvas = BP_GET_NDVAS(bp); - int error = 0; + int d, error = 0; ASSERT(!BP_IS_HOLE(bp)); @@ -1228,7 +1230,7 @@ metaslab_claim(spa_t *spa, const blkptr_t *bp, uint64_t txg) spa_config_enter(spa, SCL_ALLOC, FTAG, RW_READER); - for (int d = 0; d < ndvas; d++) + for (d = 0; d < ndvas; d++) if ((error = metaslab_claim_dva(spa, &dva[d], txg)) != 0) break; diff --git a/module/zfs/refcount.c b/module/zfs/refcount.c index 2a52cb16d..6c359ffea 100644 --- a/module/zfs/refcount.c +++ b/module/zfs/refcount.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/zfs_context.h> #include <sys/refcount.h> @@ -113,7 +113,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/rrwlock.c b/module/zfs/rrwlock.c index 710685dbc..1bb8a285b 100644 --- a/module/zfs/rrwlock.c +++ b/module/zfs/rrwlock.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/refcount.h> #include <sys/rrwlock.h> @@ -118,7 +118,7 @@ rrn_find_and_remove(rrwlock_t *rrl) rrw_node_t *prev = NULL; if (refcount_count(&rrl->rr_linked_rcount) == 0) - return (NULL); + return (B_FALSE); for (rn = tsd_get(rrw_tsd_key); rn != NULL; rn = rn->rn_next) { if (rn->rn_rrl == rrl) { diff --git a/module/zfs/sha256.c b/module/zfs/sha256.c index ca7076cb6..691920aa6 100644 --- a/module/zfs/sha256.c +++ b/module/zfs/sha256.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/zfs_context.h> #include <sys/zio.h> diff --git a/module/zfs/spa.c b/module/zfs/spa.c index 912a8daeb..e13ef765a 100644 --- a/module/zfs/spa.c +++ b/module/zfs/spa.c @@ -307,7 +307,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) { @@ -432,6 +432,8 @@ spa_prop_validate(spa_t *spa, nvlist_t *props) strcmp(slash, "/..") == 0) error = EINVAL; break; + default: + break; } if (error) @@ -571,6 +573,8 @@ spa_get_errlists(spa_t *spa, avl_tree_t *last, avl_tree_t *scrub) static void spa_activate(spa_t *spa, int mode) { + int t, q; + ASSERT(spa->spa_state == POOL_STATE_UNINITIALIZED); spa->spa_state = POOL_STATE_ACTIVE; @@ -579,9 +583,9 @@ spa_activate(spa_t *spa, int mode) spa->spa_normal_class = metaslab_class_create(zfs_metaslab_ops); spa->spa_log_class = metaslab_class_create(zfs_metaslab_ops); - for (int t = 0; t < ZIO_TYPES; t++) { + for (t = 0; t < ZIO_TYPES; t++) { const zio_taskq_info_t *ztip = &zio_taskqs[t]; - for (int q = 0; q < ZIO_TASKQ_TYPES; q++) { + for (q = 0; q < ZIO_TASKQ_TYPES; q++) { enum zti_modes mode = ztip->zti_nthreads[q].zti_mode; uint_t value = ztip->zti_nthreads[q].zti_value; char name[32]; @@ -645,6 +649,8 @@ spa_activate(spa_t *spa, int mode) static void spa_deactivate(spa_t *spa) { + int t, q; + ASSERT(spa->spa_sync_on == B_FALSE); ASSERT(spa->spa_dsl_pool == NULL); ASSERT(spa->spa_root_vdev == NULL); @@ -656,8 +662,8 @@ spa_deactivate(spa_t *spa) list_destroy(&spa->spa_config_dirty_list); list_destroy(&spa->spa_state_dirty_list); - for (int t = 0; t < ZIO_TYPES; t++) { - for (int q = 0; q < ZIO_TASKQ_TYPES; q++) { + for (t = 0; t < ZIO_TYPES; t++) { + for (q = 0; q < ZIO_TASKQ_TYPES; q++) { taskq_destroy(spa->spa_zio_taskq[t][q]); spa->spa_zio_taskq[t][q] = NULL; } @@ -694,6 +700,7 @@ spa_config_parse(spa_t *spa, vdev_t **vdp, nvlist_t *nv, vdev_t *parent, nvlist_t **child; uint_t children; int error; + int c; if ((error = vdev_alloc(spa, vdp, nv, parent, id, atype)) != 0) return (error); @@ -713,7 +720,7 @@ spa_config_parse(spa_t *spa, vdev_t **vdp, nvlist_t *nv, vdev_t *parent, return (EINVAL); } - for (int c = 0; c < children; c++) { + for (c = 0; c < children; c++) { vdev_t *vd; if ((error = spa_config_parse(spa, &vd, child[c], *vdp, c, atype)) != 0) { @@ -942,7 +949,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); @@ -1085,7 +1092,9 @@ load_nvlist(spa_t *spa, uint64_t obj, nvlist_t **value) static void spa_check_removed(vdev_t *vd) { - for (int c = 0; c < vd->vdev_children; c++) + int c; + + for (c = 0; c < vd->vdev_children; c++) spa_check_removed(vd->vdev_child[c]); if (vd->vdev_ops->vdev_op_leaf && vdev_is_dead(vd)) { @@ -1105,13 +1114,14 @@ spa_load_log_state(spa_t *spa) uint64_t is_log; uint_t children; vdev_t *rvd = spa->spa_root_vdev; + int c; VERIFY(load_nvlist(spa, spa->spa_config_object, &nv) == 0); VERIFY(nvlist_lookup_nvlist(nv, ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0); VERIFY(nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN, &child, &children) == 0); - for (int c = 0; c < children; c++) { + for (c = 0; c < children; c++) { vdev_t *tvd = rvd->vdev_child[c]; if (nvlist_lookup_uint64(child[c], ZPOOL_CONFIG_IS_LOG, @@ -1128,6 +1138,8 @@ int spa_check_logs(spa_t *spa) { switch (spa->spa_log_state) { + default: + break; case SPA_LOG_MISSING: /* need to recheck in case slog has been restored */ case SPA_LOG_UNKNOWN: @@ -1549,6 +1561,7 @@ spa_load(spa_t *spa, nvlist_t *config, spa_load_state_t state, int mosconfig) if (spa_writeable(spa)) { dmu_tx_t *tx; int need_update = B_FALSE; + int c; ASSERT(state != SPA_LOAD_TRYIMPORT); @@ -1579,7 +1592,7 @@ spa_load(spa_t *spa, nvlist_t *config, spa_load_state_t state, int mosconfig) state == SPA_LOAD_IMPORT) need_update = B_TRUE; - for (int c = 0; c < rvd->vdev_children; c++) + for (c = 0; c < rvd->vdev_children; c++) if (rvd->vdev_child[c]->vdev_ms_array == 0) need_update = B_TRUE; @@ -2091,6 +2104,7 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props, nvlist_t **spares, **l2cache; uint_t nspares, nl2cache; uint64_t version; + int c; /* * If this pool already exists, return failure. @@ -2148,7 +2162,7 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props, (error = vdev_create(rvd, txg, B_FALSE)) == 0 && (error = spa_validate_aux(spa, nvroot, txg, VDEV_ALLOC_ADD)) == 0) { - for (int c = 0; c < rvd->vdev_children; c++) { + for (c = 0; c < rvd->vdev_children; c++) { vdev_metaslab_set_size(rvd->vdev_child[c]); vdev_expand(rvd->vdev_child[c], txg); } @@ -2333,7 +2347,9 @@ spa_generate_rootconf(char *devpath, char *devid, uint64_t *guid) static void spa_alt_rootvdev(vdev_t *vd, vdev_t **avd, uint64_t *txg) { - for (int c = 0; c < vd->vdev_children; c++) + int c; + + for (c = 0; c < vd->vdev_children; c++) spa_alt_rootvdev(vd->vdev_child[c], avd, txg); if (vd->vdev_ops->vdev_op_leaf) { @@ -2892,6 +2908,7 @@ spa_vdev_add(spa_t *spa, nvlist_t *nvroot) vdev_t *vd, *tvd; nvlist_t **spares, **l2cache; uint_t nspares, nl2cache; + int c; txg = spa_vdev_enter(spa); @@ -2926,7 +2943,7 @@ spa_vdev_add(spa_t *spa, nvlist_t *nvroot) /* * Transfer each new top-level vdev from vd to rvd. */ - for (int c = 0; c < vd->vdev_children; c++) { + for (c = 0; c < vd->vdev_children; c++) { tvd = vd->vdev_child[c]; vdev_remove_child(vd, tvd); tvd->vdev_id = rvd->vdev_children; @@ -2987,7 +3004,7 @@ int spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing) { uint64_t txg, open_txg; - vdev_t *rvd = spa->spa_root_vdev; + ASSERTV(vdev_t *rvd = spa->spa_root_vdev;) vdev_t *oldvd, *newvd, *newrootvd, *pvd, *tvd; vdev_ops_t *pvops; dmu_tx_t *tx; @@ -3179,11 +3196,12 @@ spa_vdev_detach(spa_t *spa, uint64_t guid, uint64_t pguid, int replace_done) { uint64_t txg; int error; - vdev_t *rvd = spa->spa_root_vdev; + 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; size_t len; + int t; txg = spa_vdev_enter(spa); @@ -3350,7 +3368,7 @@ spa_vdev_detach(spa_t *spa, uint64_t guid, uint64_t pguid, int replace_done) * But first make sure we're not on any *other* txg's DTL list, to * prevent vd from being accessed after it's freed. */ - for (int t = 0; t < TXG_SIZE; t++) + for (t = 0; t < TXG_SIZE; t++) (void) txg_list_remove_this(&tvd->vdev_dtl_list, vd, t); vd->vdev_detached = B_TRUE; vdev_dirty(tvd, VDD_DTL, vd, txg); @@ -3388,7 +3406,9 @@ spa_vdev_detach(spa_t *spa, uint64_t guid, uint64_t pguid, int replace_done) static nvlist_t * spa_nvlist_lookup_by_guid(nvlist_t **nvpp, int count, uint64_t target_guid) { - for (int i = 0; i < count; i++) { + int i; + + for (i = 0; i < count; i++) { uint64_t guid; VERIFY(nvlist_lookup_uint64(nvpp[i], ZPOOL_CONFIG_GUID, @@ -3406,11 +3426,12 @@ spa_vdev_remove_aux(nvlist_t *config, char *name, nvlist_t **dev, int count, nvlist_t *dev_to_remove) { nvlist_t **newdev = NULL; + int i, j; if (count > 1) newdev = kmem_alloc((count - 1) * sizeof (void *), KM_SLEEP); - for (int i = 0, j = 0; i < count; i++) { + for (i = 0, j = 0; i < count; i++) { if (dev[i] == dev_to_remove) continue; VERIFY(nvlist_dup(dev[i], &newdev[j++], KM_SLEEP) == 0); @@ -3419,7 +3440,7 @@ spa_vdev_remove_aux(nvlist_t *config, char *name, nvlist_t **dev, int count, VERIFY(nvlist_remove(config, name, DATA_TYPE_NVLIST_ARRAY) == 0); VERIFY(nvlist_add_nvlist_array(config, name, newdev, count - 1) == 0); - for (int i = 0; i < count - 1; i++) + for (i = 0; i < count - 1; i++) nvlist_free(newdev[i]); if (count > 1) @@ -3498,8 +3519,9 @@ static vdev_t * spa_vdev_resilver_done_hunt(vdev_t *vd) { vdev_t *newvd, *oldvd; + int c; - for (int c = 0; c < vd->vdev_children; c++) { + for (c = 0; c < vd->vdev_children; c++) { oldvd = spa_vdev_resilver_done_hunt(vd->vdev_child[c]); if (oldvd != NULL) return (oldvd); @@ -3663,6 +3685,8 @@ spa_scrub(spa_t *spa, pool_scrub_type_t type) static void spa_async_remove(spa_t *spa, vdev_t *vd) { + int c; + if (vd->vdev_remove_wanted) { vd->vdev_remove_wanted = 0; vdev_set_state(vd, B_FALSE, VDEV_STATE_REMOVED, VDEV_AUX_NONE); @@ -3670,19 +3694,21 @@ spa_async_remove(spa_t *spa, vdev_t *vd) vdev_state_dirty(vd->vdev_top); } - for (int c = 0; c < vd->vdev_children; c++) + for (c = 0; c < vd->vdev_children; c++) spa_async_remove(spa, vd->vdev_child[c]); } static void spa_async_probe(spa_t *spa, vdev_t *vd) { + int c; + if (vd->vdev_probe_wanted) { vd->vdev_probe_wanted = 0; vdev_reopen(vd); /* vdev_open() does the actual probe */ } - for (int c = 0; c < vd->vdev_children; c++) + for (c = 0; c < vd->vdev_children; c++) spa_async_probe(spa, vd->vdev_child[c]); } @@ -3692,11 +3718,12 @@ spa_async_autoexpand(spa_t *spa, vdev_t *vd) sysevent_id_t eid; nvlist_t *attr; char *physpath; + int c; if (!spa->spa_autoexpand) return; - for (int c = 0; c < vd->vdev_children; c++) { + for (c = 0; c < vd->vdev_children; c++) { vdev_t *cvd = vd->vdev_child[c]; spa_async_autoexpand(spa, cvd); } @@ -3720,7 +3747,7 @@ spa_async_autoexpand(spa_t *spa, vdev_t *vd) static void spa_async_thread(spa_t *spa) { - int tasks; + int tasks, i; ASSERT(spa->spa_sync_on); @@ -3768,9 +3795,9 @@ spa_async_thread(spa_t *spa) if (tasks & SPA_ASYNC_REMOVE) { spa_vdev_state_enter(spa); spa_async_remove(spa, spa->spa_root_vdev); - for (int i = 0; i < spa->spa_l2cache.sav_count; i++) + for (i = 0; i < spa->spa_l2cache.sav_count; i++) spa_async_remove(spa, spa->spa_l2cache.sav_vdevs[i]); - for (int i = 0; i < spa->spa_spares.sav_count; i++) + for (i = 0; i < spa->spa_spares.sav_count; i++) spa_async_remove(spa, spa->spa_spares.sav_vdevs[i]); (void) spa_vdev_state_exit(spa, NULL, 0); } @@ -4129,6 +4156,7 @@ spa_sync(spa_t *spa, uint64_t txg) dmu_tx_t *tx; int dirty_vdevs; int error; + int c; /* * Lock out configuration changes. @@ -4259,7 +4287,7 @@ spa_sync(spa_t *spa, uint64_t txg) int children = rvd->vdev_children; int c0 = spa_get_random(children); - for (int c = 0; c < children; c++) { + for (c = 0; c < children; c++) { vd = rvd->vdev_child[(c0 + c) % children]; if (vd->vdev_ms_array == 0 || vd->vdev_islog) continue; diff --git a/module/zfs/spa_boot.c b/module/zfs/spa_boot.c index 49e9e5019..053903cac 100644 --- a/module/zfs/spa_boot.c +++ b/module/zfs/spa_boot.c @@ -24,7 +24,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/spa.h> #include <sys/sunddi.h> diff --git a/module/zfs/spa_history.c b/module/zfs/spa_history.c index 97d97d847..633c7d4a7 100644 --- a/module/zfs/spa_history.c +++ b/module/zfs/spa_history.c @@ -174,7 +174,7 @@ spa_history_write(spa_t *spa, void *buf, uint64_t len, spa_history_phys_t *shpp, } static char * -spa_history_zone() +spa_history_zone(void) { #ifdef _KERNEL return (curproc->p_zone->zone_name); diff --git a/module/zfs/spa_misc.c b/module/zfs/spa_misc.c index aea3f5625..84434d530 100644 --- a/module/zfs/spa_misc.c +++ b/module/zfs/spa_misc.c @@ -255,7 +255,9 @@ int zfs_recover = 0; static void spa_config_lock_init(spa_t *spa) { - for (int i = 0; i < SCL_LOCKS; i++) { + int i; + + for (i = 0; i < SCL_LOCKS; i++) { spa_config_lock_t *scl = &spa->spa_config_lock[i]; mutex_init(&scl->scl_lock, NULL, MUTEX_DEFAULT, NULL); cv_init(&scl->scl_cv, NULL, CV_DEFAULT, NULL); @@ -268,7 +270,9 @@ spa_config_lock_init(spa_t *spa) static void spa_config_lock_destroy(spa_t *spa) { - for (int i = 0; i < SCL_LOCKS; i++) { + int i; + + for (i = 0; i < SCL_LOCKS; i++) { spa_config_lock_t *scl = &spa->spa_config_lock[i]; mutex_destroy(&scl->scl_lock); cv_destroy(&scl->scl_cv); @@ -281,7 +285,9 @@ spa_config_lock_destroy(spa_t *spa) int spa_config_tryenter(spa_t *spa, int locks, void *tag, krw_t rw) { - for (int i = 0; i < SCL_LOCKS; i++) { + int i; + + for (i = 0; i < SCL_LOCKS; i++) { spa_config_lock_t *scl = &spa->spa_config_lock[i]; if (!(locks & (1 << i))) continue; @@ -310,7 +316,9 @@ spa_config_tryenter(spa_t *spa, int locks, void *tag, krw_t rw) void spa_config_enter(spa_t *spa, int locks, void *tag, krw_t rw) { - for (int i = 0; i < SCL_LOCKS; i++) { + int i; + + for (i = 0; i < SCL_LOCKS; i++) { spa_config_lock_t *scl = &spa->spa_config_lock[i]; if (!(locks & (1 << i))) continue; @@ -336,7 +344,9 @@ spa_config_enter(spa_t *spa, int locks, void *tag, krw_t rw) void spa_config_exit(spa_t *spa, int locks, void *tag) { - for (int i = SCL_LOCKS - 1; i >= 0; i--) { + int i; + + for (i = SCL_LOCKS - 1; i >= 0; i--) { spa_config_lock_t *scl = &spa->spa_config_lock[i]; if (!(locks & (1 << i))) continue; @@ -355,9 +365,9 @@ spa_config_exit(spa_t *spa, int locks, void *tag) int spa_config_held(spa_t *spa, int locks, krw_t rw) { - int locks_held = 0; + int i, locks_held = 0; - for (int i = 0; i < SCL_LOCKS; i++) { + for (i = 0; i < SCL_LOCKS; i++) { spa_config_lock_t *scl = &spa->spa_config_lock[i]; if (!(locks & (1 << i))) continue; @@ -385,7 +395,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)); @@ -1336,7 +1346,7 @@ spa_busy(void) } void -spa_boot_init() +spa_boot_init(void) { spa_config_load(); } diff --git a/module/zfs/txg.c b/module/zfs/txg.c index e3c0e2a13..d87b053ed 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 time) +txg_thread_wait(tx_state_t *tx, callb_cpr_t *cpr, kcondvar_t *cv, uint64_t wt) { CALLB_CPR_SAFE_BEGIN(cpr); - if (time) - (void) cv_timedwait(cv, &tx->tx_sync_lock, lbolt + time); + if (wt) + (void) cv_timedwait(cv, &tx->tx_sync_lock, lbolt + wt); else cv_wait(cv, &tx->tx_sync_lock); diff --git a/module/zfs/uberblock.c b/module/zfs/uberblock.c index 34d7e0c3a..68d9b1fc2 100644 --- a/module/zfs/uberblock.c +++ b/module/zfs/uberblock.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/zfs_context.h> #include <sys/uberblock_impl.h> diff --git a/module/zfs/unique.c b/module/zfs/unique.c index fbe7b619a..8c1d2e2f9 100644 --- a/module/zfs/unique.c +++ b/module/zfs/unique.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/zfs_context.h> #include <sys/avl.h> diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c index b14941444..574627d79 100644 --- a/module/zfs/vdev.c +++ b/module/zfs/vdev.c @@ -84,8 +84,9 @@ vdev_default_asize(vdev_t *vd, uint64_t psize) { uint64_t asize = P2ROUNDUP(psize, 1ULL << vd->vdev_top->vdev_ashift); uint64_t csize; + int c; - for (int c = 0; c < vd->vdev_children; c++) { + for (c = 0; c < vd->vdev_children; c++) { csize = vdev_psize_to_asize(vd->vdev_child[c], psize); asize = MAX(asize, csize); } @@ -131,9 +132,10 @@ vdev_get_min_asize(vdev_t *vd) void vdev_set_min_asize(vdev_t *vd) { + int c; vd->vdev_min_asize = vdev_get_min_asize(vd); - for (int c = 0; c < vd->vdev_children; c++) + for (c = 0; c < vd->vdev_children; c++) vdev_set_min_asize(vd->vdev_child[c]); } @@ -156,11 +158,12 @@ vdev_t * vdev_lookup_by_guid(vdev_t *vd, uint64_t guid) { vdev_t *mvd; + int c; if (vd->vdev_guid == guid) return (vd); - for (int c = 0; c < vd->vdev_children; c++) + for (c = 0; c < vd->vdev_children; c++) if ((mvd = vdev_lookup_by_guid(vd->vdev_child[c], guid)) != NULL) return (mvd); @@ -257,16 +260,17 @@ vdev_compact_children(vdev_t *pvd) vdev_t **newchild, *cvd; int oldc = pvd->vdev_children; int newc; + int c; ASSERT(spa_config_held(pvd->vdev_spa, SCL_ALL, RW_WRITER) == SCL_ALL); - for (int c = newc = 0; c < oldc; c++) + for (c = newc = 0; c < oldc; c++) if (pvd->vdev_child[c]) newc++; newchild = kmem_alloc(newc * sizeof (vdev_t *), KM_SLEEP); - for (int c = newc = 0; c < oldc; c++) { + for (c = newc = 0; c < oldc; c++) { if ((cvd = pvd->vdev_child[c]) != NULL) { newchild[newc] = cvd; cvd->vdev_id = newc++; @@ -285,6 +289,7 @@ static vdev_t * vdev_alloc_common(spa_t *spa, uint_t id, uint64_t guid, vdev_ops_t *ops) { vdev_t *vd; + int t; vd = kmem_zalloc(sizeof (vdev_t), KM_SLEEP); @@ -322,7 +327,7 @@ vdev_alloc_common(spa_t *spa, uint_t id, uint64_t guid, vdev_ops_t *ops) mutex_init(&vd->vdev_dtl_lock, NULL, MUTEX_DEFAULT, NULL); mutex_init(&vd->vdev_stat_lock, NULL, MUTEX_DEFAULT, NULL); mutex_init(&vd->vdev_probe_lock, NULL, MUTEX_DEFAULT, NULL); - for (int t = 0; t < DTL_TYPES; t++) { + for (t = 0; t < DTL_TYPES; t++) { space_map_create(&vd->vdev_dtl[t], 0, -1ULL, 0, &vd->vdev_dtl_lock); } @@ -531,6 +536,7 @@ vdev_alloc(spa_t *spa, vdev_t **vdp, nvlist_t *nv, vdev_t *parent, uint_t id, void vdev_free(vdev_t *vd) { + int c, t; spa_t *spa = vd->vdev_spa; /* @@ -544,7 +550,7 @@ vdev_free(vdev_t *vd) /* * Free all children. */ - for (int c = 0; c < vd->vdev_children; c++) + for (c = 0; c < vd->vdev_children; c++) vdev_free(vd->vdev_child[c]); ASSERT(vd->vdev_child == NULL); @@ -591,7 +597,7 @@ vdev_free(vdev_t *vd) txg_list_destroy(&vd->vdev_dtl_list); mutex_enter(&vd->vdev_dtl_lock); - for (int t = 0; t < DTL_TYPES; t++) { + for (t = 0; t < DTL_TYPES; t++) { space_map_unload(&vd->vdev_dtl[t]); space_map_destroy(&vd->vdev_dtl[t]); } @@ -674,12 +680,14 @@ vdev_top_transfer(vdev_t *svd, vdev_t *tvd) static void vdev_top_update(vdev_t *tvd, vdev_t *vd) { + int c; + if (vd == NULL) return; vd->vdev_top = tvd; - for (int c = 0; c < vd->vdev_children; c++) + for (c = 0; c < vd->vdev_children; c++) vdev_top_update(tvd, vd->vdev_child[c]); } @@ -912,6 +920,7 @@ vdev_probe(vdev_t *vd, zio_t *zio) spa_t *spa = vd->vdev_spa; vdev_probe_stats_t *vps = NULL; zio_t *pio; + int l; ASSERT(vd->vdev_ops->vdev_op_leaf); @@ -977,7 +986,7 @@ vdev_probe(vdev_t *vd, zio_t *zio) return (NULL); } - for (int l = 1; l < VDEV_LABELS; l++) { + for (l = 1; l < VDEV_LABELS; l++) { zio_nowait(zio_read_phys(pio, vd, vdev_label_offset(vd->vdev_psize, l, offsetof(vdev_label_t, vl_pad2)), @@ -1004,6 +1013,7 @@ vdev_open(vdev_t *vd) uint64_t osize = 0; uint64_t asize, psize; uint64_t ashift = 0; + int c; ASSERT(spa_config_held(spa, SCL_STATE_ALL, RW_WRITER) == SCL_STATE_ALL); @@ -1052,7 +1062,7 @@ vdev_open(vdev_t *vd) vd->vdev_state = VDEV_STATE_HEALTHY; } - for (int c = 0; c < vd->vdev_children; c++) { + for (c = 0; c < vd->vdev_children; c++) { if (vd->vdev_child[c]->vdev_state != VDEV_STATE_HEALTHY) { vdev_set_state(vd, B_TRUE, VDEV_STATE_DEGRADED, VDEV_AUX_NONE); @@ -1161,8 +1171,9 @@ vdev_validate(vdev_t *vd) nvlist_t *label; uint64_t guid, top_guid; uint64_t state; + int c; - for (int c = 0; c < vd->vdev_children; c++) + for (c = 0; c < vd->vdev_children; c++) if (vdev_validate(vd->vdev_child[c]) != 0) return (EBADF); @@ -1239,7 +1250,7 @@ vdev_validate(vdev_t *vd) void vdev_close(vdev_t *vd) { - spa_t *spa = vd->vdev_spa; + ASSERTV(spa_t *spa = vd->vdev_spa); ASSERT(spa_config_held(spa, SCL_STATE_ALL, RW_WRITER) == SCL_STATE_ALL); @@ -1436,11 +1447,11 @@ vdev_dtl_reassess(vdev_t *vd, uint64_t txg, uint64_t scrub_txg, int scrub_done) { spa_t *spa = vd->vdev_spa; avl_tree_t reftree; - int minref; + int c, t, minref; ASSERT(spa_config_held(spa, SCL_ALL, RW_READER) != 0); - for (int c = 0; c < vd->vdev_children; c++) + for (c = 0; c < vd->vdev_children; c++) vdev_dtl_reassess(vd->vdev_child[c], txg, scrub_txg, scrub_done); @@ -1498,7 +1509,7 @@ vdev_dtl_reassess(vdev_t *vd, uint64_t txg, uint64_t scrub_txg, int scrub_done) } mutex_enter(&vd->vdev_dtl_lock); - for (int t = 0; t < DTL_TYPES; t++) { + for (t = 0; t < DTL_TYPES; t++) { if (t == DTL_SCRUB) continue; /* leaf vdevs only */ if (t == DTL_PARTIAL) @@ -1508,7 +1519,7 @@ vdev_dtl_reassess(vdev_t *vd, uint64_t txg, uint64_t scrub_txg, int scrub_done) else minref = vd->vdev_children; /* any kind of mirror */ space_map_ref_create(&reftree); - for (int c = 0; c < vd->vdev_children; c++) { + for (c = 0; c < vd->vdev_children; c++) { vdev_t *cvd = vd->vdev_child[c]; mutex_enter(&cvd->vdev_dtl_lock); space_map_ref_add_map(&reftree, &cvd->vdev_dtl[t], 1); @@ -1565,8 +1576,7 @@ vdev_dtl_sync(vdev_t *vd, uint64_t txg) if (vd->vdev_detached) { if (smo->smo_object != 0) { - int err = dmu_object_free(mos, smo->smo_object, tx); - ASSERT3U(err, ==, 0); + VERIFY(0 == dmu_object_free(mos, smo->smo_object, tx)); smo->smo_object = 0; } dmu_tx_commit(tx); @@ -1651,6 +1661,7 @@ vdev_resilver_needed(vdev_t *vd, uint64_t *minp, uint64_t *maxp) boolean_t needed = B_FALSE; uint64_t thismin = UINT64_MAX; uint64_t thismax = 0; + int c; if (vd->vdev_children == 0) { mutex_enter(&vd->vdev_dtl_lock); @@ -1666,7 +1677,7 @@ vdev_resilver_needed(vdev_t *vd, uint64_t *minp, uint64_t *maxp) } mutex_exit(&vd->vdev_dtl_lock); } else { - for (int c = 0; c < vd->vdev_children; c++) { + for (c = 0; c < vd->vdev_children; c++) { vdev_t *cvd = vd->vdev_child[c]; uint64_t cmin, cmax; @@ -1688,10 +1699,12 @@ vdev_resilver_needed(vdev_t *vd, uint64_t *minp, uint64_t *maxp) void vdev_load(vdev_t *vd) { + int c; + /* * Recursively load all children. */ - for (int c = 0; c < vd->vdev_children; c++) + for (c = 0; c < vd->vdev_children; c++) vdev_load(vd->vdev_child[c]); /* @@ -2011,6 +2024,7 @@ void vdev_clear(spa_t *spa, vdev_t *vd) { vdev_t *rvd = spa->spa_root_vdev; + int c; ASSERT(spa_config_held(spa, SCL_STATE_ALL, RW_WRITER) == SCL_STATE_ALL); @@ -2021,7 +2035,7 @@ vdev_clear(spa_t *spa, vdev_t *vd) vd->vdev_stat.vs_write_errors = 0; vd->vdev_stat.vs_checksum_errors = 0; - for (int c = 0; c < vd->vdev_children; c++) + for (c = 0; c < vd->vdev_children; c++) vdev_clear(spa, vd->vdev_child[c]); /* @@ -2108,6 +2122,7 @@ void vdev_get_stats(vdev_t *vd, vdev_stat_t *vs) { vdev_t *rvd = vd->vdev_spa->spa_root_vdev; + int c, t; mutex_enter(&vd->vdev_stat_lock); bcopy(&vd->vdev_stat, vs, sizeof (*vs)); @@ -2124,12 +2139,12 @@ vdev_get_stats(vdev_t *vd, vdev_stat_t *vs) * over all top-level vdevs (i.e. the direct children of the root). */ if (vd == rvd) { - for (int c = 0; c < rvd->vdev_children; c++) { + for (c = 0; c < rvd->vdev_children; c++) { vdev_t *cvd = rvd->vdev_child[c]; vdev_stat_t *cvs = &cvd->vdev_stat; mutex_enter(&vd->vdev_stat_lock); - for (int t = 0; t < ZIO_TYPES; t++) { + for (t = 0; t < ZIO_TYPES; t++) { vs->vs_ops[t] += cvs->vs_ops[t]; vs->vs_bytes[t] += cvs->vs_bytes[t]; } @@ -2270,8 +2285,9 @@ void vdev_scrub_stat_update(vdev_t *vd, pool_scrub_type_t type, boolean_t complete) { vdev_stat_t *vs = &vd->vdev_stat; + int c; - for (int c = 0; c < vd->vdev_children; c++) + for (c = 0; c < vd->vdev_children; c++) vdev_scrub_stat_update(vd->vdev_child[c], type, complete); mutex_enter(&vd->vdev_stat_lock); @@ -2483,9 +2499,10 @@ vdev_propagate_state(vdev_t *vd) int degraded = 0, faulted = 0; int corrupted = 0; vdev_t *child; + int c; if (vd->vdev_children > 0) { - for (int c = 0; c < vd->vdev_children; c++) { + for (c = 0; c < vd->vdev_children; c++) { child = vd->vdev_child[c]; if (!vdev_readable(child) || @@ -2660,6 +2677,8 @@ vdev_set_state(vdev_t *vd, boolean_t isopen, vdev_state_t state, vdev_aux_t aux) boolean_t vdev_is_bootable(vdev_t *vd) { + int c; + if (!vd->vdev_ops->vdev_op_leaf) { char *vdev_type = vd->vdev_ops->vdev_op_type; @@ -2674,7 +2693,7 @@ vdev_is_bootable(vdev_t *vd) return (B_FALSE); } - for (int c = 0; c < vd->vdev_children; c++) { + for (c = 0; c < vd->vdev_children; c++) { if (!vdev_is_bootable(vd->vdev_child[c])) return (B_FALSE); } @@ -2688,10 +2707,11 @@ vdev_load_log_state(vdev_t *vd, nvlist_t *nv) nvlist_t **child; uint64_t val; spa_t *spa = vd->vdev_spa; + int c; if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN, &child, &children) == 0) { - for (int c = 0; c < children; c++) + for (c = 0; c < children; c++) vdev_load_log_state(vd->vdev_child[c], child[c]); } diff --git a/module/zfs/vdev_cache.c b/module/zfs/vdev_cache.c index 9b3a9f5a2..9fbea035d 100644 --- a/module/zfs/vdev_cache.c +++ b/module/zfs/vdev_cache.c @@ -246,7 +246,7 @@ vdev_cache_read(zio_t *zio) vdev_cache_t *vc = &zio->io_vd->vdev_cache; vdev_cache_entry_t *ve, ve_search; uint64_t cache_offset = P2ALIGN(zio->io_offset, VCBS); - uint64_t cache_phase = P2PHASE(zio->io_offset, VCBS); + ASSERTV(uint64_t cache_phase = P2PHASE(zio->io_offset, VCBS);) zio_t *fio; ASSERT(zio->io_type == ZIO_TYPE_READ); diff --git a/module/zfs/vdev_label.c b/module/zfs/vdev_label.c index 48d5fc232..e33d2660e 100644 --- a/module/zfs/vdev_label.c +++ b/module/zfs/vdev_label.c @@ -341,6 +341,7 @@ vdev_label_read_config(vdev_t *vd) zio_t *zio; int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE; + int l; ASSERT(spa_config_held(spa, SCL_STATE_ALL, RW_WRITER) == SCL_STATE_ALL); @@ -350,7 +351,7 @@ vdev_label_read_config(vdev_t *vd) vp = zio_buf_alloc(sizeof (vdev_phys_t)); retry: - for (int l = 0; l < VDEV_LABELS; l++) { + for (l = 0; l < VDEV_LABELS; l++) { zio = zio_root(spa, NULL, NULL, flags); @@ -468,6 +469,8 @@ vdev_inuse(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason, case VDEV_LABEL_SPARE: return (spa_has_spare(spa, device_guid)); + default: + break; } } @@ -504,12 +507,14 @@ 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; int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL; + int c, l, n; + vdev_t *pvd; ASSERT(spa_config_held(spa, SCL_ALL, RW_WRITER) == SCL_ALL); - for (int c = 0; c < vd->vdev_children; c++) + for (c = 0; c < vd->vdev_children; c++) if ((error = vdev_label_init(vd->vdev_child[c], crtxg, reason)) != 0) return (error); @@ -542,7 +547,7 @@ vdev_label_init(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason) vd->vdev_guid += guid_delta; - for (vdev_t *pvd = vd; pvd != NULL; pvd = pvd->vdev_parent) + for (pvd = vd; pvd != NULL; pvd = pvd->vdev_parent) pvd->vdev_guid_sum += guid_delta; /* @@ -561,7 +566,7 @@ vdev_label_init(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason) vd->vdev_guid += guid_delta; - for (vdev_t *pvd = vd; pvd != NULL; pvd = pvd->vdev_parent) + for (pvd = vd; pvd != NULL; pvd = pvd->vdev_parent) pvd->vdev_guid_sum += guid_delta; /* @@ -657,7 +662,7 @@ vdev_label_init(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason) retry: zio = zio_root(spa, NULL, NULL, flags); - for (int l = 0; l < VDEV_LABELS; l++) { + for (l = 0; l < VDEV_LABELS; l++) { vdev_label_write(zio, vd, l, vp, offsetof(vdev_label_t, vl_vdev_phys), @@ -672,7 +677,7 @@ retry: offsetof(vdev_label_t, vl_pad2), VDEV_PAD_SIZE, NULL, NULL, flags); - for (int n = 0; n < VDEV_UBERBLOCK_COUNT(vd); n++) { + for (n = 0; n < VDEV_UBERBLOCK_COUNT(vd); n++) { vdev_label_write(zio, vd, l, ub, VDEV_UBERBLOCK_OFFSET(vd, n), VDEV_UBERBLOCK_SIZE(vd), NULL, NULL, flags); @@ -774,6 +779,7 @@ vdev_uberblock_load(zio_t *zio, vdev_t *vd, uberblock_t *ubbest) vdev_t *rvd = spa->spa_root_vdev; int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE | ZIO_FLAG_TRYHARD; + int c, l, n; if (vd == rvd) { ASSERT(zio == NULL); @@ -784,12 +790,12 @@ vdev_uberblock_load(zio_t *zio, vdev_t *vd, uberblock_t *ubbest) ASSERT(zio != NULL); - for (int c = 0; c < vd->vdev_children; c++) + for (c = 0; c < vd->vdev_children; c++) vdev_uberblock_load(zio, vd->vdev_child[c], ubbest); if (vd->vdev_ops->vdev_op_leaf && vdev_readable(vd)) { - for (int l = 0; l < VDEV_LABELS; l++) { - for (int n = 0; n < VDEV_UBERBLOCK_COUNT(vd); n++) { + for (l = 0; l < VDEV_LABELS; l++) { + for (n = 0; n < VDEV_UBERBLOCK_COUNT(vd); n++) { vdev_label_read(zio, vd, l, zio_buf_alloc(VDEV_UBERBLOCK_SIZE(vd)), VDEV_UBERBLOCK_OFFSET(vd, n), @@ -825,9 +831,9 @@ static void vdev_uberblock_sync(zio_t *zio, uberblock_t *ub, vdev_t *vd, int flags) { uberblock_t *ubbuf; - int n; + int c, l, n; - for (int c = 0; c < vd->vdev_children; c++) + for (c = 0; c < vd->vdev_children; c++) vdev_uberblock_sync(zio, ub, vd->vdev_child[c], flags); if (!vd->vdev_ops->vdev_op_leaf) @@ -842,7 +848,7 @@ vdev_uberblock_sync(zio_t *zio, uberblock_t *ub, vdev_t *vd, int flags) bzero(ubbuf, VDEV_UBERBLOCK_SIZE(vd)); *ubbuf = *ub; - for (int l = 0; l < VDEV_LABELS; l++) + for (l = 0; l < VDEV_LABELS; l++) vdev_label_write(zio, vd, l, ubbuf, VDEV_UBERBLOCK_OFFSET(vd, n), VDEV_UBERBLOCK_SIZE(vd), vdev_uberblock_sync_done, zio->io_private, @@ -857,10 +863,11 @@ vdev_uberblock_sync_list(vdev_t **svd, int svdcount, uberblock_t *ub, int flags) spa_t *spa = svd[0]->vdev_spa; zio_t *zio; uint64_t good_writes = 0; + int v; zio = zio_root(spa, NULL, &good_writes, flags); - for (int v = 0; v < svdcount; v++) + for (v = 0; v < svdcount; v++) vdev_uberblock_sync(zio, ub, svd[v], flags); (void) zio_wait(zio); @@ -872,7 +879,7 @@ vdev_uberblock_sync_list(vdev_t **svd, int svdcount, uberblock_t *ub, int flags) */ zio = zio_root(spa, NULL, NULL, flags); - for (int v = 0; v < svdcount; v++) + for (v = 0; v < svdcount; v++) zio_flush(zio, svd[v]); (void) zio_wait(zio); @@ -925,8 +932,9 @@ vdev_label_sync(zio_t *zio, vdev_t *vd, int l, uint64_t txg, int flags) vdev_phys_t *vp; char *buf; size_t buflen; + int c; - for (int c = 0; c < vd->vdev_children; c++) + for (c = 0; c < vd->vdev_children; c++) vdev_label_sync(zio, vd->vdev_child[c], l, txg, flags); if (!vd->vdev_ops->vdev_op_leaf) diff --git a/module/zfs/vdev_mirror.c b/module/zfs/vdev_mirror.c index fff7e0842..c38cd6800 100644 --- a/module/zfs/vdev_mirror.c +++ b/module/zfs/vdev_mirror.c @@ -308,9 +308,9 @@ vdev_mirror_io_start(zio_t *zio) static int vdev_mirror_worst_error(mirror_map_t *mm) { - int error[2] = { 0, 0 }; + int c, error[2] = { 0, 0 }; - for (int c = 0; c < mm->mm_children; c++) { + for (c = 0; c < mm->mm_children; c++) { mirror_child_t *mc = &mm->mm_child[c]; int s = mc->mc_speculative; error[s] = zio_worst_error(error[s], mc->mc_error); diff --git a/module/zfs/vdev_queue.c b/module/zfs/vdev_queue.c index 5e57a1513..a1cf74fe1 100644 --- a/module/zfs/vdev_queue.c +++ b/module/zfs/vdev_queue.c @@ -292,12 +292,13 @@ void vdev_queue_io_done(zio_t *zio) { vdev_queue_t *vq = &zio->io_vd->vdev_queue; + int i; mutex_enter(&vq->vq_lock); avl_remove(&vq->vq_pending_tree, zio); - for (int i = 0; i < zfs_vdev_ramp_rate; i++) { + for (i = 0; i < zfs_vdev_ramp_rate; i++) { zio_t *nio = vdev_queue_io_to_issue(vq, zfs_vdev_max_pending); if (nio == NULL) break; diff --git a/module/zfs/vdev_raidz.c b/module/zfs/vdev_raidz.c index 92753d871..23c6c6600 100644 --- a/module/zfs/vdev_raidz.c +++ b/module/zfs/vdev_raidz.c @@ -775,9 +775,9 @@ static uint64_t raidz_corrected_pq; static int vdev_raidz_worst_error(raidz_map_t *rm) { - int error = 0; + int c, error = 0; - for (int c = 0; c < rm->rm_cols; c++) + for (c = 0; c < rm->rm_cols; c++) error = zio_worst_error(error, rm->rm_col[c].rc_error); return (error); @@ -789,7 +789,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, *rc1; + raidz_col_t *rc = NULL, *rc1; int unexpected_errors = 0; int parity_errors = 0; int parity_untried = 0; diff --git a/module/zfs/zap.c b/module/zfs/zap.c index 2dc2705b9..9ae4421bf 100644 --- a/module/zfs/zap.c +++ b/module/zfs/zap.c @@ -474,7 +474,7 @@ zap_open_leaf(uint64_t blkid, dmu_buf_t *db) ASSERT3U(ZAP_LEAF_HASH_NUMENTRIES(l), >, ZAP_LEAF_NUMCHUNKS(l) / 3); /* The chunks should begin at the end of the hash table */ - ASSERT3P(&ZAP_LEAF_CHUNK(l, 0), ==, + ASSERT3P(&ZAP_LEAF_CHUNK(l, 0), ==, (zap_leaf_chunk_t *) &l->l_phys->l_hash[ZAP_LEAF_HASH_NUMENTRIES(l)]); /* The chunks should end at the end of the block */ diff --git a/module/zfs/zap_leaf.c b/module/zfs/zap_leaf.c index 9d8354e73..55a4c5c7d 100644 --- a/module/zfs/zap_leaf.c +++ b/module/zfs/zap_leaf.c @@ -219,7 +219,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/zap_micro.c b/module/zfs/zap_micro.c index 140c29ab8..b02a4f4da 100644 --- a/module/zfs/zap_micro.c +++ b/module/zfs/zap_micro.c @@ -747,7 +747,7 @@ mzap_addent(zap_name_t *zn, uint64_t value) #ifdef ZFS_DEBUG for (i = 0; i < zap->zap_m.zap_num_chunks; i++) { - mzap_ent_phys_t *mze = &zap->zap_m.zap_phys->mz_chunk[i]; + ASSERTV(mzap_ent_phys_t *mze=&zap->zap_m.zap_phys->mz_chunk[i]); ASSERT(strcmp(zn->zn_name_orij, mze->mze_name) != 0); } #endif diff --git a/module/zfs/zfs_byteswap.c b/module/zfs/zfs_byteswap.c index cd36696f9..d5f3013df 100644 --- a/module/zfs/zfs_byteswap.c +++ b/module/zfs/zfs_byteswap.c @@ -50,7 +50,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_ioctl.c b/module/zfs/zfs_ioctl.c index 50f670626..0b90ce789 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -154,7 +154,7 @@ history_str_get(zfs_cmd_t *zc) { char *buf; - if (zc->zc_history == NULL) + if (zc->zc_history == 0) return (NULL); buf = kmem_alloc(HIS_MAX_RECORD_LEN, KM_SLEEP); @@ -337,6 +337,8 @@ zfs_secpolicy_setprop(const char *name, zfs_prop_t prop, cred_t *cr) * Check permissions for special properties. */ switch (prop) { + default: + break; case ZFS_PROP_ZONED: /* * Disallow setting of 'zoned' from within a local zone. @@ -1435,7 +1437,7 @@ zfs_ioc_objset_zplprops(zfs_cmd_t *zc) * which we aren't supposed to do with a DS_MODE_USER * hold, because it could be inconsistent. */ - if (zc->zc_nvlist_dst != NULL && + if (zc->zc_nvlist_dst != 0 && !zc->zc_objset_stats.dds_inconsistent && dmu_objset_type(os) == DMU_OST_ZFS) { nvlist_t *nv; @@ -1640,6 +1642,8 @@ zfs_set_prop_nvlist(const char *name, nvlist_t *nvl) * Check that this value is valid for this pool version */ switch (prop) { + default: + break; case ZFS_PROP_COMPRESSION: /* * If the user specified gzip compression, make sure @@ -1993,7 +1997,7 @@ zfs_ioc_pool_get_props(zfs_cmd_t *zc) spa_close(spa, FTAG); } - if (error == 0 && zc->zc_nvlist_dst != NULL) + if (error == 0 && zc->zc_nvlist_dst != 0) error = put_nvlist(zc, nvp); else error = EFAULT; @@ -2367,7 +2371,7 @@ zfs_ioc_create(zfs_cmd_t *zc) strchr(zc->zc_name, '%')) return (EINVAL); - if (zc->zc_nvlist_src != NULL && + if (zc->zc_nvlist_src != 0 && (error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, zc->zc_iflags, &nvprops)) != 0) return (error); @@ -2491,7 +2495,7 @@ zfs_ioc_snapshot(zfs_cmd_t *zc) if (snapshot_namecheck(zc->zc_value, NULL, NULL) != 0) return (EINVAL); - if (zc->zc_nvlist_src != NULL && + if (zc->zc_nvlist_src != 0 && (error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, zc->zc_iflags, &nvprops)) != 0) return (error); @@ -2728,7 +2732,7 @@ zfs_ioc_recv(zfs_cmd_t *zc) *tosnap = '\0'; tosnap++; - if (zc->zc_nvlist_src != NULL && + if (zc->zc_nvlist_src != 0 && (error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, zc->zc_iflags, &props)) != 0) return (error); diff --git a/module/zfs/zfs_replay.c b/module/zfs/zfs_replay.c index 85b79703a..819ba2886 100644 --- a/module/zfs/zfs_replay.c +++ b/module/zfs/zfs_replay.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/types.h> #include <sys/param.h> diff --git a/module/zfs/zio.c b/module/zfs/zio.c index 2b2441215..63398f7e9 100644 --- a/module/zfs/zio.c +++ b/module/zfs/zio.c @@ -355,6 +355,7 @@ void zio_add_child(zio_t *pio, zio_t *cio) { zio_link_t *zl = kmem_cache_alloc(zio_link_cache, KM_SLEEP); + int w; /* * Logical I/Os can have logical, gang, or vdev children. @@ -372,7 +373,7 @@ zio_add_child(zio_t *pio, zio_t *cio) ASSERT(pio->io_state[ZIO_WAIT_DONE] == 0); - for (int w = 0; w < ZIO_WAIT_TYPES; w++) + for (w = 0; w < ZIO_WAIT_TYPES; w++) pio->io_children[cio->io_child_type][w] += !cio->io_state[w]; list_insert_head(&pio->io_child_list, zl); @@ -905,8 +906,8 @@ zio_write_bp_init(zio_t *zio) */ if (bp->blk_birth == zio->io_txg && BP_GET_PSIZE(bp) == csize && pass > SYNC_PASS_REWRITE) { - ASSERT(csize != 0); uint32_t gang_stages = zio->io_pipeline & ZIO_GANG_STAGES; + ASSERT(csize != 0); zio->io_pipeline = ZIO_REWRITE_PIPELINE | gang_stages; zio->io_flags |= ZIO_FLAG_IO_REWRITE; } else { @@ -964,8 +965,9 @@ zio_taskq_member(zio_t *zio, enum zio_taskq_type q) { kthread_t *executor = zio->io_executor; spa_t *spa = zio->io_spa; + zio_type_t t; - for (zio_type_t t = 0; t < ZIO_TYPES; t++) + for (t = 0; t < ZIO_TYPES; t++) if (taskq_member(spa->spa_zio_taskq[t][q], executor)) return (B_TRUE); @@ -1099,6 +1101,7 @@ static void zio_reexecute(zio_t *pio) { zio_t *cio, *cio_next; + int c, w; ASSERT(pio->io_child_type == ZIO_CHILD_LOGICAL); ASSERT(pio->io_orig_stage == ZIO_STAGE_OPEN); @@ -1110,9 +1113,9 @@ zio_reexecute(zio_t *pio) pio->io_pipeline = pio->io_orig_pipeline; pio->io_reexecute = 0; pio->io_error = 0; - for (int w = 0; w < ZIO_WAIT_TYPES; w++) + for (w = 0; w < ZIO_WAIT_TYPES; w++) pio->io_state[w] = 0; - for (int c = 0; c < ZIO_CHILD_TYPES; c++) + for (c = 0; c < ZIO_CHILD_TYPES; c++) pio->io_child_error[c] = 0; if (IO_IS_ALLOCATING(pio)) { @@ -1139,7 +1142,7 @@ zio_reexecute(zio_t *pio) for (cio = zio_walk_children(pio); cio != NULL; cio = cio_next) { cio_next = zio_walk_children(pio); mutex_enter(&pio->io_lock); - for (int w = 0; w < ZIO_WAIT_TYPES; w++) + for (w = 0; w < ZIO_WAIT_TYPES; w++) pio->io_children[cio->io_child_type][w]++; mutex_exit(&pio->io_lock); zio_reexecute(cio); @@ -1369,8 +1372,9 @@ static void zio_gang_node_free(zio_gang_node_t **gnpp) { zio_gang_node_t *gn = *gnpp; + int g; - for (int g = 0; g < SPA_GBH_NBLKPTRS; g++) + for (g = 0; g < SPA_GBH_NBLKPTRS; g++) ASSERT(gn->gn_child[g] == NULL); zio_buf_free(gn->gn_gbh, SPA_GANGBLOCKSIZE); @@ -1382,11 +1386,12 @@ static void zio_gang_tree_free(zio_gang_node_t **gnpp) { zio_gang_node_t *gn = *gnpp; + int g; if (gn == NULL) return; - for (int g = 0; g < SPA_GBH_NBLKPTRS; g++) + for (g = 0; g < SPA_GBH_NBLKPTRS; g++) zio_gang_tree_free(&gn->gn_child[g]); zio_gang_node_free(gnpp); @@ -1411,6 +1416,7 @@ zio_gang_tree_assemble_done(zio_t *zio) zio_t *gio = zio->io_gang_leader; zio_gang_node_t *gn = zio->io_private; blkptr_t *bp = zio->io_bp; + int g; ASSERT(gio == zio_unique_parent(zio)); ASSERT(zio_walk_children(zio) == NULL); @@ -1425,7 +1431,7 @@ zio_gang_tree_assemble_done(zio_t *zio) ASSERT(zio->io_size == SPA_GANGBLOCKSIZE); ASSERT(gn->gn_gbh->zg_tail.zbt_magic == ZBT_MAGIC); - for (int g = 0; g < SPA_GBH_NBLKPTRS; g++) { + for (g = 0; g < SPA_GBH_NBLKPTRS; g++) { blkptr_t *gbp = &gn->gn_gbh->zg_blkptr[g]; if (!BP_IS_GANG(gbp)) continue; @@ -1438,6 +1444,7 @@ zio_gang_tree_issue(zio_t *pio, zio_gang_node_t *gn, blkptr_t *bp, void *data) { zio_t *gio = pio->io_gang_leader; zio_t *zio; + int g; ASSERT(BP_IS_GANG(bp) == !!gn); ASSERT(BP_GET_CHECKSUM(bp) == BP_GET_CHECKSUM(gio->io_bp)); @@ -1452,7 +1459,7 @@ zio_gang_tree_issue(zio_t *pio, zio_gang_node_t *gn, blkptr_t *bp, void *data) if (gn != NULL) { ASSERT(gn->gn_gbh->zg_tail.zbt_magic == ZBT_MAGIC); - for (int g = 0; g < SPA_GBH_NBLKPTRS; g++) { + for (g = 0; g < SPA_GBH_NBLKPTRS; g++) { blkptr_t *gbp = &gn->gn_gbh->zg_blkptr[g]; if (BP_IS_HOLE(gbp)) continue; @@ -1508,10 +1515,11 @@ static void zio_write_gang_member_ready(zio_t *zio) { zio_t *pio = zio_unique_parent(zio); - zio_t *gio = zio->io_gang_leader; + ASSERTV(zio_t *gio = zio->io_gang_leader); dva_t *cdva = zio->io_bp->blk_dva; dva_t *pdva = pio->io_bp->blk_dva; uint64_t asize; + int d; if (BP_IS_HOLE(zio->io_bp)) return; @@ -1525,7 +1533,7 @@ zio_write_gang_member_ready(zio_t *zio) ASSERT3U(BP_GET_NDVAS(zio->io_bp), <=, BP_GET_NDVAS(pio->io_bp)); mutex_enter(&pio->io_lock); - for (int d = 0; d < BP_GET_NDVAS(zio->io_bp); d++) { + for (d = 0; d < BP_GET_NDVAS(zio->io_bp); d++) { ASSERT(DVA_GET_GANG(&pdva[d])); asize = DVA_GET_ASIZE(&pdva[d]); asize += DVA_GET_ASIZE(&cdva[d]); @@ -1549,7 +1557,7 @@ zio_write_gang_block(zio_t *pio) int ndvas = gio->io_prop.zp_ndvas; int gbh_ndvas = MIN(ndvas + 1, spa_max_replication(spa)); zio_prop_t zp; - int error; + int g, error; error = metaslab_alloc(spa, spa->spa_normal_class, SPA_GANGBLOCKSIZE, bp, gbh_ndvas, txg, pio == gio ? NULL : gio->io_bp, @@ -1579,7 +1587,7 @@ zio_write_gang_block(zio_t *pio) /* * Create and nowait the gang children. */ - for (int g = 0; resid != 0; resid -= lsize, g++) { + for (g = 0; resid != 0; resid -= lsize, g++) { lsize = P2ROUNDUP(resid / (SPA_GBH_NBLKPTRS - g), SPA_MINBLOCKSIZE); ASSERT(lsize >= SPA_MINBLOCKSIZE && lsize <= resid); @@ -1674,6 +1682,7 @@ zio_dva_unallocate(zio_t *zio, zio_gang_node_t *gn, blkptr_t *bp) { spa_t *spa = zio->io_spa; boolean_t now = !(zio->io_flags & ZIO_FLAG_IO_REWRITE); + int g; ASSERT(bp->blk_birth == zio->io_txg || BP_IS_HOLE(bp)); @@ -1704,7 +1713,7 @@ zio_dva_unallocate(zio_t *zio, zio_gang_node_t *gn, blkptr_t *bp) metaslab_free(spa, bp, bp->blk_birth, now); if (gn != NULL) { - for (int g = 0; g < SPA_GBH_NBLKPTRS; g++) { + for (g = 0; g < SPA_GBH_NBLKPTRS; g++) { zio_dva_unallocate(zio, gn->gn_child[g], &gn->gn_gbh->zg_blkptr[g]); } @@ -2117,6 +2126,7 @@ zio_done(zio_t *zio) vdev_t *vd = zio->io_vd; uint64_t psize = zio->io_size; zio_t *pio, *pio_next; + int c, w; /* * If our children haven't all completed, @@ -2127,8 +2137,8 @@ zio_done(zio_t *zio) zio_wait_for_children(zio, ZIO_CHILD_LOGICAL, ZIO_WAIT_DONE)) return (ZIO_PIPELINE_STOP); - for (int c = 0; c < ZIO_CHILD_TYPES; c++) - for (int w = 0; w < ZIO_WAIT_TYPES; w++) + for (c = 0; c < ZIO_CHILD_TYPES; c++) + for (w = 0; w < ZIO_WAIT_TYPES; w++) ASSERT(zio->io_children[c][w] == 0); if (bp != NULL) { diff --git a/module/zfs/zio_compress.c b/module/zfs/zio_compress.c index c563be4eb..560b43b68 100644 --- a/module/zfs/zio_compress.c +++ b/module/zfs/zio_compress.c @@ -24,7 +24,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/zfs_context.h> #include <sys/compress.h> |