misc: cleanup unused variables on MacOS
Clean up unused variables found by GCC on MacOS.
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index 6348777..48db71a 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -1173,7 +1173,7 @@
int old_bitmaps;
__u32 features[3];
char *cp;
- int qtype; /* quota type */
+ int qtype = -99; /* quota type */
clear_problem_context(&pctx);
sigcatcher_setup();
diff --git a/e2fsck/util.c b/e2fsck/util.c
index 7c4caab..f3ba645 100644
--- a/e2fsck/util.c
+++ b/e2fsck/util.c
@@ -795,7 +795,6 @@
const char *profile_name, unsigned int *old_type)
{
unsigned type;
- errcode_t retval;
if (old_type)
*old_type = fs->default_bitmap_type;
diff --git a/lib/ext2fs/blkmap64_rb.c b/lib/ext2fs/blkmap64_rb.c
index 7196e90..6007238 100644
--- a/lib/ext2fs/blkmap64_rb.c
+++ b/lib/ext2fs/blkmap64_rb.c
@@ -70,7 +70,7 @@
printf("\t\t\t=================================\n");
}
-static int check_tree(struct rb_root *root, const char *msg)
+static void check_tree(struct rb_root *root, const char *msg)
{
struct rb_node *new_node, *node, *next;
struct bmap_rb_extent *ext, *old = NULL;
@@ -115,7 +115,7 @@
}
old = ext;
}
- return 0;
+ return;
err_out:
printf("%s\n", msg);
@@ -123,8 +123,8 @@
exit(1);
}
#else
-#define check_tree(root, msg) 0
-#define print_tree(root, msg) 0
+#define check_tree(root, msg) do {} while (0)
+#define print_tree(root, msg) do {} while (0)
#endif
static void rb_get_new_extent(struct bmap_rb_extent **ext, __u64 start,
diff --git a/lib/ext2fs/bmap.c b/lib/ext2fs/bmap.c
index 16d51e0..aadd22e 100644
--- a/lib/ext2fs/bmap.c
+++ b/lib/ext2fs/bmap.c
@@ -95,7 +95,7 @@
int *blocks_alloc,
blk_t nr, blk_t *ret_blk)
{
- blk_t b;
+ blk_t b = 0;
errcode_t retval;
blk_t addr_per_block;
@@ -115,7 +115,7 @@
int *blocks_alloc,
blk_t nr, blk_t *ret_blk)
{
- blk_t b;
+ blk_t b = 0;
errcode_t retval;
blk_t addr_per_block;
diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c
index bf532ae..6a223df 100644
--- a/lib/ext2fs/ismounted.c
+++ b/lib/ext2fs/ismounted.c
@@ -302,9 +302,7 @@
errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags,
char *mtpt, int mtlen)
{
- struct stat st_buf;
errcode_t retval = 0;
- int fd;
if (is_swap_device(device)) {
*mount_flags = EXT2_MF_MOUNTED | EXT2_MF_SWAP;
@@ -327,15 +325,18 @@
return retval;
#ifdef __linux__ /* This only works on Linux 2.6+ systems */
- if ((stat(device, &st_buf) != 0) ||
- !S_ISBLK(st_buf.st_mode))
- return 0;
- fd = open(device, O_RDONLY | O_EXCL);
- if (fd < 0) {
- if (errno == EBUSY)
- *mount_flags |= EXT2_MF_BUSY;
- } else
- close(fd);
+ {
+ struct stat st_buf;
+
+ if (stat(device, &st_buf) == 0 && S_ISBLK(st_buf.st_mode)) {
+ int fd = open(device, O_RDONLY | O_EXCL);
+
+ if (fd >= 0)
+ close(fd);
+ else if (errno == EBUSY)
+ *mount_flags |= EXT2_MF_BUSY;
+ }
+ }
#endif
return 0;
diff --git a/lib/ext2fs/mkjournal.c b/lib/ext2fs/mkjournal.c
index 30ccdd2..c154d91 100644
--- a/lib/ext2fs/mkjournal.c
+++ b/lib/ext2fs/mkjournal.c
@@ -496,7 +496,7 @@
ext2_ino_t journal_ino;
struct stat st;
char jfile[1024];
- int mount_flags, f;
+ int mount_flags;
int fd = -1;
if (flags & EXT2_MKJOURNAL_NO_MNT_CHECK)
@@ -507,6 +507,9 @@
return retval;
if (mount_flags & EXT2_MF_MOUNTED) {
+#if HAVE_EXT2_IOCTLS
+ int f = 0;
+#endif
strcat(jfile, "/.journal");
/*
@@ -519,7 +522,6 @@
#if HAVE_EXT2_IOCTLS
fd = open(jfile, O_RDONLY);
if (fd >= 0) {
- f = 0;
ioctl(fd, EXT2_IOC_SETFLAGS, &f);
close(fd);
}
diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c
index 53f6ec4..3f3ed65 100644
--- a/lib/ext2fs/rw_bitmaps.c
+++ b/lib/ext2fs/rw_bitmaps.c
@@ -154,7 +154,6 @@
int block_nbytes = EXT2_CLUSTERS_PER_GROUP(fs->super) / 8;
int inode_nbytes = EXT2_INODES_PER_GROUP(fs->super) / 8;
int csum_flag = 0;
- int do_image = fs->flags & EXT2_FLAG_IMAGE_FILE;
unsigned int cnt;
blk64_t blk;
blk64_t blk_itr = EXT2FS_B2C(fs, fs->super->s_first_data_block);
diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c
index 7371654..19be630 100644
--- a/lib/ext2fs/unix_io.c
+++ b/lib/ext2fs/unix_io.c
@@ -472,7 +472,7 @@
io_channel io = NULL;
struct unix_private_data *data = NULL;
errcode_t retval;
- int open_flags, zeroes = 0;
+ int open_flags;
int f_nocache = 0;
ext2fs_struct_stat st;
#ifdef __linux__
@@ -550,9 +550,12 @@
}
#ifdef BLKDISCARDZEROES
- ioctl(data->dev, BLKDISCARDZEROES, &zeroes);
- if (zeroes)
- io->flags |= CHANNEL_FLAGS_DISCARD_ZEROES;
+ {
+ int zeroes = 0;
+ if (ioctl(data->dev, BLKDISCARDZEROES, &zeroes) == 0 &&
+ zeroes)
+ io->flags |= CHANNEL_FLAGS_DISCARD_ZEROES;
+ }
#endif
#if defined(__CYGWIN__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
@@ -920,7 +923,6 @@
unsigned long long count)
{
struct unix_private_data *data;
- __uint64_t range[2];
int ret;
EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
@@ -929,6 +931,8 @@
if (channel->flags & CHANNEL_FLAGS_BLOCK_DEVICE) {
#ifdef BLKDISCARD
+ __uint64_t range[2];
+
range[0] = (__uint64_t)(block) * channel->block_size;
range[1] = (__uint64_t)(count) * channel->block_size;
diff --git a/lib/quota/quotaio.c b/lib/quota/quotaio.c
index 7cdd653..ac34a80 100644
--- a/lib/quota/quotaio.c
+++ b/lib/quota/quotaio.c
@@ -117,7 +117,6 @@
int ref_offset EXT2FS_ATTR((unused)),
void *private)
{
- blk64_t block;
blk64_t *num_blocks = private;
*num_blocks += 1;
@@ -128,7 +127,6 @@
{
struct ext2_inode inode;
errcode_t err;
- int i;
if ((err = ext2fs_read_inode(fs, ino, &inode)))
return err;
diff --git a/lib/uuid/gen_uuid.c b/lib/uuid/gen_uuid.c
index 42d7563..efa4e3d 100644
--- a/lib/uuid/gen_uuid.c
+++ b/lib/uuid/gen_uuid.c
@@ -176,8 +176,7 @@
{
int i, n = nbytes, fd = get_random_fd();
int lose_counter = 0;
- unsigned char *cp = (unsigned char *) buf;
- unsigned short tmp_seed[3];
+ unsigned char *cp = buf;
if (fd >= 0) {
while (n > 0) {
@@ -200,12 +199,16 @@
for (cp = buf, i = 0; i < nbytes; i++)
*cp++ ^= (rand() >> 7) & 0xFF;
#ifdef DO_JRAND_MIX
- memcpy(tmp_seed, jrand_seed, sizeof(tmp_seed));
- jrand_seed[2] = jrand_seed[2] ^ syscall(__NR_gettid);
- for (cp = buf, i = 0; i < nbytes; i++)
- *cp++ ^= (jrand48(tmp_seed) >> 7) & 0xFF;
- memcpy(jrand_seed, tmp_seed,
- sizeof(jrand_seed)-sizeof(unsigned short));
+ {
+ unsigned short tmp_seed[3];
+
+ memcpy(tmp_seed, jrand_seed, sizeof(tmp_seed));
+ jrand_seed[2] = jrand_seed[2] ^ syscall(__NR_gettid);
+ for (cp = buf, i = 0; i < nbytes; i++)
+ *cp++ ^= (jrand48(tmp_seed) >> 7) & 0xFF;
+ memcpy(jrand_seed, tmp_seed,
+ sizeof(jrand_seed) - sizeof(unsigned short));
+ }
#endif
return;
diff --git a/misc/badblocks.c b/misc/badblocks.c
index 890d510..f37cf26 100644
--- a/misc/badblocks.c
+++ b/misc/badblocks.c
@@ -68,19 +68,18 @@
const char * program_name = "badblocks";
const char * done_string = N_("done \n");
-static int v_flag = 0; /* verbose */
-static int w_flag = 0; /* do r/w test: 0=no, 1=yes,
+static int v_flag; /* verbose */
+static int w_flag; /* do r/w test: 0=no, 1=yes,
* 2=non-destructive */
-static int s_flag = 0; /* show progress of test */
-static int force = 0; /* force check of mounted device */
-static int t_flag = 0; /* number of test patterns */
-static int t_max = 0; /* allocated test patterns */
-static unsigned int *t_patts = NULL; /* test patterns */
-static int current_O_DIRECT = 0; /* Current status of O_DIRECT flag */
-static int use_buffered_io = 0;
-static int exclusive_ok = 0;
-static unsigned int max_bb = 0; /* Abort test if more than this number of bad blocks has been encountered */
-static unsigned int d_flag = 0; /* delay factor between reads */
+static int s_flag; /* show progress of test */
+static int force; /* force check of mounted device */
+static int t_flag; /* number of test patterns */
+static int t_max; /* allocated test patterns */
+static unsigned int *t_patts; /* test patterns */
+static int use_buffered_io;
+static int exclusive_ok;
+static unsigned int max_bb; /* Abort test if more than this number of bad blocks has been encountered */
+static unsigned int d_flag; /* delay factor between reads */
static struct timeval time_start;
#define T_INC 32
@@ -286,6 +285,7 @@
ext2_loff_t offset)
{
#ifdef O_DIRECT
+ static int current_O_DIRECT; /* Current status of O_DIRECT flag */
int new_flag = O_DIRECT;
int flag;
diff --git a/misc/ismounted.c b/misc/ismounted.c
index 4671af8..6aa0e04 100644
--- a/misc/ismounted.c
+++ b/misc/ismounted.c
@@ -40,6 +40,7 @@
#include "et/com_err.h"
+#ifdef HAVE_SETMNTENT
static char *skip_over_blank(char *cp)
{
while (*cp && isspace(*cp))
@@ -69,6 +70,7 @@
*buf = next;
return word;
}
+#endif
/*
* Helper function which checks a file in /etc/mtab format to see if a
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 0f9a299..df9c1c1 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -146,6 +146,7 @@
return l;
}
+#ifdef __linux__
static int parse_version_number(const char *s)
{
int major, minor, rev;
@@ -167,6 +168,7 @@
return 0;
return ((((major * 256) + minor) * 256) + rev);
}
+#endif
/*
* Helper function for read_bb_file and test_disk