From db7b497cbdd6eb264cf2ab90bb8be82d361f34cd Mon Sep 17 00:00:00 2001 From: Tomohiro Kusumi Date: Wed, 23 Dec 2015 16:06:53 +0900 Subject: [PATCH] sbin/hammer: Remove global variable NumVolumes Only newfs_hammer uses this, but doesn't need to be global. (Keeping a number of volumes isn't that important either, because it can be retrieved directly from volume headers or by counting the number of elements in the volume_info list) --- sbin/hammer/hammer.c | 3 --- sbin/hammer/hammer_util.h | 1 - sbin/hammer/ondisk.c | 1 - sbin/newfs_hammer/newfs_hammer.c | 19 ++++++++++--------- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/sbin/hammer/hammer.c b/sbin/hammer/hammer.c index 4b61c7147a..44d1a79e0e 100644 --- a/sbin/hammer/hammer.c +++ b/sbin/hammer/hammer.c @@ -615,9 +615,6 @@ hammer_parsedevs(const char *blkdevs) if (volnum != vol->ondisk->vol_count) errx(1, "Volume header says %d volumes, but %d specified.", vol->ondisk->vol_count, volnum); - - assert(NumVolumes == 0); - NumVolumes = volnum; } static diff --git a/sbin/hammer/hammer_util.h b/sbin/hammer/hammer_util.h index 8a132785eb..d0c06c963c 100644 --- a/sbin/hammer/hammer_util.h +++ b/sbin/hammer/hammer_util.h @@ -149,7 +149,6 @@ extern int64_t UndoBufferSize; extern int DebugOpt; extern const char *ScoreBoardFile; extern const char *RestrictTarget; -extern int NumVolumes; extern int RootVolNo; extern struct volume_list VolList; extern int UseReadBehind; diff --git a/sbin/hammer/ondisk.c b/sbin/hammer/ondisk.c index 71f0ba7936..cc02cd9503 100644 --- a/sbin/hammer/ondisk.c +++ b/sbin/hammer/ondisk.c @@ -51,7 +51,6 @@ uuid_t Hammer_FSId; int64_t BootAreaSize; int64_t MemAreaSize; int64_t UndoBufferSize; -int NumVolumes; int RootVolNo = -1; int UseReadBehind = -4; int UseReadAhead = 4; diff --git a/sbin/newfs_hammer/newfs_hammer.c b/sbin/newfs_hammer/newfs_hammer.c index 5e7f30bfb1..8ba185f1b0 100644 --- a/sbin/newfs_hammer/newfs_hammer.c +++ b/sbin/newfs_hammer/newfs_hammer.c @@ -59,6 +59,7 @@ main(int ac, char **av) off_t avg_vol_size; int ch; int i; + int nvols; int eflag = 0; const char *label = NULL; struct volume_info *vol; @@ -171,17 +172,17 @@ main(int ac, char **av) */ ac -= optind; av += optind; - NumVolumes = ac; + nvols = ac; RootVolNo = 0; - if (NumVolumes == 0) { + if (nvols == 0) { fprintf(stderr, "newfs_hammer: You must specify at least one " "special file (volume)\n"); exit(1); } - if (NumVolumes > HAMMER_MAX_VOLUMES) { + if (nvols > HAMMER_MAX_VOLUMES) { fprintf(stderr, "newfs_hammer: The maximum number of volumes is %d\n", HAMMER_MAX_VOLUMES); @@ -189,7 +190,7 @@ main(int ac, char **av) } total = 0; - for (i = 0; i < NumVolumes; ++i) { + for (i = 0; i < nvols; ++i) { vol = setup_volume(i, av[i], 1, O_RDWR); /* @@ -238,7 +239,7 @@ main(int ac, char **av) /* * Calculate defaults for the boot and memory area sizes. */ - avg_vol_size = total / NumVolumes; + avg_vol_size = total / nvols; BootAreaSize = init_boot_area_size(BootAreaSize, avg_vol_size); MemAreaSize = init_mem_area_size(MemAreaSize, avg_vol_size); @@ -246,10 +247,10 @@ main(int ac, char **av) * Format the volumes. Format the root volume first so we can * bootstrap the freemap. */ - format_volume(get_volume(RootVolNo), NumVolumes, label, total); - for (i = 0; i < NumVolumes; ++i) { + format_volume(get_volume(RootVolNo), nvols, label, total); + for (i = 0; i < nvols; ++i) { if (i != RootVolNo) - format_volume(get_volume(i), NumVolumes, label, total); + format_volume(get_volume(i), nvols, label, total); } /* @@ -264,7 +265,7 @@ main(int ac, char **av) printf("---------------------------------------------\n"); printf("%d volume%s total size %s version %d\n", - NumVolumes, (NumVolumes == 1 ? "" : "s"), + nvols, (nvols == 1 ? "" : "s"), sizetostr(total), HammerVersion); printf("root-volume: %s\n", vol->name); printf("boot-area-size: %s\n", sizetostr(BootAreaSize)); -- 2.41.0