Whamcloud - gitweb
Fix various signed/unsigned gcc warnings
authorTheodore Ts'o <tytso@mit.edu>
Sun, 16 Nov 2008 15:03:00 +0000 (10:03 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 16 Nov 2008 15:06:59 +0000 (10:06 -0500)
Some of these could affect filesystems between 2^31 and 2^32-1 blocks.

Thanks to Valerie Aurora Henson for pointing out the problems in
lib/ext2fs/alloc_tables.c, which led me to do a "make gcc-wall" scan
over the source tree.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck/pass1.c
e2fsck/pass2.c
lib/ext2fs/alloc.c
lib/ext2fs/alloc_tables.c
lib/ext2fs/inode.c
resize/resize2fs.c

index 8ad0871..3e1a94d 100644 (file)
@@ -404,7 +404,7 @@ static void check_is_really_dir(e2fsck_t ctx, struct problem_context *pctx,
        const char              *old_op;
        errcode_t               retval;
        blk_t                   blk;
-       int                     i, rec_len, not_device = 0;
+       unsigned int            i, rec_len, not_device = 0;
 
        if (LINUX_S_ISDIR(inode->i_mode) || LINUX_S_ISREG(inode->i_mode) ||
            LINUX_S_ISLNK(inode->i_mode) || inode->i_block[0] == 0)
@@ -1935,7 +1935,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
                        bad_size = 4;
                else if ((extent_fs && (inode->i_flags & EXT4_EXTENTS_FL)) &&
                         size >
-                        ((1LL << (32 + EXT2_BLOCK_SIZE_BITS(fs->super))) - 1))
+                        ((1ULL << (32 + EXT2_BLOCK_SIZE_BITS(fs->super))) - 1))
                        /* too big for an extent-based file - 32bit ee_block */
                        bad_size = 6;
        }
index c36bfcf..f479df6 100644 (file)
@@ -717,7 +717,7 @@ static int check_dir_block(ext2_filsys fs,
        const char *            old_op;
        int                     dir_modified = 0;
        int                     dot_state;
-       int                     rec_len;
+       unsigned int            rec_len;
        blk_t                   block_nr = db->blk;
        ext2_ino_t              ino = db->ino;
        ext2_ino_t              subdir_parent;
@@ -855,7 +855,7 @@ out_htree:
                if (((offset + rec_len) > fs->blocksize) ||
                    (rec_len < 12) ||
                    ((rec_len % 4) != 0) ||
-                   (((dirent->name_len & 0xFF)+8) > rec_len)) {
+                   (((dirent->name_len & (unsigned) 0xFF)+8) > rec_len)) {
                        if (fix_problem(ctx, PR_2_DIR_CORRUPTED, &cd->pctx)) {
                                salvage_directory(fs, dirent, prev, &offset);
                                dir_modified++;
index 230bec9..be2b56b 100644 (file)
 /*
  * Check for uninit block bitmaps and deal with them appropriately
  */
-static check_block_uninit(ext2_filsys fs, ext2fs_block_bitmap map,
+static void check_block_uninit(ext2_filsys fs, ext2fs_block_bitmap map,
                          dgrp_t group)
 {
-       int             i;
+       blk_t           i;
        blk_t           blk, super_blk, old_desc_blk, new_desc_blk;
        int             old_desc_blocks;
 
@@ -75,11 +75,10 @@ static check_block_uninit(ext2_filsys fs, ext2fs_block_bitmap map,
 /*
  * Check for uninit inode bitmaps and deal with them appropriately
  */
-static check_inode_uninit(ext2_filsys fs, ext2fs_inode_bitmap map,
+static void check_inode_uninit(ext2_filsys fs, ext2fs_inode_bitmap map,
                          dgrp_t group)
 {
-       int             i;
-       ext2_ino_t      ino;
+       ext2_ino_t      i, ino;
 
        if (!(EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
                                         EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) ||
index 4d2535e..9b4c057 100644 (file)
@@ -119,7 +119,7 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
                start_blk = group_blk;
 
        if (flexbg_size) {
-               int prev_block = 0;
+               blk_t prev_block = 0;
                if (group && fs->group_desc[group-1].bg_block_bitmap)
                        prev_block = fs->group_desc[group-1].bg_block_bitmap;
                start_blk = flexbg_offset(fs, group, prev_block, bmap,
@@ -147,7 +147,7 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
        }
 
        if (flexbg_size) {
-               int prev_block = 0;
+               blk_t prev_block = 0;
                if (group && fs->group_desc[group-1].bg_inode_bitmap)
                        prev_block = fs->group_desc[group-1].bg_inode_bitmap;
                start_blk = flexbg_offset(fs, group, prev_block, bmap,
index b75cb77..b3ac9f2 100644 (file)
@@ -17,6 +17,7 @@
 #if HAVE_ERRNO_H
 #include <errno.h>
 #endif
+#include <time.h>
 #if HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
index f392867..abe05f5 100644 (file)
@@ -176,8 +176,7 @@ errout:
  */
 static void fix_uninit_block_bitmaps(ext2_filsys fs)
 {
-       int             i;
-       blk_t           blk, super_blk, old_desc_blk, new_desc_blk;
+       blk_t           i, blk, super_blk, old_desc_blk, new_desc_blk;
        int             old_desc_blocks;
        dgrp_t          g;
 
@@ -1375,8 +1374,8 @@ errout:
 struct istruct {
        ext2_resize_t rfs;
        errcode_t       err;
-       unsigned long   max_dirs;
-       int             num;
+       unsigned int    max_dirs;
+       unsigned int    num;
 };
 
 static int check_and_change_inodes(ext2_ino_t dir,