Whamcloud - gitweb
Fix miscellaneous compiler warnings using "make gcc-wall"
authorTheodore Ts'o <tytso@mit.edu>
Mon, 26 Jul 2021 03:38:39 +0000 (23:38 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 26 Jul 2021 03:38:39 +0000 (23:38 -0400)
Address a number of signed vs. unsigned comparison errors, unused
function parameters, casts which drop const, etc.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
22 files changed:
e2fsck/e2fsck.h
e2fsck/extents.c
e2fsck/journal.c
e2fsck/pass1.c
e2fsck/pass2.c
e2fsck/rehash.c
lib/ext2fs/blknum.c
lib/ext2fs/compiler.h
lib/ext2fs/crc32c.c
lib/ext2fs/ext2_fs.h
lib/ext2fs/ext2fs.h
lib/ext2fs/imager.c
lib/ext2fs/io_manager.c
lib/ext2fs/kernel-jbd.h
lib/ext2fs/link.c
lib/ext2fs/rw_bitmaps.c
lib/ext2fs/tdb.c
lib/ext2fs/unix_io.c
lib/support/dict.c
lib/support/dict.h
misc/e2image.c
misc/mke2fs.c

index 15d043e..5704316 100644 (file)
@@ -247,9 +247,9 @@ struct e2fsck_fc_replay_state {
        struct extent_list fc_extent_list;
        int fc_replay_num_tags;
        int fc_replay_expected_off;
-       int fc_current_pass;
+       enum passtype fc_current_pass;
        int fc_cur_tag;
-       int fc_crc;
+       unsigned int fc_crc;
        __u16 fc_super_state;
 };
 
index 0274e05..01879f5 100644 (file)
@@ -196,7 +196,7 @@ static int find_blocks(ext2_filsys fs, blk64_t *blocknr, e2_blkcnt_t blockcnt,
        return 0;
 }
 
-errcode_t rewrite_extent_replay(e2fsck_t ctx, struct extent_list *list,
+static errcode_t rewrite_extent_replay(e2fsck_t ctx, struct extent_list *list,
                                       struct ext2_inode_large *inode)
 {
        errcode_t               retval;
index 62a965a..fe4e018 100644 (file)
@@ -419,8 +419,8 @@ static int make_room(struct extent_list *list, int i)
 
 static int ex_compar(const void *arg1, const void *arg2)
 {
-       struct ext2fs_extent *ex1 = (struct ext2fs_extent *)arg1;
-       struct ext2fs_extent *ex2 = (struct ext2fs_extent *)arg2;
+       const struct ext2fs_extent *ex1 = (const struct ext2fs_extent *)arg1;
+       const struct ext2fs_extent *ex2 = (const struct ext2fs_extent *)arg2;
 
        if (ex1->e_lblk < ex2->e_lblk)
                return -1;
@@ -431,8 +431,8 @@ static int ex_compar(const void *arg1, const void *arg2)
 
 static int ex_len_compar(const void *arg1, const void *arg2)
 {
-       struct ext2fs_extent *ex1 = (struct ext2fs_extent *)arg1;
-       struct ext2fs_extent *ex2 = (struct ext2fs_extent *)arg2;
+       const struct ext2fs_extent *ex1 = (const struct ext2fs_extent *)arg1;
+       const struct ext2fs_extent *ex2 = (const struct ext2fs_extent *)arg2;
 
        if (ex1->e_len < ex2->e_len)
                return 1;
@@ -445,7 +445,7 @@ static int ex_len_compar(const void *arg1, const void *arg2)
 
 static void ex_sort_and_merge(struct extent_list *list)
 {
-       int i, j;
+       unsigned int i, j;
 
        if (list->count < 2)
                return;
@@ -490,8 +490,8 @@ static void ex_sort_and_merge(struct extent_list *list)
 static int ext4_modify_extent_list(e2fsck_t ctx, struct extent_list *list,
                                        struct ext2fs_extent *ex, int del)
 {
-       int ret;
-       int i, offset;
+       int ret, offset;
+       unsigned int i;
        struct ext2fs_extent add_ex = *ex;
 
        /* First let's create a hole from ex->e_lblk of length ex->e_len */
@@ -575,7 +575,7 @@ static int ext4_del_extent_from_list(e2fsck_t ctx, struct extent_list *list,
        return ext4_modify_extent_list(ctx, list, ex, 1 /* delete */);
 }
 
-static int ext4_fc_read_extents(e2fsck_t ctx, int ino)
+static int ext4_fc_read_extents(e2fsck_t ctx, ino_t ino)
 {
        struct extent_list *extent_list = &ctx->fc_replay_state.fc_extent_list;
 
@@ -594,7 +594,7 @@ static int ext4_fc_read_extents(e2fsck_t ctx, int ino)
  * for the inode so that we can flush all of them at once and it also saves us
  * from continuously growing and shrinking the extent tree.
  */
-static void ext4_fc_flush_extents(e2fsck_t ctx, int ino)
+static void ext4_fc_flush_extents(e2fsck_t ctx, ino_t ino)
 {
        struct extent_list *extent_list = &ctx->fc_replay_state.fc_extent_list;
 
@@ -607,7 +607,9 @@ static void ext4_fc_flush_extents(e2fsck_t ctx, int ino)
 
 /* Helper struct for dentry replay routines */
 struct dentry_info_args {
-       int parent_ino, dname_len, ino, inode_len;
+       ino_t parent_ino;
+       int dname_len;
+       ino_t ino;
        char *dname;
 };
 
@@ -630,7 +632,7 @@ static inline int tl_to_darg(struct dentry_info_args *darg,
               val + sizeof(struct ext4_fc_dentry_info),
               darg->dname_len);
        darg->dname[darg->dname_len] = 0;
-       jbd_debug(1, "%s: %s, ino %d, parent %d\n",
+       jbd_debug(1, "%s: %s, ino %lu, parent %lu\n",
                tag == EXT4_FC_TAG_CREAT ? "create" :
                (tag == EXT4_FC_TAG_LINK ? "link" :
                (tag == EXT4_FC_TAG_UNLINK ? "unlink" : "error")),
@@ -795,7 +797,8 @@ static int ext4_fc_handle_add_extent(e2fsck_t ctx, __u8 *val)
 {
        struct ext2fs_extent extent;
        struct ext4_fc_add_range add_range;
-       int ret = 0, ino;
+       ino_t ino;
+       int ret = 0;
 
        memcpy(&add_range, val, sizeof(add_range));
        ino = le32_to_cpu(add_range.fc_ino);
index 9d43089..dde862a 100644 (file)
@@ -2058,9 +2058,7 @@ void e2fsck_pass1(e2fsck_t ctx)
                goto endit;
        }
 
-       if (ctx->large_dirs && !ext2fs_has_feature_largedir(ctx->fs->super)) {
-               ext2_filsys fs = ctx->fs;
-
+       if (ctx->large_dirs && !ext2fs_has_feature_largedir(fs->super)) {
                if (fix_problem(ctx, PR_2_FEATURE_LARGE_DIRS, &pctx)) {
                        ext2fs_set_feature_largedir(fs->super);
                        fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
@@ -2728,7 +2726,7 @@ static int handle_htree(e2fsck_t ctx, struct problem_context *pctx,
        if (root->indirect_levels > ext2_dir_htree_level(fs) &&
            !ext2fs_has_feature_largedir(fs->super)) {
                int blockbits = EXT2_BLOCK_SIZE_BITS(fs->super) + 10;
-               int idx_pb = 1 << (blockbits - 3);
+               unsigned idx_pb = 1 << (blockbits - 3);
 
                /* compare inode size/blocks vs. max-sized 2-level htree */
                if (EXT2_I_SIZE(pctx->inode) <
index 8ebdf76..f00cb40 100644 (file)
@@ -360,8 +360,9 @@ static int dict_de_cf_cmp(const void *cmp_ctx, const void *a, const void *b)
        de_b = (const struct ext2_dir_entry *) b;
        b_len = ext2fs_dirent_name_len(de_b);
 
-       return ext2fs_casefold_cmp(tbl, (unsigned char *) de_a->name, a_len,
-                                  (unsigned char *) de_b->name, b_len);
+       return ext2fs_casefold_cmp(tbl,
+                                  (const unsigned char *) de_a->name, a_len,
+                                  (const unsigned char *) de_b->name, b_len);
 }
 
 /*
@@ -791,7 +792,7 @@ static void salvage_directory(ext2_filsys fs,
         * Special case of directory entry of size 8: copy what's left
         * of the directory block up to cover up the invalid hole.
         */
-       if ((left >= ext2fs_dir_rec_len(1, hash_in_dirent)) &&
+       if ((left >= (int) ext2fs_dir_rec_len(1, hash_in_dirent)) &&
             (rec_len == EXT2_DIR_ENTRY_HEADER_LEN)) {
                memmove(cp, cp+EXT2_DIR_ENTRY_HEADER_LEN, left);
                memset(cp + left, 0, EXT2_DIR_ENTRY_HEADER_LEN);
@@ -1297,7 +1298,7 @@ skip_checksum:
 
        if (cf_dir) {
                dict_init(&de_dict, DICTCOUNT_T_MAX, dict_de_cf_cmp);
-               dict_set_cmp_context(&de_dict, (void *)ctx->fs->encoding);
+               dict_set_cmp_context(&de_dict, (const void *)ctx->fs->encoding);
        } else {
                dict_init(&de_dict, DICTCOUNT_T_MAX, dict_de_cmp);
        }
@@ -1313,7 +1314,7 @@ skip_checksum:
                unsigned int name_len;
                /* csum entry is not checked here, so don't worry about it */
                int extended = (dot_state > 1) && hash_in_dirent;
-               int min_dir_len = ext2fs_dir_rec_len(1, extended);
+               unsigned int min_dir_len = ext2fs_dir_rec_len(1, extended);
 
                problem = 0;
                if (!inline_data_size || dot_state > 1) {
index 7d30ff0..8cc36f2 100644 (file)
@@ -164,7 +164,7 @@ static int fill_dir_block(ext2_filsys fs,
        /* While the directory block is "hot", index it. */
        dir_offset = 0;
        while (dir_offset < fs->blocksize) {
-               int min_rec = EXT2_DIR_ENTRY_HEADER_LEN;
+               unsigned int min_rec = EXT2_DIR_ENTRY_HEADER_LEN;
                int extended = hash_in_entry && !is_fake_entry(fs, blockcnt, dir_offset);
 
                if (extended)
@@ -548,7 +548,7 @@ static errcode_t copy_dir_entries(e2fsck_t ctx,
        int                     csum_size = 0;
        struct                  ext2_dir_entry_tail *t;
        int hash_in_entry = ext4_hash_in_dirent(fd->inode);
-       int min_rec_len = ext2fs_dir_rec_len(1, hash_in_entry);
+       unsigned int min_rec_len = ext2fs_dir_rec_len(1, hash_in_entry);
 
        if (ctx->htree_slack_percentage == 255) {
                profile_get_uint(ctx->profile, "options",
index 3458b12..04839d8 100644 (file)
@@ -204,7 +204,7 @@ struct ext2_group_desc *ext2fs_group_desc(ext2_filsys fs,
        struct ext2_group_desc *ret_gdp;
        errcode_t       retval;
        static char     *buf = 0;
-       static int      bufsize = 0;
+       static unsigned bufsize = 0;
        blk64_t         blk;
        int             desc_size = EXT2_DESC_SIZE(fs->super) & ~7;
        int             desc_per_blk = EXT2_DESC_PER_BLOCK(fs->super);
index 42faa61..baed2a6 100644 (file)
@@ -4,8 +4,9 @@
 #include <stddef.h>
 
 #ifdef __GNUC__
-#define container_of(ptr, type, member) ({                     \
-       const __typeof__( ((type *)0)->member ) *__mptr = (ptr);        \
+
+#define container_of(ptr, type, member) ({                             \
+       __typeof__( ((type *)0)->member ) *__mptr = (ptr);      \
        (type *)( (char *)__mptr - offsetof(type,member) );})
 #else
 #define container_of(ptr, type, member)                                \
index 8ad0050..df5cf9b 100644 (file)
 
 #if CRC_LE_BITS > 8 || CRC_BE_BITS > 8
 
+#if CRC_LE_BITS < 64 && CRC_BE_BITS < 64
+#define CRC_INLINE inline
+#else
+#define CRC_INLINE
+#endif
+
 /* implements slicing-by-4 or slicing-by-8 algorithm */
-static inline uint32_t
+static CRC_INLINE uint32_t
 crc32_body(uint32_t crc, unsigned char const *buf, size_t len,
           const uint32_t (*tab)[256])
 {
index e92a045..01d2573 100644 (file)
 #endif
 #endif
 
+#ifndef __nonstring
+#ifdef __has_attribute
+#if __has_attribute(__nonstring__)
+#define __nonstring                    __attribute__((__nonstring__))
+#else
+#define __nonstring
+#endif /* __has_attribute(__nonstring__) */
+#else
+# define __nonstring
+#endif /* __has_attribute */
+#endif /* __nonstring */
+
 /*
  * The second extended filesystem constants/structures
  */
@@ -525,8 +537,8 @@ struct ext2_inode_large {
 #endif  /* __GNU__ */
 #endif /* defined(__KERNEL__) || defined(__linux__) */
 
-#define inode_uid(inode)       ((inode).i_uid | (inode).osd2.linux2.l_i_uid_high << 16)
-#define inode_gid(inode)       ((inode).i_gid | (inode).osd2.linux2.l_i_gid_high << 16)
+#define inode_uid(inode)       ((inode).i_uid | (unsigned)(inode).osd2.linux2.l_i_uid_high << 16)
+#define inode_gid(inode)       ((inode).i_gid | (unsigned)(inode).osd2.linux2.l_i_gid_high << 16)
 #define inode_projid(inode)    ((inode).i_projid)
 #define ext2fs_set_i_uid_high(inode,x) ((inode).osd2.linux2.l_i_uid_high = (x))
 #define ext2fs_set_i_gid_high(inode,x) ((inode).osd2.linux2.l_i_gid_high = (x))
@@ -683,9 +695,9 @@ struct ext2_super_block {
        __u32   s_feature_compat;       /* compatible feature set */
 /*060*/        __u32   s_feature_incompat;     /* incompatible feature set */
        __u32   s_feature_ro_compat;    /* readonly-compatible feature set */
-/*068*/        __u8    s_uuid[16];             /* 128-bit uuid for volume */
-/*078*/        __u8    s_volume_name[EXT2_LABEL_LEN];  /* volume name, no NUL? */
-/*088*/        __u8    s_last_mounted[64];     /* directory last mounted on, no NUL? */
+/*068*/        __u8    s_uuid[16] __nonstring;         /* 128-bit uuid for volume */
+/*078*/        __u8    s_volume_name[EXT2_LABEL_LEN] __nonstring;      /* volume name, no NUL? */
+/*088*/        __u8    s_last_mounted[64] __nonstring; /* directory last mounted on, no NUL? */
 /*0c8*/        __u32   s_algorithm_usage_bitmap; /* For compression */
        /*
         * Performance hints.  Directory preallocation should only
@@ -697,7 +709,7 @@ struct ext2_super_block {
        /*
         * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set.
         */
-/*0d0*/        __u8    s_journal_uuid[16];     /* uuid of journal superblock */
+/*0d0*/        __u8    s_journal_uuid[16] __nonstring; /* uuid of journal superblock */
 /*0e0*/        __u32   s_journal_inum;         /* inode number of journal file */
        __u32   s_journal_dev;          /* device number of journal file */
        __u32   s_last_orphan;          /* start of list of inodes to delete */
@@ -733,15 +745,15 @@ struct ext2_super_block {
        __u32   s_first_error_time;     /* first time an error happened */
        __u32   s_first_error_ino;      /* inode involved in first error */
 /*1a0*/        __u64   s_first_error_block;    /* block involved in first error */
-       __u8    s_first_error_func[32]; /* function where error hit, no NUL? */
+       __u8    s_first_error_func[32] __nonstring;     /* function where error hit, no NUL? */
 /*1c8*/        __u32   s_first_error_line;     /* line number where error happened */
        __u32   s_last_error_time;      /* most recent time of an error */
 /*1d0*/        __u32   s_last_error_ino;       /* inode involved in last error */
        __u32   s_last_error_line;      /* line number where error happened */
        __u64   s_last_error_block;     /* block involved of last error */
-/*1e0*/        __u8    s_last_error_func[32];  /* function where error hit, no NUL? */
+/*1e0*/        __u8    s_last_error_func[32] __nonstring;      /* function where error hit, no NUL? */
 #define EXT4_S_ERR_END ext4_offsetof(struct ext2_super_block, s_mount_opts)
-/*200*/        __u8    s_mount_opts[64];       /* default mount options, no NUL? */
+/*200*/        __u8    s_mount_opts[64] __nonstring;   /* default mount options, no NUL? */
 /*240*/        __u32   s_usr_quota_inum;       /* inode number of user quota file */
        __u32   s_grp_quota_inum;       /* inode number of group quota file */
        __u32   s_overhead_clusters;    /* overhead blocks/clusters in fs */
@@ -1137,8 +1149,8 @@ struct mmp_struct {
        __u32   mmp_magic;              /* Magic number for MMP */
        __u32   mmp_seq;                /* Sequence no. updated periodically */
        __u64   mmp_time;               /* Time last updated (seconds) */
-       __u8    mmp_nodename[64];       /* Node updating MMP block, no NUL? */
-       __u8    mmp_bdevname[32];       /* Bdev updating MMP block, no NUL? */
+       __u8    mmp_nodename[64] __nonstring;   /* Node updating MMP block, no NUL? */
+       __u8    mmp_bdevname[32] __nonstring;   /* Bdev updating MMP block, no NUL? */
        __u16   mmp_check_interval;     /* Changed mmp_check_interval */
        __u16   mmp_pad1;
        __u32   mmp_pad2[226];
index df150f0..0ac3e45 100644 (file)
 #define EXT2FS_ATTR(x)
 #endif
 
+#ifndef __nonstring
+#ifdef __has_attribute
+#if __has_attribute(__nonstring__)
+#define __nonstring                    __attribute__((__nonstring__))
+#else
+#define __nonstring
+#endif /* __has_attribute(__nonstring__) */
+#else
+# define __nonstring
+#endif /* __has_attribute */
+#endif /* __nonstring */
+
 #ifdef CONFIG_TDB
 #define EXT2FS_NO_TDB_UNUSED
 #else
index 586227f..b56e0e9 100644 (file)
@@ -272,7 +272,7 @@ errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd,
                retval = errno;
                goto errout;
        }
-       if (actual != (ssize_t)fs->blocksize * fs->desc_blocks) {
+       if (actual != (ssize_t)(fs->blocksize * fs->desc_blocks)) {
                retval = EXT2_ET_SHORT_WRITE;
                goto errout;
        }
index 996c31a..dca6af0 100644 (file)
@@ -134,8 +134,8 @@ errcode_t io_channel_alloc_buf(io_channel io, int count, void *ptr)
        else
                size = -count;
 
-       if (io->align) {
-               if (io->align > size)
+       if (io->align > 0) {
+               if ((unsigned) io->align > size)
                        size = io->align;
                return ext2fs_get_memalign(size, io->align, ptr);
        } else
index c94de23..2811957 100644 (file)
@@ -263,6 +263,7 @@ typedef struct journal_superblock_s
 #ifdef NO_INLINE_FUNCS
 extern size_t journal_tag_bytes(journal_t *journal);
 extern int jbd2_journal_has_csum_v2or3(journal_t *journal);
+extern int jbd2_journal_get_num_fc_blks(journal_superblock_t *jsb);
 extern int tid_gt(tid_t x, tid_t y) EXT2FS_ATTR((unused));
 extern int tid_geq(tid_t x, tid_t y) EXT2FS_ATTR((unused));
 #endif
index a2c34ac..d69b1e3 100644 (file)
@@ -35,7 +35,7 @@ struct dx_lookup_info {
        int namelen;
        int hash_alg;
        __u32 hash;
-       int levels;
+       unsigned levels;
        struct dx_frame frames[EXT4_HTREE_LEVEL];
 };
 
@@ -46,7 +46,7 @@ static errcode_t alloc_dx_frame(ext2_filsys fs, struct dx_frame *frame)
 
 static void dx_release(struct dx_lookup_info *info)
 {
-       int level;
+       unsigned level;
 
        for (level = 0; level < info->levels; level++) {
                if (info->frames[level].buf == NULL)
@@ -110,7 +110,8 @@ static errcode_t dx_lookup(ext2_filsys fs, ext2_ino_t dir,
                                         info->frames[0].buf);
        if (errcode)
                goto out_err;
-       root = info->frames[0].buf + EXT2_DX_ROOT_OFF;
+       root = (struct ext2_dx_root_info *) ((char *)info->frames[0].buf +
+                                            EXT2_DX_ROOT_OFF);
        hash_alg = root->hash_version;
        if (hash_alg != EXT2_HASH_TEA && hash_alg != EXT2_HASH_HALF_MD4 &&
            hash_alg != EXT2_HASH_LEGACY) {
@@ -329,19 +330,19 @@ static errcode_t dx_move_dirents(ext2_filsys fs, struct dx_hash_map *map,
                csum_size = sizeof(struct ext2_dir_entry_tail);
 
        for (i = 0; i < count; i++) {
-               de = from + map[i].off;
+               de = (struct ext2_dir_entry *) ((char *)from + map[i].off);
                rec_len = EXT2_DIR_REC_LEN(ext2fs_dirent_name_len(de));
                memcpy(to, de, rec_len);
                retval = ext2fs_set_rec_len(fs, rec_len, to);
                if (retval)
                        return retval;
-               to += rec_len;
+               to = (char *)to + rec_len;
        }
        /*
         * Update rec_len of the last dir entry to stretch to the end of block
         */
-       to -= rec_len;
-       rec_len = fs->blocksize - (to - base) - csum_size;
+       to = (char *)to - rec_len;
+       rec_len = fs->blocksize - ((char *)to - (char *)base) - csum_size;
        retval = ext2fs_set_rec_len(fs, rec_len, to);
        if (retval)
                return retval;
@@ -396,7 +397,7 @@ static errcode_t dx_split_leaf(ext2_filsys fs, ext2_ino_t dir,
                return retval;
        }
        for (offset = 0; offset < fs->blocksize; offset += rec_len) {
-               de = buf + offset;
+               de = (struct ext2_dir_entry *) ((char *)buf + offset);
                retval = ext2fs_get_rec_len(fs, de, &rec_len);
                if (retval)
                        goto out;
@@ -490,7 +491,7 @@ static errcode_t dx_grow_tree(ext2_filsys fs, ext2_ino_t dir,
        if (retval)
                return retval;
        /* Only leaf addition needed? */
-       if (i == info->levels - 1)
+       if (i == (int)info->levels - 1)
                return dx_split_leaf(fs, dir, diri, info, buf, leaf_pblk,
                                     lblk, pblk);
 
@@ -501,7 +502,7 @@ static errcode_t dx_grow_tree(ext2_filsys fs, ext2_ino_t dir,
        retval = ext2fs_set_rec_len(fs, fs->blocksize, de);
        if (retval)
                return retval;
-       head = buf + 8;
+       head = (struct ext2_dx_countlimit *) ((char *)buf + 8);
        count = ext2fs_le16_to_cpu(info->frames[i+1].head->count);
        /* Growing tree depth? */
        if (i < 0) {
@@ -517,7 +518,8 @@ static errcode_t dx_grow_tree(ext2_filsys fs, ext2_ino_t dir,
                /* Now update tree root */
                info->frames[0].head->count = ext2fs_cpu_to_le16(1);
                info->frames[0].entries[0].block = ext2fs_cpu_to_le32(lblk);
-               root = info->frames[0].buf + EXT2_DX_ROOT_OFF;
+               root = (struct ext2_dx_root_info *)
+                       ((char *)info->frames[0].buf + EXT2_DX_ROOT_OFF);
                root->indirect_levels++;
        } else {
                /* Splitting internal node in two */
@@ -558,7 +560,7 @@ static errcode_t dx_link(ext2_filsys fs, ext2_ino_t dir,
        struct dx_lookup_info dx_info;
        errcode_t retval;
        void *blockbuf;
-       int restart = 0;
+       unsigned restart = 0;
        blk64_t leaf_pblk;
 
        retval = ext2fs_get_mem(fs->blocksize, &blockbuf);
index ba5de8b..1f38010 100644 (file)
@@ -557,7 +557,7 @@ errcode_t ext2fs_rw_bitmaps(ext2_filsys fs, int flags, int num_threads)
        if (num_threads < 0)
                num_threads = 4;
 
-       if (num_threads > fs->group_desc_count)
+       if ((unsigned) num_threads > fs->group_desc_count)
                num_threads = fs->group_desc_count;
        average_group = fs->group_desc_count / num_threads;
        if (ext2fs_has_feature_flex_bg(fs->super)) {
index 0fb9481..dc5c0ff 100644 (file)
@@ -65,6 +65,12 @@ Last Changed Date: 2007-06-22 13:36:10 -0400 (Fri, 22 Jun 2007)
 #include <sys/mman.h>
 #endif
 
+#ifdef __GNUC__
+#define EXT2FS_ATTR(x) __attribute__(x)
+#else
+#define EXT2FS_ATTR(x)
+#endif
+
 #ifndef MAP_FILE
 #define MAP_FILE 0
 #endif
@@ -256,6 +262,7 @@ struct tdb_context {
 static int tdb_munmap(struct tdb_context *tdb);
 static void tdb_mmap(struct tdb_context *tdb);
 static int tdb_lock(struct tdb_context *tdb, int list, int ltype);
+int tdb_lock_nonblock(struct tdb_context *tdb, int list, int ltype);
 static int tdb_unlock(struct tdb_context *tdb, int list, int ltype);
 static int tdb_brlock(struct tdb_context *tdb, tdb_off_t offset, int rw_type, int lck_type, int probe, size_t len);
 static int tdb_transaction_lock(struct tdb_context *tdb, int ltype);
@@ -410,7 +417,7 @@ static int _tdb_lock(struct tdb_context *tdb, int list, int ltype, int op)
 
        /* a global lock allows us to avoid per chain locks */
        if (tdb->global_lock.count &&
-           (ltype == tdb->global_lock.ltype || ltype == F_RDLCK)) {
+           ((u32)ltype == tdb->global_lock.ltype || ltype == F_RDLCK)) {
                return 0;
        }
 
@@ -505,7 +512,7 @@ int tdb_unlock(struct tdb_context *tdb, int list, int ltype)
 
        /* a global lock allows us to avoid per chain locks */
        if (tdb->global_lock.count &&
-           (ltype == tdb->global_lock.ltype || ltype == F_RDLCK)) {
+           ((u32)ltype == tdb->global_lock.ltype || ltype == F_RDLCK)) {
                return 0;
        }
 
@@ -626,7 +633,7 @@ static int _tdb_lockall(struct tdb_context *tdb, int ltype, int op)
        if (tdb->read_only || tdb->traverse_read)
                return TDB_ERRCODE(TDB_ERR_LOCK, -1);
 
-       if (tdb->global_lock.count && tdb->global_lock.ltype == ltype) {
+       if (tdb->global_lock.count && tdb->global_lock.ltype == (u32)ltype) {
                tdb->global_lock.count++;
                return 0;
        }
@@ -670,7 +677,8 @@ static int _tdb_unlockall(struct tdb_context *tdb, int ltype)
                return TDB_ERRCODE(TDB_ERR_LOCK, -1);
        }
 
-       if (tdb->global_lock.ltype != ltype || tdb->global_lock.count == 0) {
+       if (tdb->global_lock.ltype != (u32)ltype ||
+           tdb->global_lock.count == 0) {
                return TDB_ERRCODE(TDB_ERR_LOCK, -1);
        }
 
@@ -853,7 +861,7 @@ static int tdb_oob(struct tdb_context *tdb, tdb_off_t len, int probe)
                return TDB_ERRCODE(TDB_ERR_IO, -1);
        }
 
-       if (st.st_size < (size_t)len) {
+       if (st.st_size < (off_t)len) {
                if (!probe) {
                        /* Ensure ecode is set for log fn. */
                        tdb->ecode = TDB_ERR_IO;
@@ -1537,7 +1545,8 @@ static void transaction_next_hash_chain(struct tdb_context *tdb, u32 *chain)
 /*
   out of bounds check during a transaction
 */
-static int transaction_oob(struct tdb_context *tdb, tdb_off_t len, int probe)
+static int transaction_oob(struct tdb_context *tdb, tdb_off_t len,
+                          int probe EXT2FS_ATTR((unused)))
 {
        if (len <= tdb->map_size) {
                return 0;
@@ -1563,8 +1572,12 @@ static int transaction_expand_file(struct tdb_context *tdb, tdb_off_t size,
 /*
   brlock during a transaction - ignore them
 */
-static int transaction_brlock(struct tdb_context *tdb, tdb_off_t offset,
-                             int rw_type, int lck_type, int probe, size_t len)
+static int transaction_brlock(struct tdb_context *tdb EXT2FS_ATTR((unused)),
+                             tdb_off_t offset EXT2FS_ATTR((unused)),
+                             int rw_type EXT2FS_ATTR((unused)),
+                             int lck_type EXT2FS_ATTR((unused)),
+                             int probe EXT2FS_ATTR((unused)),
+                             size_t len EXT2FS_ATTR((unused)))
 {
        return 0;
 }
@@ -3007,7 +3020,7 @@ static int tdb_dump_chain(struct tdb_context *tdb, int i)
 void tdb_dump_all(struct tdb_context *tdb)
 {
        int i;
-       for (i=0;i<tdb->header.hash_size;i++) {
+       for (i = 0; i < (int)tdb->header.hash_size; i++) {
                tdb_dump_chain(tdb, i);
        }
        printf("freelist:\n");
@@ -3100,7 +3113,8 @@ static void tdb_increment_seqnum(struct tdb_context *tdb)
        tdb_brlock(tdb, TDB_SEQNUM_OFS, F_UNLCK, F_SETLKW, 1, 1);
 }
 
-static int tdb_key_compare(TDB_DATA key, TDB_DATA data, void *private_data)
+static int tdb_key_compare(TDB_DATA key, TDB_DATA data,
+                          void *private_data EXT2FS_ATTR((unused)))
 {
        return memcmp(data.dptr, key.dptr, data.dsize);
 }
@@ -3804,7 +3818,9 @@ struct tdb_context *tdb_open(const char *name, int hash_size, int tdb_flags,
 
 /* a default logging function */
 static void null_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
-static void null_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...)
+static void null_log_fn(struct tdb_context *tdb EXT2FS_ATTR((unused)),
+                       enum tdb_debug_level level EXT2FS_ATTR((unused)),
+                       const char *fmt EXT2FS_ATTR((unused)), ...)
 {
 }
 
index 0eea1c2..d251c20 100644 (file)
@@ -315,7 +315,7 @@ bounce_read:
                        actual = align_size - offset;
                if (actual > size)
                        actual = size;
-               memcpy(buf, data->bounce + offset, actual);
+               memcpy(buf, (char *)data->bounce + offset, actual);
 
                really_read += actual;
                size -= actual;
index f8277c4..ee0bf29 100644 (file)
@@ -295,7 +295,7 @@ void dict_set_allocator(dict_t *dict, dnode_alloc_t al,
     dict->context = context;
 }
 
-void dict_set_cmp_context(dict_t *dict, void *cmp_ctx)
+void dict_set_cmp_context(dict_t *dict, const void *cmp_ctx)
 {
     dict_assert (!dict->cmp_ctx);
     dict_assert (dict_count(dict) == 0);
index d9462a3..f1382e1 100644 (file)
@@ -69,7 +69,7 @@ typedef struct dict_t {
     dnode_alloc_t dict_allocnode;
     dnode_free_t dict_freenode;
     void *dict_context;
-    void *cmp_ctx;
+    const void *cmp_ctx;
     int dict_dupes;
 #else
     int dict_dummmy;
@@ -89,7 +89,7 @@ typedef struct dict_load_t {
 
 extern dict_t *dict_create(dictcount_t, dict_comp_t);
 extern void dict_set_allocator(dict_t *, dnode_alloc_t, dnode_free_t, void *);
-extern void dict_set_cmp_context(dict_t *, void *);
+extern void dict_set_cmp_context(dict_t *, const void *);
 extern void dict_destroy(dict_t *);
 extern void dict_free_nodes(dict_t *);
 extern void dict_free(dict_t *);
index 347759b..bbde889 100644 (file)
@@ -1305,7 +1305,7 @@ static void write_raw_image_file(ext2_filsys fs, int fd, int type, int flags,
        }
 
        if (superblock) {
-               int j;
+               unsigned int j;
 
                ext2fs_mark_block_bitmap2(meta_block_map, superblock);
                meta_blocks_count++;
index c7b3231..306064d 100644 (file)
@@ -2321,9 +2321,9 @@ profile_error:
                        device_name);
        } else {
                /* setting stripe/stride to blocksize is pointless */
-               if (dev_param.min_io > blocksize)
+               if (dev_param.min_io > (unsigned) blocksize)
                        fs_param.s_raid_stride = dev_param.min_io / blocksize;
-               if (dev_param.opt_io > blocksize) {
+               if (dev_param.opt_io > (unsigned) blocksize) {
                        fs_param.s_raid_stripe_width =
                                                dev_param.opt_io / blocksize;
                }