Fix gcc missing case warnings
[zfs.git] / cmd / ztest / ztest.c
index eed92ec..5677dcb 100644 (file)
@@ -359,7 +359,7 @@ static void usage(boolean_t) __NORETURN;
  * debugging facilities.
  */
 const char *
-_umem_debug_init()
+_umem_debug_init(void)
 {
        return ("default,verbose"); /* $UMEM_DEBUG setting */
 }
@@ -979,25 +979,28 @@ ztest_zd_init(ztest_ds_t *zd, objset_t *os)
        zd->zd_zilog = dmu_objset_zil(os);
        zd->zd_seq = 0;
        dmu_objset_name(os, zd->zd_name);
+       int l;
 
        VERIFY(_mutex_init(&zd->zd_dirobj_lock, USYNC_THREAD, NULL) == 0);
 
-       for (int l = 0; l < ZTEST_OBJECT_LOCKS; l++)
+       for (l = 0; l < ZTEST_OBJECT_LOCKS; l++)
                ztest_rll_init(&zd->zd_object_lock[l]);
 
-       for (int l = 0; l < ZTEST_RANGE_LOCKS; l++)
+       for (l = 0; l < ZTEST_RANGE_LOCKS; l++)
                ztest_rll_init(&zd->zd_range_lock[l]);
 }
 
 static void
 ztest_zd_fini(ztest_ds_t *zd)
 {
+       int l;
+
        VERIFY(_mutex_destroy(&zd->zd_dirobj_lock) == 0);
 
-       for (int l = 0; l < ZTEST_OBJECT_LOCKS; l++)
+       for (l = 0; l < ZTEST_OBJECT_LOCKS; l++)
                ztest_rll_destroy(&zd->zd_object_lock[l]);
 
-       for (int l = 0; l < ZTEST_RANGE_LOCKS; l++)
+       for (l = 0; l < ZTEST_RANGE_LOCKS; l++)
                ztest_rll_destroy(&zd->zd_range_lock[l]);
 }
 
@@ -1102,7 +1105,7 @@ ztest_bt_bonus(dmu_buf_t *db)
 #define        lrz_bonustype   lr_rdev
 #define        lrz_bonuslen    lr_crtime[1]
 
-static uint64_t
+static void
 ztest_log_create(ztest_ds_t *zd, dmu_tx_t *tx, lr_create_t *lr)
 {
        char *name = (void *)(lr + 1);          /* name follows lr */
@@ -1110,40 +1113,41 @@ ztest_log_create(ztest_ds_t *zd, dmu_tx_t *tx, lr_create_t *lr)
        itx_t *itx;
 
        if (zil_replaying(zd->zd_zilog, tx))
-               return (0);
+               return;
 
        itx = zil_itx_create(TX_CREATE, sizeof (*lr) + namesize);
        bcopy(&lr->lr_common + 1, &itx->itx_lr + 1,
            sizeof (*lr) + namesize - sizeof (lr_t));
 
-       return (zil_itx_assign(zd->zd_zilog, itx, tx));
+       zil_itx_assign(zd->zd_zilog, itx, tx);
 }
 
-static uint64_t
-ztest_log_remove(ztest_ds_t *zd, dmu_tx_t *tx, lr_remove_t *lr)
+static void
+ztest_log_remove(ztest_ds_t *zd, dmu_tx_t *tx, lr_remove_t *lr, uint64_t object)
 {
        char *name = (void *)(lr + 1);          /* name follows lr */
        size_t namesize = strlen(name) + 1;
        itx_t *itx;
 
        if (zil_replaying(zd->zd_zilog, tx))
-               return (0);
+               return;
 
        itx = zil_itx_create(TX_REMOVE, sizeof (*lr) + namesize);
        bcopy(&lr->lr_common + 1, &itx->itx_lr + 1,
            sizeof (*lr) + namesize - sizeof (lr_t));
 
-       return (zil_itx_assign(zd->zd_zilog, itx, tx));
+       itx->itx_oid = object;
+       zil_itx_assign(zd->zd_zilog, itx, tx);
 }
 
-static uint64_t
+static void
 ztest_log_write(ztest_ds_t *zd, dmu_tx_t *tx, lr_write_t *lr)
 {
        itx_t *itx;
        itx_wr_state_t write_state = ztest_random(WR_NUM_STATES);
 
        if (zil_replaying(zd->zd_zilog, tx))
-               return (0);
+               return;
 
        if (lr->lr_length > ZIL_MAX_LOG_DATA)
                write_state = WR_INDIRECT;
@@ -1166,37 +1170,39 @@ ztest_log_write(ztest_ds_t *zd, dmu_tx_t *tx, lr_write_t *lr)
        bcopy(&lr->lr_common + 1, &itx->itx_lr + 1,
            sizeof (*lr) - sizeof (lr_t));
 
-       return (zil_itx_assign(zd->zd_zilog, itx, tx));
+       zil_itx_assign(zd->zd_zilog, itx, tx);
 }
 
-static uint64_t
+static void
 ztest_log_truncate(ztest_ds_t *zd, dmu_tx_t *tx, lr_truncate_t *lr)
 {
        itx_t *itx;
 
        if (zil_replaying(zd->zd_zilog, tx))
-               return (0);
+               return;
 
        itx = zil_itx_create(TX_TRUNCATE, sizeof (*lr));
        bcopy(&lr->lr_common + 1, &itx->itx_lr + 1,
            sizeof (*lr) - sizeof (lr_t));
 
-       return (zil_itx_assign(zd->zd_zilog, itx, tx));
+       itx->itx_sync = B_FALSE;
+       zil_itx_assign(zd->zd_zilog, itx, tx);
 }
 
-static uint64_t
+static void
 ztest_log_setattr(ztest_ds_t *zd, dmu_tx_t *tx, lr_setattr_t *lr)
 {
        itx_t *itx;
 
        if (zil_replaying(zd->zd_zilog, tx))
-               return (0);
+               return;
 
        itx = zil_itx_create(TX_SETATTR, sizeof (*lr));
        bcopy(&lr->lr_common + 1, &itx->itx_lr + 1,
            sizeof (*lr) - sizeof (lr_t));
 
-       return (zil_itx_assign(zd->zd_zilog, itx, tx));
+       itx->itx_sync = B_FALSE;
+       zil_itx_assign(zd->zd_zilog, itx, tx);
 }
 
 /*
@@ -1328,7 +1334,7 @@ ztest_replay_remove(ztest_ds_t *zd, lr_remove_t *lr, boolean_t byteswap)
 
        VERIFY3U(0, ==, zap_remove(os, lr->lr_doid, name, tx));
 
-       (void) ztest_log_remove(zd, tx, lr);
+       (void) ztest_log_remove(zd, tx, lr, object);
 
        dmu_tx_commit(tx);
 
@@ -1573,26 +1579,26 @@ ztest_replay_setattr(ztest_ds_t *zd, lr_setattr_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 */
-       ztest_replay_write,     /* TX_WRITE */
-       ztest_replay_truncate,  /* TX_TRUNCATE */
-       ztest_replay_setattr,   /* TX_SETATTR */
-       NULL,                   /* TX_ACL */
-       NULL,                   /* TX_CREATE_ACL */
-       NULL,                   /* TX_CREATE_ATTR */
-       NULL,                   /* TX_CREATE_ACL_ATTR */
-       NULL,                   /* TX_MKDIR_ACL */
-       NULL,                   /* TX_MKDIR_ATTR */
-       NULL,                   /* TX_MKDIR_ACL_ATTR */
-       NULL,                   /* TX_WRITE2 */
+       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 */
+       (zil_replay_func_t *)ztest_replay_write,        /* TX_WRITE */
+       (zil_replay_func_t *)ztest_replay_truncate,     /* TX_TRUNCATE */
+       (zil_replay_func_t *)ztest_replay_setattr,      /* TX_SETATTR */
+       NULL,                                           /* TX_ACL */
+       NULL,                                           /* TX_CREATE_ACL */
+       NULL,                                           /* TX_CREATE_ATTR */
+       NULL,                                           /* TX_CREATE_ACL_ATTR */
+       NULL,                                           /* TX_MKDIR_ACL */
+       NULL,                                           /* TX_MKDIR_ATTR */
+       NULL,                                           /* TX_MKDIR_ACL_ATTR */
+       NULL,                                           /* TX_WRITE2 */
 };
 
 /*
@@ -1728,10 +1734,11 @@ ztest_lookup(ztest_ds_t *zd, ztest_od_t *od, int count)
 {
        int missing = 0;
        int error;
+       int i;
 
        ASSERT(_mutex_held(&zd->zd_dirobj_lock));
 
-       for (int i = 0; i < count; i++, od++) {
+       for (i = 0; i < count; i++, od++) {
                od->od_object = 0;
                error = zap_lookup(zd->zd_os, od->od_dir, od->od_name,
                    sizeof (uint64_t), 1, &od->od_object);
@@ -1768,10 +1775,11 @@ static int
 ztest_create(ztest_ds_t *zd, ztest_od_t *od, int count)
 {
        int missing = 0;
+       int i;
 
        ASSERT(_mutex_held(&zd->zd_dirobj_lock));
 
-       for (int i = 0; i < count; i++, od++) {
+       for (i = 0; i < count; i++, od++) {
                if (missing) {
                        od->od_object = 0;
                        missing++;
@@ -1813,12 +1821,13 @@ ztest_remove(ztest_ds_t *zd, ztest_od_t *od, int count)
 {
        int missing = 0;
        int error;
+       int i;
 
        ASSERT(_mutex_held(&zd->zd_dirobj_lock));
 
        od += count - 1;
 
-       for (int i = count - 1; i >= 0; i--, od--) {
+       for (i = count - 1; i >= 0; i--, od--) {
                if (missing) {
                        missing++;
                        continue;
@@ -1989,6 +1998,8 @@ ztest_io(ztest_ds_t *zd, uint64_t object, uint64_t offset)
        case ZTEST_IO_SETATTR:
                (void) ztest_setattr(zd, object);
                break;
+       default:
+               break;
        }
 
        umem_free(data, blocksize);
@@ -2013,7 +2024,7 @@ ztest_od_init(ztest_od_t *od, uint64_t id, char *tag, uint64_t index,
        od->od_gen = 0;
 
        (void) snprintf(od->od_name, sizeof (od->od_name), "%s(%lld)[%llu]",
-           tag, (int64_t)id, index);
+           tag, (longlong_t)id, (u_longlong_t)index);
 }
 
 /*
@@ -2045,7 +2056,7 @@ ztest_zil_commit(ztest_ds_t *zd, uint64_t id)
 {
        zilog_t *zilog = zd->zd_zilog;
 
-       zil_commit(zilog, UINT64_MAX, ztest_random(ZTEST_OBJECTS));
+       zil_commit(zilog, ztest_random(ZTEST_OBJECTS));
 
        /*
         * Remember the committed values in zd, which is in parent/child
@@ -2105,11 +2116,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);
@@ -2582,7 +2594,7 @@ grow_vdev(vdev_t *vd, void *arg)
                return (vd);
 
        fsize = lseek(fd, 0, SEEK_END);
-       (void) ftruncate(fd, *newsize);
+       VERIFY(ftruncate(fd, *newsize) == 0);
 
        if (zopt_verbose >= 6) {
                (void) printf("%s grew from %lu to %lu bytes\n",
@@ -2659,6 +2671,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);
@@ -2666,7 +2680,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);
@@ -2875,7 +2889,7 @@ ztest_snapshot_create(char *osname, uint64_t id)
            (u_longlong_t)id);
 
        error = dmu_objset_snapshot(osname, strchr(snapname, '@') + 1,
-           NULL, B_FALSE);
+           NULL, NULL, B_FALSE, B_FALSE, -1);
        if (error == ENOSPC) {
                ztest_record_enospc(FTAG);
                return (B_FALSE);
@@ -2911,6 +2925,7 @@ ztest_dmu_objset_create_destroy(ztest_ds_t *zd, uint64_t id)
        objset_t *os, *os2;
        char name[MAXNAMELEN];
        zilog_t *zilog;
+       int i;
 
        (void) rw_rdlock(&zs->zs_name_lock);
 
@@ -2971,7 +2986,7 @@ ztest_dmu_objset_create_destroy(ztest_ds_t *zd, uint64_t id)
         * and randomly take a couple of snapshots along the way.
         */
        iters = ztest_random(5);
-       for (int i = 0; i < iters; i++) {
+       for (i = 0; i < iters; i++) {
                ztest_dmu_object_alloc_free(&zdtmp, id);
                if (ztest_random(iters) == 0)
                        (void) ztest_snapshot_create(name, i);
@@ -3029,11 +3044,16 @@ ztest_dsl_dataset_cleanup(char *osname, uint64_t id)
        char snap3name[MAXNAMELEN];
        int error;
 
-       (void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu", osname, id);
-       (void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu", osname, id);
-       (void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu", clone1name, id);
-       (void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu", osname, id);
-       (void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu", clone1name, id);
+       (void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu",
+           osname, (u_longlong_t)id);
+       (void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu",
+           osname, (u_longlong_t)id);
+       (void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu",
+           clone1name, (u_longlong_t)id);
+       (void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu",
+           osname, (u_longlong_t)id);
+       (void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu",
+           clone1name, (u_longlong_t)id);
 
        error = dmu_objset_destroy(clone2name, B_FALSE);
        if (error && error != ENOENT)
@@ -3073,14 +3093,19 @@ ztest_dsl_dataset_promote_busy(ztest_ds_t *zd, uint64_t id)
 
        ztest_dsl_dataset_cleanup(osname, id);
 
-       (void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu", osname, id);
-       (void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu", osname, id);
-       (void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu", clone1name, id);
-       (void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu", osname, id);
-       (void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu", clone1name, id);
+       (void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu",
+           osname, (u_longlong_t)id);
+       (void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu",
+           osname, (u_longlong_t)id);
+       (void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu",
+           clone1name, (u_longlong_t)id);
+       (void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu",
+           osname, (u_longlong_t)id);
+       (void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu",
+           clone1name, (u_longlong_t)id);
 
        error = dmu_objset_snapshot(osname, strchr(snap1name, '@')+1,
-           NULL, B_FALSE);
+           NULL, NULL, B_FALSE, B_FALSE, -1);
        if (error && error != EEXIST) {
                if (error == ENOSPC) {
                        ztest_record_enospc(FTAG);
@@ -3104,7 +3129,7 @@ ztest_dsl_dataset_promote_busy(ztest_ds_t *zd, uint64_t id)
        }
 
        error = dmu_objset_snapshot(clone1name, strchr(snap2name, '@')+1,
-           NULL, B_FALSE);
+           NULL, NULL, B_FALSE, B_FALSE, -1);
        if (error && error != EEXIST) {
                if (error == ENOSPC) {
                        ztest_record_enospc(FTAG);
@@ -3114,7 +3139,7 @@ ztest_dsl_dataset_promote_busy(ztest_ds_t *zd, uint64_t id)
        }
 
        error = dmu_objset_snapshot(clone1name, strchr(snap3name, '@')+1,
-           NULL, B_FALSE);
+           NULL, NULL, B_FALSE, B_FALSE, -1);
        if (error && error != EEXIST) {
                if (error == ENOSPC) {
                        ztest_record_enospc(FTAG);
@@ -3160,8 +3185,9 @@ ztest_dmu_object_alloc_free(ztest_ds_t *zd, uint64_t id)
 {
        ztest_od_t od[4];
        int batchsize = sizeof (od) / sizeof (od[0]);
+       int b;
 
-       for (int b = 0; b < batchsize; b++)
+       for (b = 0; b < batchsize; b++)
                ztest_od_init(&od[b], id, FTAG, b, DMU_OT_UINT64_OTHER, 0, 0);
 
        /*
@@ -3877,6 +3903,7 @@ ztest_fzap(ztest_ds_t *zd, uint64_t id)
        objset_t *os = zd->zd_os;
        ztest_od_t od[1];
        uint64_t object, txg;
+       int i;
 
        ztest_od_init(&od[0], id, FTAG, 0, DMU_OT_ZAP_OTHER, 0, 0);
 
@@ -3890,14 +3917,14 @@ ztest_fzap(ztest_ds_t *zd, uint64_t id)
         * and gets upgraded to a fatzap. Also, since we are adding
         * 2050 entries we should see ptrtbl growth and leaf-block split.
         */
-       for (int i = 0; i < 2050; i++) {
+       for (i = 0; i < 2050; i++) {
                char name[MAXNAMELEN];
                uint64_t value = i;
                dmu_tx_t *tx;
                int error;
 
                (void) snprintf(name, sizeof (name), "fzap-%llu-%llu",
-                   id, value);
+                   (u_longlong_t)id, (u_longlong_t)value);
 
                tx = dmu_tx_create(os);
                dmu_tx_hold_zap(tx, object, B_TRUE, name);
@@ -4237,10 +4264,11 @@ ztest_dsl_prop_get_set(ztest_ds_t *zd, uint64_t id)
                ZFS_PROP_DEDUP
        };
        ztest_shared_t *zs = ztest_shared;
+       int p;
 
        (void) rw_rdlock(&zs->zs_name_lock);
 
-       for (int p = 0; p < sizeof (proplist) / sizeof (proplist[0]); p++)
+       for (p = 0; p < sizeof (proplist) / sizeof (proplist[0]); p++)
                (void) ztest_dsl_prop_set_uint64(zd->zd_name, proplist[p],
                    ztest_random_dsl_prop(proplist[p]), (int)ztest_random(2));
 
@@ -4304,7 +4332,8 @@ ztest_dmu_snapshot_hold(ztest_ds_t *zd, uint64_t id)
         * Create snapshot, clone it, mark snap for deferred destroy,
         * destroy clone, verify snap was also destroyed.
         */
-       error = dmu_objset_snapshot(osname, snapname, NULL, FALSE);
+       error = dmu_objset_snapshot(osname, snapname, NULL, NULL, FALSE,
+           FALSE, -1);
        if (error) {
                if (error == ENOSPC) {
                        ztest_record_enospc("dmu_objset_snapshot");
@@ -4346,7 +4375,8 @@ ztest_dmu_snapshot_hold(ztest_ds_t *zd, uint64_t id)
         * destroy a held snapshot, mark for deferred destroy,
         * release hold, verify snapshot was destroyed.
         */
-       error = dmu_objset_snapshot(osname, snapname, NULL, FALSE);
+       error = dmu_objset_snapshot(osname, snapname, NULL, NULL, FALSE,
+           FALSE, -1);
        if (error) {
                if (error == ENOSPC) {
                        ztest_record_enospc("dmu_objset_snapshot");
@@ -4355,7 +4385,8 @@ ztest_dmu_snapshot_hold(ztest_ds_t *zd, uint64_t id)
                fatal(0, "dmu_objset_snapshot(%s) = %d", fullname, error);
        }
 
-       error = dsl_dataset_user_hold(osname, snapname, tag, B_FALSE, B_TRUE);
+       error = dsl_dataset_user_hold(osname, snapname, tag, B_FALSE,
+           B_TRUE, -1);
        if (error)
                fatal(0, "dsl_dataset_user_hold(%s)", fullname, tag);
 
@@ -4393,7 +4424,7 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id)
        int fd;
        uint64_t offset;
        uint64_t leaves;
-       uint64_t bad = 0x1990c0ffeedecade;
+       uint64_t bad = 0x1990c0ffeedecadeull;
        uint64_t top, leaf;
        char path0[MAXPATHLEN];
        char pathrand[MAXPATHLEN];
@@ -4574,6 +4605,7 @@ ztest_ddt_repair(ztest_ds_t *zd, uint64_t id)
        void *buf;
        blkptr_t blk;
        int copies = 2 * ZIO_DEDUPDITTO_MIN;
+       int i;
 
        blocksize = ztest_random_blocksize();
        blocksize = MIN(blocksize, 2048);       /* because we write so many */
@@ -4614,7 +4646,7 @@ ztest_ddt_repair(ztest_ds_t *zd, uint64_t id)
        /*
         * Write all the copies of our block.
         */
-       for (int i = 0; i < copies; i++) {
+       for (i = 0; i < copies; i++) {
                uint64_t offset = i * blocksize;
                VERIFY(dmu_buf_hold(os, object, offset, FTAG, &db,
                    DMU_READ_NO_PREFETCH) == 0);
@@ -4843,19 +4875,19 @@ ztest_spa_import_export(char *oldname, char *newname)
        /*
         * Import it under the new name.
         */
-       VERIFY3U(0, ==, spa_import(newname, config, NULL));
+       VERIFY3U(0, ==, spa_import(newname, config, NULL, 0));
 
        ztest_walk_pool_directory("pools after import");
 
        /*
         * Try to import it again -- should fail with EEXIST.
         */
-       VERIFY3U(EEXIST, ==, spa_import(newname, config, NULL));
+       VERIFY3U(EEXIST, ==, spa_import(newname, config, NULL, 0));
 
        /*
         * Try to import it under a different name -- should fail with EEXIST.
         */
-       VERIFY3U(EEXIST, ==, spa_import(oldname, config, NULL));
+       VERIFY3U(EEXIST, ==, spa_import(oldname, config, NULL, 0));
 
        /*
         * Verify that the pool is no longer visible under the old name.
@@ -4918,8 +4950,9 @@ ztest_execute(ztest_info_t *zi, uint64_t id)
        ztest_shared_t *zs = ztest_shared;
        ztest_ds_t *zd = &zs->zs_zd[id % zopt_datasets];
        hrtime_t functime = gethrtime();
+       int i;
 
-       for (int i = 0; i < zi->zi_iters; i++)
+       for (i = 0; i < zi->zi_iters; i++)
                zi->zi_func(zd, id);
 
        functime = gethrtime() - functime;
@@ -4982,6 +5015,7 @@ static void
 ztest_dataset_destroy(ztest_shared_t *zs, int d)
 {
        char name[MAXNAMELEN];
+       int t;
 
        ztest_dataset_name(name, zs->zs_pool, d);
 
@@ -4993,7 +5027,7 @@ ztest_dataset_destroy(ztest_shared_t *zs, int d)
         * ztest thread t operates on dataset (t % zopt_datasets),
         * so there may be more than one thing to clean up.
         */
-       for (int t = d; t < zopt_threads; t += zopt_datasets)
+       for (t = d; t < zopt_threads; t += zopt_datasets)
                ztest_dsl_dataset_cleanup(name, t);
 
        (void) dmu_objset_find(name, ztest_objset_destroy_cb, NULL,
@@ -5099,6 +5133,7 @@ ztest_run(ztest_shared_t *zs)
        spa_t *spa;
        thread_t resume_tid;
        int error;
+       int t, d;
 
        ztest_exiting = B_FALSE;
 
@@ -5157,8 +5192,8 @@ ztest_run(ztest_shared_t *zs)
         * we probe a 5-wide window around each power of two.
         * This hits all edge cases, including zero and the max.
         */
-       for (int t = 0; t < 64; t++) {
-               for (int d = -5; d <= 5; d++) {
+       for (t = 0; t < 64; t++) {
+               for (d = -5; d <= 5; d++) {
                        error = dmu_object_info(spa->spa_meta_objset,
                            (1ULL << t) + d, NULL);
                        ASSERT(error == 0 || error == ENOENT ||
@@ -5183,7 +5218,7 @@ ztest_run(ztest_shared_t *zs)
        /*
         * Kick off all the tests that run in parallel.
         */
-       for (int t = 0; t < zopt_threads; t++) {
+       for (t = 0; t < zopt_threads; t++) {
                if (t < zopt_datasets && ztest_dataset_open(zs, t) != 0)
                        return;
                VERIFY(thr_create(0, 0, ztest_thread, (void *)(uintptr_t)t,
@@ -5194,7 +5229,7 @@ ztest_run(ztest_shared_t *zs)
         * Wait for all of the tests to complete.  We go in reverse order
         * so we don't close datasets while threads are still using them.
         */
-       for (int t = zopt_threads - 1; t >= 0; t--) {
+       for (t = zopt_threads - 1; t >= 0; t--) {
                VERIFY(thr_join(tid[t], NULL, NULL) == 0);
                if (t < zopt_datasets)
                        ztest_dataset_close(zs, t);
@@ -5242,6 +5277,13 @@ ztest_run(ztest_shared_t *zs)
        }
 
        kernel_fini();
+
+       list_destroy(&zcl.zcl_callbacks);
+
+       (void) _mutex_destroy(&zcl.zcl_callbacks_lock);
+
+       (void) rwlock_destroy(&zs->zs_name_lock);
+       (void) _mutex_destroy(&zs->zs_vdev_lock);
 }
 
 static void
@@ -5265,7 +5307,7 @@ ztest_freeze(ztest_shared_t *zs)
         */
        while (BP_IS_HOLE(&zd->zd_zilog->zl_header->zh_log)) {
                ztest_dmu_object_alloc_free(zd, 0);
-               zil_commit(zd->zd_zilog, UINT64_MAX, 0);
+               zil_commit(zd->zd_zilog, 0);
        }
 
        txg_wait_synced(spa_get_dsl(spa), 0);
@@ -5292,7 +5334,7 @@ ztest_freeze(ztest_shared_t *zs)
        /*
         * Commit all of the changes we just generated.
         */
-       zil_commit(zd->zd_zilog, UINT64_MAX, 0);
+       zil_commit(zd->zd_zilog, 0);
        txg_wait_synced(spa_get_dsl(spa), 0);
 
        /*
@@ -5311,13 +5353,6 @@ ztest_freeze(ztest_shared_t *zs)
        ztest_dataset_close(zs, 0);
        spa_close(spa, FTAG);
        kernel_fini();
-
-       list_destroy(&zcl.zcl_callbacks);
-
-       (void) _mutex_destroy(&zcl.zcl_callbacks_lock);
-
-       (void) rwlock_destroy(&zs->zs_name_lock);
-       (void) _mutex_destroy(&zs->zs_vdev_lock);
 }
 
 void
@@ -5346,7 +5381,7 @@ print_time(hrtime_t t, char *timebuf)
 }
 
 static nvlist_t *
-make_random_props()
+make_random_props(void)
 {
        nvlist_t *props;
 
@@ -5401,6 +5436,9 @@ ztest_init(ztest_shared_t *zs)
        ztest_freeze(zs);
 
        ztest_run_zdb(zs->zs_pool);
+
+       (void) rwlock_destroy(&zs->zs_name_lock);
+       (void) _mutex_destroy(&zs->zs_vdev_lock);
 }
 
 int
@@ -5414,6 +5452,7 @@ main(int argc, char **argv)
        char timebuf[100];
        char numbuf[6];
        spa_t *spa;
+       int i, f;
 
        (void) setvbuf(stdout, NULL, _IOLBF, 0);
 
@@ -5422,7 +5461,8 @@ main(int argc, char **argv)
        process_options(argc, argv);
 
        /* Override location of zpool.cache */
-       (void) asprintf((char **)&spa_config_path, "%s/zpool.cache", zopt_dir);
+       VERIFY(asprintf((char **)&spa_config_path, "%s/zpool.cache",
+           zopt_dir) != -1);
 
        /*
         * Blow away any existing copy of zpool.cache
@@ -5446,7 +5486,7 @@ main(int argc, char **argv)
        /*
         * Create and initialize our storage pool.
         */
-       for (int i = 1; i <= zopt_init; i++) {
+       for (i = 1; i <= zopt_init; i++) {
                bzero(zs, sizeof (ztest_shared_t));
                if (zopt_verbose >= 3 && zopt_init != 1)
                        (void) printf("ztest_init(), pass %d\n", i);
@@ -5458,7 +5498,7 @@ main(int argc, char **argv)
        zs->zs_proc_start = gethrtime();
        zs->zs_proc_stop = zs->zs_proc_start + zopt_time * NANOSEC;
 
-       for (int f = 0; f < ZTEST_FUNCS; f++) {
+       for (f = 0; f < ZTEST_FUNCS; f++) {
                zi = &zs->zs_info[f];
                *zi = ztest_info[f];
                if (zs->zs_proc_start + zi->zi_interval[0] > zs->zs_proc_stop)
@@ -5480,7 +5520,7 @@ main(int argc, char **argv)
                /*
                 * Initialize the workload counters for each function.
                 */
-               for (int f = 0; f < ZTEST_FUNCS; f++) {
+               for (f = 0; f < ZTEST_FUNCS; f++) {
                        zi = &zs->zs_info[f];
                        zi->zi_call_count = 0;
                        zi->zi_call_time = 0;
@@ -5552,7 +5592,7 @@ main(int argc, char **argv)
                            "Calls", "Time", "Function");
                        (void) printf("%7s %9s   %s\n",
                            "-----", "----", "--------");
-                       for (int f = 0; f < ZTEST_FUNCS; f++) {
+                       for (f = 0; f < ZTEST_FUNCS; f++) {
                                Dl_info dli;
 
                                zi = &zs->zs_info[f];