aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2010-08-26 09:52:39 -0700
committerBrian Behlendorf <[email protected]>2010-08-27 15:28:32 -0700
commitd6320ddb78fa89c4d0fc2af00ae53c7c70992f96 (patch)
tree8a50c251b955ae31a670835ac0c90cfba6d28752 /cmd
parentc5b3a7bbcc321846bb15ff73c6fd6f1c483b6aa6 (diff)
Fix gcc c90 compliance warnings
Fix non-c90 compliant code, for the most part these changes simply deal with where a particular variable is declared. Under c90 it must alway be done at the very start of a block. Signed-off-by: Brian Behlendorf <[email protected]>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/zdb/zdb.c56
-rw-r--r--cmd/zfs/zfs_main.c2
-rw-r--r--cmd/ztest/ztest.c66
3 files changed, 80 insertions, 44 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c
index c6e219df9..45b27b0a4 100644
--- a/cmd/zdb/zdb.c
+++ b/cmd/zdb/zdb.c
@@ -645,8 +645,9 @@ dump_dde(const ddt_t *ddt, const ddt_entry_t *dde, uint64_t index)
char *types[4] = { "ditto", "single", "double", "triple" };
char blkbuf[BP_SPRINTF_LEN];
blkptr_t blk;
+ int p;
- for (int p = 0; p < DDT_PHYS_TYPES; p++, ddp++) {
+ for (p = 0; p < DDT_PHYS_TYPES; p++, ddp++) {
if (ddp->ddp_phys_birth == 0)
continue;
ddt_bp_create(ddt->ddt_checksum, ddk, ddp, &blk);
@@ -733,13 +734,19 @@ dump_ddt(ddt_t *ddt, enum ddt_type type, enum ddt_class class)
static void
dump_all_ddts(spa_t *spa)
{
- ddt_histogram_t ddh_total = { 0 };
- ddt_stat_t dds_total = { 0 };
+ ddt_histogram_t ddh_total;
+ ddt_stat_t dds_total;
+ enum zio_checksum c;
+ enum ddt_type type;
+ enum ddt_class class;
+
+ bzero(&ddh_total, sizeof (ddt_histogram_t));
+ bzero(&dds_total, sizeof (ddt_stat_t));
- for (enum zio_checksum c = 0; c < ZIO_CHECKSUM_FUNCTIONS; c++) {
+ for (c = 0; c < ZIO_CHECKSUM_FUNCTIONS; c++) {
ddt_t *ddt = spa->spa_ddt[c];
- for (enum ddt_type type = 0; type < DDT_TYPES; type++) {
- for (enum ddt_class class = 0; class < DDT_CLASSES;
+ for (type = 0; type < DDT_TYPES; type++) {
+ for (class = 0; class < DDT_CLASSES;
class++) {
dump_ddt(ddt, type, class);
}
@@ -783,6 +790,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, SCL_NONE);
required = vdev_dtl_required(vd);
@@ -796,7 +804,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;
@@ -810,7 +818,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);
}
@@ -826,6 +834,7 @@ dump_history(spa_t *spa)
struct tm t;
char tbuf[30];
char internalstr[MAXPATHLEN];
+ int i;
do {
len = sizeof (buf);
@@ -843,7 +852,7 @@ dump_history(spa_t *spa)
} while (len != 0);
(void) printf("\nHistory:\n");
- for (int i = 0; i < num; i++) {
+ for (i = 0; i < num; i++) {
uint64_t time, txg, ievent;
char *cmd, *intstr;
@@ -904,6 +913,7 @@ sprintf_blkptr_compact(char *blkbuf, const blkptr_t *bp)
{
const dva_t *dva = bp->blk_dva;
int ndvas = dump_opt['d'] > 5 ? BP_GET_NDVAS(bp) : 1;
+ int i;
if (dump_opt['b'] >= 5) {
sprintf_blkptr(blkbuf, bp);
@@ -912,7 +922,7 @@ sprintf_blkptr_compact(char *blkbuf, const blkptr_t *bp)
blkbuf[0] = '\0';
- for (int i = 0; i < ndvas; i++)
+ for (i = 0; i < ndvas; i++)
(void) sprintf(blkbuf + strlen(blkbuf), "%llu:%llx:%llx ",
(u_longlong_t)DVA_GET_VDEV(&dva[i]),
(u_longlong_t)DVA_GET_OFFSET(&dva[i]),
@@ -1751,11 +1761,12 @@ dump_label_uberblocks(vdev_label_t *lbl, uint64_t ashift)
vdev_t vd;
vdev_t *vdp = &vd;
char header[ZDB_MAX_UB_HEADER_SIZE];
+ int i;
vd.vdev_ashift = ashift;
vdp->vdev_top = vdp;
- for (int i = 0; i < VDEV_UBERBLOCK_COUNT(vdp); i++) {
+ for (i = 0; i < VDEV_UBERBLOCK_COUNT(vdp); i++) {
uint64_t uoff = VDEV_UBERBLOCK_OFFSET(vdp, i);
uberblock_t *ub = (void *)((char *)lbl + uoff);
@@ -1777,6 +1788,7 @@ dump_label(const char *dev)
struct stat64 statbuf;
uint64_t psize, ashift;
int len = strlen(dev) + 1;
+ int l;
if (strncmp(dev, "/dev/dsk/", 9) == 0) {
len++;
@@ -1811,7 +1823,7 @@ dump_label(const char *dev)
psize = statbuf.st_size;
psize = P2ALIGN(psize, (uint64_t)sizeof (vdev_label_t));
- for (int l = 0; l < VDEV_LABELS; l++) {
+ for (l = 0; l < VDEV_LABELS; l++) {
nvlist_t *config = NULL;
(void) printf("--------------------------------------------\n");
@@ -1905,13 +1917,14 @@ zdb_count_block(zdb_cb_t *zcb, zilog_t *zilog, const blkptr_t *bp,
dmu_object_type_t type)
{
uint64_t refcnt = 0;
+ int i;
ASSERT(type < ZDB_OT_TOTAL);
if (zilog && zil_bp_tree_add(zilog, bp) != 0)
return;
- for (int i = 0; i < 4; i++) {
+ for (i = 0; i < 4; i++) {
int l = (i < 2) ? BP_GET_LEVEL(bp) : ZB_TOTAL;
int t = (i & 1) ? type : ZDB_OT_TOTAL;
zdb_blkstats_t *zb = &zcb->zcb_type[l][t];
@@ -2063,6 +2076,7 @@ zdb_ddt_leak_init(spa_t *spa, zdb_cb_t *zcb)
ddt_bookmark_t ddb = { 0 };
ddt_entry_t dde;
int error;
+ int p;
while ((error = ddt_walk(spa, &ddb, &dde)) == 0) {
blkptr_t blk;
@@ -2073,7 +2087,7 @@ zdb_ddt_leak_init(spa_t *spa, zdb_cb_t *zcb)
ASSERT(ddt_phys_total_refcnt(&dde) > 1);
- for (int p = 0; p < DDT_PHYS_TYPES; p++, ddp++) {
+ for (p = 0; p < DDT_PHYS_TYPES; p++, ddp++) {
if (ddp->ddp_phys_birth == 0)
continue;
ddt_bp_create(ddb.ddb_checksum,
@@ -2101,12 +2115,13 @@ static void
zdb_leak_init(spa_t *spa, zdb_cb_t *zcb)
{
zcb->zcb_spa = spa;
+ int c, m;
if (!dump_opt['L']) {
vdev_t *rvd = spa->spa_root_vdev;
- 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);
@@ -2129,11 +2144,13 @@ zdb_leak_init(spa_t *spa, zdb_cb_t *zcb)
static void
zdb_leak_fini(spa_t *spa)
{
+ int c, m;
+
if (!dump_opt['L']) {
vdev_t *rvd = spa->spa_root_vdev;
- 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);
@@ -2167,6 +2184,7 @@ dump_block_stats(spa_t *spa)
uint64_t norm_alloc, norm_space, total_alloc, total_found;
int flags = TRAVERSE_PRE | TRAVERSE_PREFETCH_METADATA | TRAVERSE_HARD;
int leaks = 0;
+ int e;
(void) printf("\nTraversing all blocks %s%s%s%s%s...\n",
(dump_opt['c'] || !dump_opt['L']) ? "to verify " : "",
@@ -2201,7 +2219,7 @@ dump_block_stats(spa_t *spa)
if (zcb.zcb_haderrors) {
(void) printf("\nError counts:\n\n");
(void) printf("\t%5s %s\n", "errno", "count");
- for (int e = 0; e < 256; e++) {
+ for (e = 0; e < 256; e++) {
if (zcb.zcb_errors[e] != 0) {
(void) printf("\t%5d %llu\n",
e, (u_longlong_t)zcb.zcb_errors[e]);
diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c
index 951669739..f694ee18f 100644
--- a/cmd/zfs/zfs_main.c
+++ b/cmd/zfs/zfs_main.c
@@ -3238,7 +3238,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);
}
diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c
index 46d3410e3..a6503f477 100644
--- a/cmd/ztest/ztest.c
+++ b/cmd/ztest/ztest.c
@@ -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]);
}
@@ -1731,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);
@@ -1771,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++;
@@ -1816,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;
@@ -2108,11 +2114,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);
@@ -2662,6 +2669,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);
@@ -2669,7 +2678,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);
@@ -2914,6 +2923,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);
@@ -2974,7 +2984,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);
@@ -3163,8 +3173,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);
/*
@@ -3880,6 +3891,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);
@@ -3893,7 +3905,7 @@ 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;
@@ -4240,10 +4252,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));
@@ -4580,6 +4593,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 */
@@ -4620,7 +4634,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);
@@ -4924,8 +4938,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;
@@ -4988,6 +5003,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);
@@ -4999,7 +5015,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,
@@ -5105,6 +5121,7 @@ ztest_run(ztest_shared_t *zs)
spa_t *spa;
thread_t resume_tid;
int error;
+ int t, d;
ztest_exiting = B_FALSE;
@@ -5163,8 +5180,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 ||
@@ -5189,7 +5206,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,
@@ -5200,7 +5217,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);
@@ -5423,6 +5440,7 @@ main(int argc, char **argv)
char timebuf[100];
char numbuf[6];
spa_t *spa;
+ int i, f;
(void) setvbuf(stdout, NULL, _IOLBF, 0);
@@ -5455,7 +5473,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);
@@ -5467,7 +5485,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)
@@ -5489,7 +5507,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;
@@ -5561,7 +5579,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];