OSDN Git Service

e2fsck,resize2fs: fix gcc -Wall nits
authorTheodore Ts'o <tytso@mit.edu>
Sun, 29 May 2016 17:36:20 +0000 (13:36 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 29 May 2016 17:36:20 +0000 (13:36 -0400)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/pass1.c
e2fsck/pass2.c
e2fsck/pass5.c
e2fsck/rehash.c
resize/main.c
resize/resize2fs.c

index c924d31..23720ae 100644 (file)
@@ -87,7 +87,7 @@ struct process_block_struct {
                                inode_modified:1;
        blk64_t         num_blocks;
        blk64_t         max_blocks;
-       e2_blkcnt_t     last_block;
+       blk64_t         last_block;
        e2_blkcnt_t     last_init_lblock;
        e2_blkcnt_t     last_db_block;
        int             num_illegal_blocks;
@@ -2514,7 +2514,7 @@ void e2fsck_clear_inode(e2fsck_t ctx, ext2_ino_t ino,
  * line up.
  */
 static int has_unaligned_cluster_map(e2fsck_t ctx,
-                                    blk64_t last_pblk, e2_blkcnt_t last_lblk,
+                                    blk64_t last_pblk, blk64_t last_lblk,
                                     blk64_t pblk, blk64_t lblk)
 {
        blk64_t cluster_mask;
@@ -2614,7 +2614,7 @@ static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx,
                        problem = PR_1_EXTENT_ENDS_BEYOND;
                else if (is_leaf && is_dir &&
                         ((extent.e_lblk + extent.e_len) >
-                         (1 << (21 - ctx->fs->super->s_log_block_size))))
+                         (1U << (21 - ctx->fs->super->s_log_block_size))))
                        problem = PR_1_TOOBIG_DIR;
 
                if (is_leaf && problem == 0 && extent.e_len > 0 &&
@@ -2783,7 +2783,7 @@ report_problem:
                 * pass 3 allocating empty directory blocks to fill the hole.
                 */
                if (try_repairs && is_dir &&
-                   pb->last_block + 1 < (e2_blkcnt_t)extent.e_lblk) {
+                   pb->last_block + 1 < extent.e_lblk) {
                        blk64_t new_lblk;
 
                        new_lblk = pb->last_block + 1;
@@ -3051,7 +3051,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
 
        pb.ino = ino;
        pb.num_blocks = 0;
-       pb.last_block = -1;
+       pb.last_block = ~0;
        pb.last_init_lblock = -1;
        pb.last_db_block = -1;
        pb.num_illegal_blocks = 0;
@@ -3178,29 +3178,28 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
                pb.num_blocks *= (fs->blocksize / 512);
        pb.num_blocks *= EXT2FS_CLUSTER_RATIO(fs);
 #if 0
-       printf("inode %u, i_size = %u, last_block = %lld, i_blocks=%llu, num_blocks = %llu\n",
+       printf("inode %u, i_size = %u, last_block = %llu, i_blocks=%llu, num_blocks = %llu\n",
               ino, inode->i_size, pb.last_block, ext2fs_inode_i_blocks(fs, inode),
               pb.num_blocks);
 #endif
        if (pb.is_dir) {
-               int nblock = inode->i_size >> EXT2_BLOCK_SIZE_BITS(fs->super);
+               unsigned nblock = inode->i_size >> EXT2_BLOCK_SIZE_BITS(fs->super);
                if (inode->i_flags & EXT4_INLINE_DATA_FL) {
                        int flags;
-                       size_t size;
+                       size_t sz = 0;
                        errcode_t err;
 
-                       size = 0;
                        flags = ctx->fs->flags;
                        ctx->fs->flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS;
                        err = ext2fs_inline_data_size(ctx->fs, pctx->ino,
-                                                     &size);
+                                                     &sz);
                        ctx->fs->flags = (flags &
                                          EXT2_FLAG_IGNORE_CSUM_ERRORS) |
                                         (ctx->fs->flags &
                                          ~EXT2_FLAG_IGNORE_CSUM_ERRORS);
-                       if (err || size != inode->i_size) {
+                       if (err || sz != inode->i_size) {
                                bad_size = 7;
-                               pctx->num = size;
+                               pctx->num = sz;
                        }
                } else if (inode->i_size & (fs->blocksize - 1))
                        bad_size = 5;
index 6a7215a..b204f44 100644 (file)
@@ -779,11 +779,11 @@ static errcode_t insert_dirent_tail(ext2_filsys fs, void *dirbuf)
                d = NEXT_DIRENT(d);
 
        if (d != top) {
-               size_t min_size = EXT2_DIR_REC_LEN(
+               unsigned int min_size = EXT2_DIR_REC_LEN(
                                ext2fs_dirent_name_len(dirbuf));
-               if (min_size > top - (void *)d)
+               if (min_size > (char *)top - (char *)d)
                        return EXT2_ET_DIR_NO_SPACE_FOR_CSUM;
-               d->rec_len = top - (void *)d;
+               d->rec_len = (char *)top - (char *)d;
        }
 
        t = (struct ext2_dir_entry_tail *)top;
@@ -1148,7 +1148,7 @@ skip_checksum:
                        if ((offset + rec_len > max_block_size) ||
                            (rec_len < 12) ||
                            ((rec_len % 4) != 0) ||
-                           ((ext2fs_dirent_name_len(dirent) + EXT2_DIR_ENTRY_HEADER_LEN) > rec_len)) {
+                           (((unsigned) ext2fs_dirent_name_len(dirent) + EXT2_DIR_ENTRY_HEADER_LEN) > rec_len)) {
                                if (fix_problem(ctx, PR_2_DIR_CORRUPTED,
                                                &cd->pctx)) {
 #ifdef WORDS_BIGENDIAN
@@ -1908,7 +1908,7 @@ static int allocate_dir_block(e2fsck_t ctx,
         * Update the inode block count
         */
        ext2fs_iblk_add_blocks(fs, &inode, 1);
-       if (EXT2_I_SIZE(&inode) < (db->blockcnt+1) * fs->blocksize) {
+       if (EXT2_I_SIZE(&inode) < ((__u64) db->blockcnt+1) * fs->blocksize) {
                pctx->errcode = ext2fs_inode_size_set(fs, &inode,
                                        (db->blockcnt+1) * fs->blocksize);
                if (pctx->errcode) {
index 4a7e53c..fb55b7e 100644 (file)
@@ -390,7 +390,7 @@ redo_counts:
                 * to do a discard operation.
                 */
                if (!first_block_in_bg ||
-                   (group == (int)fs->group_desc_count - 1) ||
+                   (group == fs->group_desc_count - 1) ||
                    (ctx->options & E2F_OPT_DISCARD))
                        goto no_optimize;
 
index 1285adb..10e5d67 100644 (file)
@@ -210,9 +210,8 @@ static EXT2_QSORT_TYPE name_cmp(const void *a, const void *b)
 {
        const struct hash_entry *he_a = (const struct hash_entry *) a;
        const struct hash_entry *he_b = (const struct hash_entry *) b;
-       unsigned int he_a_len, he_b_len;
+       unsigned int he_a_len, he_b_len, min_len;
        int     ret;
-       int     min_len;
 
        he_a_len = ext2fs_dirent_name_len(he_a->dir);
        he_b_len = ext2fs_dirent_name_len(he_b->dir);
@@ -309,7 +308,7 @@ static errcode_t get_next_block(ext2_filsys fs, struct out_dir *outdir,
  */
 static void mutate_name(char *str, unsigned int *len)
 {
-       int     i;
+       int i;
        unsigned int l = *len;
 
        /*
@@ -320,7 +319,7 @@ static void mutate_name(char *str, unsigned int *len)
                if (!isdigit(str[i]))
                        break;
        }
-       if ((i == l-1) || (str[i] != '~')) {
+       if ((i == (int)l - 1) || (str[i] != '~')) {
                if (((l-1) & 3) < 2)
                        l += 2;
                else
@@ -404,7 +403,7 @@ static int duplicate_search_and_fix(e2fsck_t ctx, ext2_filsys fs,
                for (j=0; j < fd->num_array; j++) {
                        if ((i==j) ||
                            (new_len !=
-                            ext2fs_dirent_name_len(fd->harray[j].dir)) ||
+                            (unsigned) ext2fs_dirent_name_len(fd->harray[j].dir)) ||
                            strncmp(new_name, fd->harray[j].dir->name, new_len))
                                continue;
                        mutate_name(new_name, &new_len);
@@ -702,7 +701,6 @@ static int write_dir_block(ext2_filsys fs,
                           void *priv_data)
 {
        struct write_dir_struct *wd = (struct write_dir_struct *) priv_data;
-       blk64_t blk;
        char    *dir, *buf = 0;
 
 #ifdef REHASH_DEBUG
index f25df40..5a99483 100644 (file)
@@ -167,11 +167,12 @@ static void bigalloc_check(ext2_filsys fs, int force)
        }
 }
 
-static int resize2fs_setup_tdb(const char *device_name, char *undo_file,
+static int resize2fs_setup_tdb(const char *device, char *undo_file,
                               io_manager *io_ptr)
 {
        errcode_t retval = ENOMEM;
-       char *tdb_dir = NULL, *tdb_file = NULL;
+       const char *tdb_dir = NULL;
+       char *tdb_file = NULL;
        char *dev_name, *tmp_name;
 
        /* (re)open a specific undo file */
@@ -186,7 +187,7 @@ static int resize2fs_setup_tdb(const char *device_name, char *undo_file,
                printf(_("Overwriting existing filesystem; this can be undone "
                         "using the command:\n"
                         "    e2undo %s %s\n\n"),
-                       undo_file, device_name);
+                       undo_file, device);
                return retval;
        }
 
@@ -202,7 +203,7 @@ static int resize2fs_setup_tdb(const char *device_name, char *undo_file,
            access(tdb_dir, W_OK))
                return 0;
 
-       tmp_name = strdup(device_name);
+       tmp_name = strdup(device);
        if (!tmp_name)
                goto errout;
        dev_name = basename(tmp_name);
@@ -230,7 +231,7 @@ static int resize2fs_setup_tdb(const char *device_name, char *undo_file,
                goto errout;
        printf(_("Overwriting existing filesystem; this can be undone "
                 "using the command:\n"
-                "    e2undo %s %s\n\n"), tdb_file, device_name);
+                "    e2undo %s %s\n\n"), tdb_file, device);
 
        free(tdb_file);
        return 0;
index 8d33e54..b94d439 100644 (file)
@@ -73,7 +73,7 @@ static inline int is_inode_bm(ext2_filsys fs, unsigned int grp, blk64_t blk)
        return blk == ext2fs_inode_bitmap_loc(fs, grp);
 }
 
-static inline int is_inode_tb(ext2_filsys fs, unsigned int grp, blk64_t blk)
+static int is_inode_tb(ext2_filsys fs, unsigned int grp, blk64_t blk)
 {
        return blk >= ext2fs_inode_table_loc(fs, grp) &&
               blk < (ext2fs_inode_table_loc(fs, grp) +
@@ -329,8 +329,8 @@ static errcode_t resize_group_descriptors(ext2_resize_t rfs, blk64_t new_size)
                copy_size = EXT2_DESC_SIZE(rfs->new_fs->super);
        for (i = 0; i < rfs->old_fs->group_desc_count; i++) {
                memcpy(n, o, copy_size);
-               n += EXT2_DESC_SIZE(rfs->new_fs->super);
-               o += EXT2_DESC_SIZE(rfs->old_fs->super);
+               n = (char *)n + EXT2_DESC_SIZE(rfs->new_fs->super);
+               o = (char *)o + EXT2_DESC_SIZE(rfs->old_fs->super);
        }
 
        ext2fs_free_mem(&rfs->new_fs->group_desc);
@@ -584,7 +584,7 @@ static void fix_uninit_block_bitmaps(ext2_filsys fs)
 {
        blk64_t         blk, lblk;
        dgrp_t          g;
-       int             i;
+       unsigned int    i;
 
        if (!ext2fs_has_group_desc_csum(fs))
                return;
@@ -604,7 +604,7 @@ static void fix_uninit_block_bitmaps(ext2_filsys fs)
                ext2fs_mark_block_bitmap2(fs->block_map,
                                          ext2fs_inode_bitmap_loc(fs, g));
                for (i = 0, blk = ext2fs_inode_table_loc(fs, g);
-                    i < (unsigned int) fs->inode_blocks_per_group;
+                    i < fs->inode_blocks_per_group;
                     i++, blk++)
                        ext2fs_mark_block_bitmap2(fs->block_map, blk);
        }
@@ -631,12 +631,12 @@ static errcode_t free_gdp_blocks(ext2_filsys fs,
                                 ext2_filsys old_fs,
                                 dgrp_t group)
 {
-       blk64_t blk;
-       int     j;
-       dgrp_t  i;
+       blk64_t         blk;
+       unsigned int    j;
+       dgrp_t          i;
        ext2fs_block_bitmap bg_map = NULL;
-       errcode_t retval = 0;
-       dgrp_t count = old_fs->group_desc_count - fs->group_desc_count;
+       errcode_t       retval = 0;
+       dgrp_t          count = old_fs->group_desc_count - fs->group_desc_count;
 
        /* If bigalloc, don't free metadata living in the same cluster */
        if (EXT2FS_CLUSTER_RATIO(fs) > 1) {
@@ -1256,7 +1256,8 @@ static void mark_fs_metablock(ext2_resize_t rfs,
  */
 static errcode_t blocks_to_move(ext2_resize_t rfs)
 {
-       int             j, has_super;
+       unsigned int    j;
+       int             has_super;
        dgrp_t          i, max_groups, g;
        blk64_t         blk, group_blk;
        blk64_t         old_blocks, new_blocks, group_end, cluster_freed;
@@ -1662,8 +1663,7 @@ static errcode_t block_mover(ext2_resize_t rfs)
        ext2_filsys             fs = rfs->new_fs;
        ext2_filsys             old_fs = rfs->old_fs;
        errcode_t               retval;
-       __u64                   size;
-       int                     c;
+       __u64                   c, size;
        int                     to_move, moved;
        ext2_badblocks_list     badblock_list = 0;
        int                     bb_modified = 0;
@@ -2298,7 +2298,8 @@ static errcode_t move_itables(ext2_resize_t rfs)
        char            *cp;
        blk64_t         old_blk, new_blk, blk, cluster_freed;
        errcode_t       retval;
-       int             j, to_move, moved;
+       int             to_move, moved;
+       unsigned int    j;
        ext2fs_block_bitmap     new_bmap = NULL;
 
        max_groups = fs->group_desc_count;