From e64e6761aa22f31123a91206a5686526f7b9c6c0 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 5 Apr 2012 12:13:05 -0700 Subject: [PATCH] Fix gcc -Wall nitpicks Signed-off-by: "Theodore Ts'o" --- debugfs/debugfs.c | 2 +- e2fsck/pass5.c | 31 ++++++++++++++----------------- e2fsck/quota.c | 3 --- e2fsck/unix.c | 4 ++-- lib/ext2fs/blkmap64_rb.c | 10 ++++------ lib/ext2fs/crc32c.c | 4 ++-- lib/ext2fs/ext2fs.h | 2 -- lib/ext2fs/gen_bitmap64.c | 2 ++ lib/ext2fs/get_pathname.c | 10 +++++----- lib/ext2fs/icount.c | 2 -- lib/ext2fs/rbtree.h | 2 +- misc/e2image.c | 7 +++---- misc/tune2fs.c | 2 +- 13 files changed, 35 insertions(+), 46 deletions(-) diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index e82dddb..590468d 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -1000,7 +1000,7 @@ void do_freei(int argc, char *argv[]) if (common_args_process(argc, argv, 2, 3, argv[0], " [num]", CHECK_FS_RW | CHECK_FS_BITMAPS)) - return 1; + return; if (check_fs_read_write(argv[0])) return; diff --git a/e2fsck/pass5.c b/e2fsck/pass5.c index 148473c..8ebddf8 100644 --- a/e2fsck/pass5.c +++ b/e2fsck/pass5.c @@ -99,12 +99,11 @@ static void e2fsck_discard_blocks(e2fsck_t ctx, blk64_t start, * is 1-based, it means that we need to adjust it by -1 in this * function to compute right offset in the particular inode table. */ -static void e2fsck_discard_inodes(e2fsck_t ctx, int group, - int start, int count) +static void e2fsck_discard_inodes(e2fsck_t ctx, dgrp_t group, + ext2_ino_t start, int count) { ext2_filsys fs = ctx->fs; blk64_t blk, num; - int orig = count; /* * Sanity check for 'start' @@ -196,12 +195,12 @@ static void check_block_bitmaps(e2fsck_t ctx) { ext2_filsys fs = ctx->fs; blk64_t i; - int *free_array; + unsigned int *free_array; int group = 0; - int blocks = 0; + unsigned int blocks = 0; blk64_t free_blocks = 0; blk64_t first_free = ext2fs_blocks_count(fs->super); - int group_free = 0; + unsigned int group_free = 0; int actual, bitmap; struct problem_context pctx; int problem, save_problem, fixit, had_problem; @@ -213,11 +212,10 @@ static void check_block_bitmaps(e2fsck_t ctx) int cmp_block = 0; int redo_flag = 0; blk64_t super_blk, old_desc_blk, new_desc_blk; - io_manager manager = ctx->fs->io->manager; clear_problem_context(&pctx); - free_array = (int *) e2fsck_allocate_memory(ctx, - fs->group_desc_count * sizeof(int), "free block count array"); + free_array = (unsigned int *) e2fsck_allocate_memory(ctx, + fs->group_desc_count * sizeof(unsigned int), "free block count array"); if ((B2C(fs->super->s_first_data_block) < ext2fs_get_block_bitmap_start2(ctx->block_found_map)) || @@ -489,8 +487,8 @@ static void check_inode_bitmaps(e2fsck_t ctx) int dirs_count = 0; int group = 0; unsigned int inodes = 0; - int *free_array; - int *dir_array; + ext2_ino_t *free_array; + ext2_ino_t *dir_array; int actual, bitmap; errcode_t retval; struct problem_context pctx; @@ -498,15 +496,14 @@ static void check_inode_bitmaps(e2fsck_t ctx) int csum_flag; int skip_group = 0; int redo_flag = 0; - io_manager manager = ctx->fs->io->manager; - int first_free = fs->super->s_inodes_per_group + 1; + ext2_ino_t first_free = fs->super->s_inodes_per_group + 1; clear_problem_context(&pctx); - free_array = (int *) e2fsck_allocate_memory(ctx, - fs->group_desc_count * sizeof(int), "free inode count array"); + free_array = (ext2_ino_t *) e2fsck_allocate_memory(ctx, + fs->group_desc_count * sizeof(ext2_ino_t), "free inode count array"); - dir_array = (int *) e2fsck_allocate_memory(ctx, - fs->group_desc_count * sizeof(int), "directory count array"); + dir_array = (ext2_ino_t *) e2fsck_allocate_memory(ctx, + fs->group_desc_count * sizeof(ext2_ino_t), "directory count array"); if ((1 < ext2fs_get_inode_bitmap_start2(ctx->inode_used_map)) || (fs->super->s_inodes_count > diff --git a/e2fsck/quota.c b/e2fsck/quota.c index 3ae934a..a5bce98 100644 --- a/e2fsck/quota.c +++ b/e2fsck/quota.c @@ -21,10 +21,7 @@ static void move_quota_inode(ext2_filsys fs, ext2_ino_t from_ino, ext2_ino_t to_ino, int qtype) { - struct ext2_super_block *sb = fs->super; - ext2_ino_t ino; struct ext2_inode inode; - errcode_t retval; char qf_name[QUOTA_NAME_LEN]; if (ext2fs_read_inode(fs, from_ino, &inode)) diff --git a/e2fsck/unix.c b/e2fsck/unix.c index 190deaf..63d1c65 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -262,7 +262,7 @@ static int is_on_batt(void) f = fopen("/sys/class/power_supply/AC/online", "r"); if (f) { - if (fscanf(f, "%d\n", &acflag) == 1) { + if (fscanf(f, "%u\n", &acflag) == 1) { fclose(f); return (!acflag); } @@ -1040,7 +1040,7 @@ static errcode_t try_open_fs(e2fsck_t ctx, int flags, io_manager io_ptr, static const char *my_ver_string = E2FSPROGS_VERSION; static const char *my_ver_date = E2FSPROGS_DATE; -int e2fsck_check_mmp(ext2_filsys fs, e2fsck_t ctx) +static int e2fsck_check_mmp(ext2_filsys fs, e2fsck_t ctx) { struct mmp_struct *mmp_s; unsigned int mmp_check_interval; diff --git a/lib/ext2fs/blkmap64_rb.c b/lib/ext2fs/blkmap64_rb.c index aba7cfd..7ab72f4 100644 --- a/lib/ext2fs/blkmap64_rb.c +++ b/lib/ext2fs/blkmap64_rb.c @@ -318,7 +318,6 @@ rb_test_bit(struct ext2fs_rb_private *bp, __u64 bit) struct rb_node *parent = NULL; struct rb_node **n = &bp->root.rb_node; struct bmap_rb_extent *ext; - int i=0; rcursor = *bp->rcursor; if (!rcursor) @@ -542,8 +541,6 @@ static int rb_remove_extent(__u64 start, __u64 count, static int rb_mark_bmap(ext2fs_generic_bitmap bitmap, __u64 arg) { struct ext2fs_rb_private *bp; - int i; - bp = (struct ext2fs_rb_private *) bitmap->private; arg -= bitmap->start; @@ -580,7 +577,6 @@ static void rb_mark_bmap_extent(ext2fs_generic_bitmap bitmap, __u64 arg, unsigned int num) { struct ext2fs_rb_private *bp; - struct bmap_rb_extent *new_ext; bp = (struct ext2fs_rb_private *) bitmap->private; arg -= bitmap->start; @@ -592,7 +588,6 @@ static void rb_unmark_bmap_extent(ext2fs_generic_bitmap bitmap, __u64 arg, unsigned int num) { struct ext2fs_rb_private *bp; - int ret; bp = (struct ext2fs_rb_private *) bitmap->private; arg -= bitmap->start; @@ -752,8 +747,11 @@ static void rb_print_stats(ext2fs_generic_bitmap bitmap) __u64 max_size = 0; __u64 min_size = ULONG_MAX; __u64 size = 0, avg_size = 0; + double eff; +#ifdef BMAP_STATS_OPS __u64 mark_all, test_all; - double eff, m_hit = 0.0, t_hit = 0.0; + double m_hit = 0.0, t_hit = 0.0; +#endif bp = (struct ext2fs_rb_private *) bitmap->private; diff --git a/lib/ext2fs/crc32c.c b/lib/ext2fs/crc32c.c index 6be4336..da2c60b 100644 --- a/lib/ext2fs/crc32c.c +++ b/lib/ext2fs/crc32c.c @@ -35,9 +35,9 @@ #define __force #define min(x, y) ((x) > (y) ? (y) : (x)) #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask)) -#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) +#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1) #define ALIGN(x, a) __ALIGN_KERNEL((x), (a)) -#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a))) +#define PTR_ALIGN(p, a) ((__typeof__(p))ALIGN((unsigned long)(p), (a))) #include "crc32c_defs.h" #include "ext2fs.h" diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index 4e7711a..c6b0b24 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -1706,8 +1706,6 @@ _INLINE_ __u64 ext2fs_div64_ceil(__u64 a, __u64 b) _INLINE_ int ext2fs_open_file(const char *pathname, int flags, mode_t mode) { - va_list args; - if (mode) #if defined(HAVE_OPEN64) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED) return open64(pathname, flags, mode); diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c index b57df54..e765d2c 100644 --- a/lib/ext2fs/gen_bitmap64.c +++ b/lib/ext2fs/gen_bitmap64.c @@ -177,8 +177,10 @@ errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic, void ext2fs_print_bmap_statistics(ext2fs_generic_bitmap bitmap) { struct ext2_bmap_statistics *stats = &bitmap->stats; +#ifdef BMAP_STATS_OPS float mark_seq_perc = 0.0, test_seq_perc = 0.0; float mark_back_perc = 0.0, test_back_perc = 0.0; +#endif double inuse; struct timeval now; diff --git a/lib/ext2fs/get_pathname.c b/lib/ext2fs/get_pathname.c index 3320994..52aea62 100644 --- a/lib/ext2fs/get_pathname.c +++ b/lib/ext2fs/get_pathname.c @@ -100,16 +100,16 @@ static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir, retval = ext2fs_dir_iterate(fs, dir, 0, buf, get_pathname_proc, &gp); if (retval == EXT2_ET_NO_DIRECTORY) { - char buf[32]; + char tmp[32]; if (ino) - snprintf(buf, sizeof(buf), "<%u>/<%u>", dir, ino); + snprintf(tmp, sizeof(tmp), "<%u>/<%u>", dir, ino); else - snprintf(buf, sizeof(buf), "<%u>", dir); - retval = ext2fs_get_mem(strlen(buf)+1, name); + snprintf(tmp, sizeof(tmp), "<%u>", dir); + retval = ext2fs_get_mem(strlen(tmp)+1, name); if (retval) goto cleanup; - strcpy(*name, buf); + strcpy(*name, tmp); return 0; } else if (retval) goto cleanup; diff --git a/lib/ext2fs/icount.c b/lib/ext2fs/icount.c index 8b46eda..84b74a9 100644 --- a/lib/ext2fs/icount.c +++ b/lib/ext2fs/icount.c @@ -351,9 +351,7 @@ static struct ext2_icount_el *insert_icount_el(ext2_icount_t icount, static struct ext2_icount_el *get_icount_el(ext2_icount_t icount, ext2_ino_t ino, int create) { - float range; int low, high, mid; - ext2_ino_t lowval, highval; if (!icount || !icount->list) return 0; diff --git a/lib/ext2fs/rbtree.h b/lib/ext2fs/rbtree.h index 972297b..16defb5 100644 --- a/lib/ext2fs/rbtree.h +++ b/lib/ext2fs/rbtree.h @@ -104,7 +104,7 @@ static inline struct page * rb_insert_page_cache(struct inode * inode, #endif #define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) struct rb_node diff --git a/misc/e2image.c b/misc/e2image.c index 4a28900..3a956ef 100644 --- a/misc/e2image.c +++ b/misc/e2image.c @@ -55,7 +55,7 @@ char * device_name = NULL; static void lseek_error_and_exit(int errnum) { - perror("seek"); + fprintf(stderr, "seek: %s\n", error_message(errnum)); exit(1); } @@ -537,8 +537,7 @@ static void output_meta_data_blocks(ext2_filsys fs, int fd) ext2fs_free_mem(&buf); } -static void init_l1_table(struct ext2_super_block *sb, - struct ext2_qcow2_image *image) +static void init_l1_table(struct ext2_qcow2_image *image) { __u64 *l1_table; errcode_t ret; @@ -724,7 +723,7 @@ static int initialize_qcow2_image(int fd, ext2_filsys fs, image->hdr = header; /* Initialize l1 and l2 tables */ - init_l1_table(sb, image); + init_l1_table(image); init_l2_cache(image); return 0; diff --git a/misc/tune2fs.c b/misc/tune2fs.c index e49b433..f1f0bcf 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -754,7 +754,7 @@ void handle_quota_options(ext2_filsys fs) void parse_quota_opts(const char *opts) { - char *buf, *token, *next, *p, *arg; + char *buf, *token, *next, *p; int len; len = strlen(opts); -- 1.8.3.1