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>
This commit is contained in:
Andreas Dilger 2012-11-29 05:47:52 -07:00 committed by Theodore Ts'o
parent f797cf3e37
commit 1d6fd6d0c3
13 changed files with 59 additions and 49 deletions

View File

@ -1173,7 +1173,7 @@ int main (int argc, char *argv[])
int old_bitmaps;
__u32 features[3];
char *cp;
int qtype; /* quota type */
int qtype = -99; /* quota type */
clear_problem_context(&pctx);
sigcatcher_setup();

View File

@ -795,7 +795,6 @@ void e2fsck_set_bitmap_type(ext2_filsys fs, unsigned int default_type,
const char *profile_name, unsigned int *old_type)
{
unsigned type;
errcode_t retval;
if (old_type)
*old_type = fs->default_bitmap_type;

View File

@ -70,7 +70,7 @@ static void print_tree(struct rb_root *root)
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 @@ static int check_tree(struct rb_root *root, const char *msg)
}
old = ext;
}
return 0;
return;
err_out:
printf("%s\n", msg);
@ -123,8 +123,8 @@ err_out:
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,

View File

@ -95,7 +95,7 @@ static _BMAP_INLINE_ errcode_t block_dind_bmap(ext2_filsys fs, int flags,
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 @@ static _BMAP_INLINE_ errcode_t block_tind_bmap(ext2_filsys fs, int flags,
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;

View File

@ -302,9 +302,7 @@ leave:
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 @@ errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags,
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;

View File

@ -496,7 +496,7 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t num_blocks, int flags)
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 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t num_blocks, int flags)
return retval;
if (mount_flags & EXT2_MF_MOUNTED) {
#if HAVE_EXT2_IOCTLS
int f = 0;
#endif
strcat(jfile, "/.journal");
/*
@ -519,7 +522,6 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t num_blocks, int flags)
#if HAVE_EXT2_IOCTLS
fd = open(jfile, O_RDONLY);
if (fd >= 0) {
f = 0;
ioctl(fd, EXT2_IOC_SETFLAGS, &f);
close(fd);
}

View File

@ -154,7 +154,6 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
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);

View File

@ -472,7 +472,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
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 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
}
#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 @@ static errcode_t unix_discard(io_channel channel, unsigned long long block,
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 @@ static errcode_t unix_discard(io_channel channel, unsigned long long block,
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;

View File

@ -117,7 +117,6 @@ static int compute_num_blocks_proc(ext2_filsys fs, blk64_t *blocknr,
int ref_offset EXT2FS_ATTR((unused)),
void *private)
{
blk64_t block;
blk64_t *num_blocks = private;
*num_blocks += 1;
@ -128,7 +127,6 @@ errcode_t quota_inode_truncate(ext2_filsys fs, ext2_ino_t ino)
{
struct ext2_inode inode;
errcode_t err;
int i;
if ((err = ext2fs_read_inode(fs, ino, &inode)))
return err;

View File

@ -176,8 +176,7 @@ static void get_random_bytes(void *buf, int nbytes)
{
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 @@ static void get_random_bytes(void *buf, int nbytes)
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;

View File

@ -68,19 +68,18 @@ extern int optind;
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 @@ static void set_o_direct(int dev, unsigned char *buffer, size_t size,
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;

View File

@ -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 @@ static char *parse_word(char **buf)
*buf = next;
return word;
}
#endif
/*
* Helper function which checks a file in /etc/mtab format to see if a

View File

@ -146,6 +146,7 @@ static int int_log10(unsigned long long arg)
return l;
}
#ifdef __linux__
static int parse_version_number(const char *s)
{
int major, minor, rev;
@ -167,6 +168,7 @@ static int parse_version_number(const char *s)
return 0;
return ((((major * 256) + minor) * 256) + rev);
}
#endif
/*
* Helper function for read_bb_file and test_disk