diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/zdb/zdb.c | 34 | ||||
-rw-r--r-- | cmd/zdb/zdb_il.c | 44 | ||||
-rw-r--r-- | cmd/zfs/zfs_main.c | 21 | ||||
-rw-r--r-- | cmd/zfs/zfs_util.h | 2 | ||||
-rw-r--r-- | cmd/zinject/translate.c | 6 | ||||
-rw-r--r-- | cmd/zinject/zinject.c | 2 | ||||
-rw-r--r-- | cmd/zinject/zinject.h | 2 | ||||
-rw-r--r-- | cmd/zpool/zpool_iter.c | 4 | ||||
-rw-r--r-- | cmd/zpool/zpool_main.c | 13 | ||||
-rw-r--r-- | cmd/zpool/zpool_util.c | 2 | ||||
-rw-r--r-- | cmd/zpool/zpool_vdev.c | 2 | ||||
-rw-r--r-- | cmd/ztest/ztest.c | 40 |
12 files changed, 95 insertions, 77 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index 09f23c1b2..fb9c4be6f 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -71,7 +71,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 */ } @@ -538,6 +538,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); @@ -551,7 +552,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; @@ -565,7 +566,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); } @@ -646,7 +647,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); @@ -816,7 +817,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]; @@ -826,6 +827,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)) { @@ -872,7 +874,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); @@ -1401,10 +1403,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, @@ -1419,10 +1422,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); @@ -1457,7 +1461,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]; @@ -1562,13 +1568,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...\n", (dump_opt['c'] || !dump_opt['L']) ? "to verify " : "", @@ -1874,7 +1882,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 02d35a050..2d5141051 100644 --- a/cmd/zdb/zdb_il.c +++ b/cmd/zdb/zdb_il.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + /* * Print intent log header and statistics. @@ -225,7 +225,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; @@ -233,26 +233,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 1f7f47d08..7fb6aa6db 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -542,7 +542,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; @@ -645,7 +645,7 @@ zfs_do_create(int argc, char **argv) zfs_prop_t resv_prop; char *strval; - if (p = strchr(argv[0], '/')) + if ((p = strchr(argv[0], '/'))) *p = '\0'; zpool_handle = zpool_open(g_zfs, argv[0]); if (p != NULL) @@ -1446,7 +1446,7 @@ upgrade_set_callback(zfs_handle_t *zhp, void *data) /* can't upgrade */ (void) printf(gettext("%s: can not be upgraded; " "the pool version needs to first be upgraded\nto " - "version %d\n\n"), + "version %llu\n\n"), zfs_get_name(zhp), SPA_VERSION_FUID); cb->cb_numfailed++; return (0); @@ -1457,7 +1457,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 @@ -1563,11 +1563,11 @@ zfs_do_upgrade(int argc, char **argv) ret = zfs_for_each(argc, argv, flags, ZFS_TYPE_FILESYSTEM, NULL, NULL, 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; @@ -1652,9 +1652,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"); @@ -2234,7 +2234,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, set_callback, &cb); return (ret); @@ -3283,7 +3283,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); } @@ -4208,6 +4208,7 @@ main(int argc, char **argv) (void) fprintf(stderr, gettext("unrecognized " "command '%s'\n"), cmdname); usage(B_FALSE); + ret = 1; } } 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 0264aca6f..4127339ed 100644 --- a/cmd/zinject/translate.c +++ b/cmd/zinject/translate.c @@ -219,6 +219,8 @@ calculate_range(const char *dataset, err_type_t type, int level, char *range, } switch (type) { + default: + break; case TYPE_DATA: break; @@ -333,6 +335,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; @@ -459,6 +463,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.c b/cmd/zinject/zinject.c index 02dc18b9c..3e2ca3554 100644 --- a/cmd/zinject/zinject.c +++ b/cmd/zinject/zinject.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" + /* * ZFS Fault Injector 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 2f0daefd5..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> @@ -131,7 +131,7 @@ pool_list_get(int argc, char **argv, zprop_list_t **proplist, int *err) for (i = 0; i < argc; i++) { zpool_handle_t *zhp; - if (zhp = zpool_open_canfail(g_zfs, argv[i])) { + if ((zhp = zpool_open_canfail(g_zfs, argv[i]))) { if (add_pool(zhp, zlp) != 0) *err = B_TRUE; } else { diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 13c8a59ab..3125cfe41 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -1373,7 +1373,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; @@ -2070,9 +2070,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"); @@ -3350,7 +3350,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) { @@ -3613,8 +3613,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; } @@ -3915,6 +3915,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 ce494fa79..019c57385 100644 --- a/cmd/ztest/ztest.c +++ b/cmd/ztest/ztest.c @@ -260,7 +260,7 @@ static void usage(boolean_t) __NORETURN; * debugging facilities. */ const char * -_umem_debug_init() +_umem_debug_init(void) { return ("default,verbose"); /* $UMEM_DEBUG setting */ } @@ -756,19 +756,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 */ }; /* @@ -827,11 +827,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); @@ -1170,7 +1171,7 @@ ztest_vdev_LUN_growth(ztest_args_t *za) */ if (fsize < 2 * zopt_vdev_size) { size_t newsize = fsize + ztest_random(fsize / 32); - (void) ftruncate(fd, newsize); + VERIFY(ftruncate(fd, newsize) == 0); if (zopt_verbose >= 6) { (void) printf("%s grew from %lu to %lu bytes\n", dev_name, (ulong_t)fsize, (ulong_t)newsize); @@ -1343,7 +1344,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); @@ -1931,11 +1932,12 @@ ztest_dmu_write_parallel(ztest_args_t *za) pthread_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); + bzero(&blk, sizeof(blkptr_t)); dmu_objset_name(os, osname); /* @@ -2495,7 +2497,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]; |