diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c
index 19462b867a..1325b93ea6 100644
--- a/cmd/zfs/zfs_main.c
+++ b/cmd/zfs/zfs_main.c
@@ -2397,7 +2397,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);
diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c
index 65c27e0cb0..dc34d2d8e6 100644
--- a/cmd/ztest/ztest.c
+++ b/cmd/ztest/ztest.c
@@ -1231,6 +1231,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);
@@ -1238,7 +1240,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);
@@ -1622,11 +1624,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)
@@ -1668,11 +1675,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);
diff --git a/module/zfs/vdev_label.c b/module/zfs/vdev_label.c
index fea44226ee..e33d2660e0 100644
--- a/module/zfs/vdev_label.c
+++ b/module/zfs/vdev_label.c
@@ -510,6 +510,7 @@ vdev_label_init(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason)
 	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);