]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
Fix gcc and clang warnings
authorTheodore Ts'o <tytso@mit.edu>
Sun, 24 Jun 2018 03:00:50 +0000 (23:00 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 24 Jun 2018 03:00:50 +0000 (23:00 -0400)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
36 files changed:
debugfs/debugfs.c
debugfs/debugfs.h
debugfs/xattrs.c
e2fsck/e2fsck.h
e2fsck/extents.c
e2fsck/jfs_user.h
e2fsck/pass1.c
e2fsck/pass2.c
e2fsck/quota.c
e2fsck/rehash.c
e2fsck/unix.c
e2fsck/util.c
lib/e2p/crypto_mode.c
lib/e2p/e2p.h
lib/e2p/ljs.c
lib/ext2fs/ext2fs.h
lib/ext2fs/ext4_acl.h
lib/ext2fs/ext_attr.c
lib/ext2fs/fiemap.h
lib/ext2fs/hashmap.h
lib/ext2fs/jfs_compat.h
lib/ext2fs/openfs.c
lib/ext2fs/unix_io.c
lib/support/mkquota.c
misc/e2freefrag.c
misc/e2undo.c
misc/e4crypt.c
misc/e4defrag.c
misc/filefrag.c
misc/fsck.c
misc/fuse2fs.c
misc/mk_hugefiles.c
misc/mklost+found.c
misc/tune2fs.c
resize/resize2fs.c
tests/progs/test_icount.c

index a270e8c2e584b54fa98ede9f2d3773391679c738..2bf6a30ce067827db53081b5a0b15bc386453f9b 100644 (file)
@@ -60,8 +60,9 @@ static int debugfs_setup_tdb(const char *device_name, char *undo_file,
                             io_manager *io_ptr)
 {
        errcode_t retval = ENOMEM;
-       char *tdb_dir = NULL, *tdb_file = NULL;
-       char *dev_name, *tmp_name;
+       const char      *tdb_dir = NULL;
+       char            *tdb_file = NULL;
+       char            *dev_name, *tmp_name;
 
        /* (re)open a specific undo file */
        if (undo_file && undo_file[0] != 0) {
@@ -2103,7 +2104,6 @@ void do_idump(int argc, char *argv[])
        reset_getopt();
        while ((c = getopt (argc, argv, "bex")) != EOF) {
                if (mode || c == '?') {
-               print_usage:
                        com_err(argv[0], 0,
                                "Usage: inode_dump [-b]|[-e] <file>");
                        return;
@@ -2144,7 +2144,6 @@ void do_idump(int argc, char *argv[])
        case 'x':
        case 'e':
                if (size <= EXT2_GOOD_OLD_INODE_SIZE) {
-               no_extra_space:
                        com_err(argv[0], 0, "No extra space in inode");
                        goto err;
                }
index 3322d05a0afd7195a7f40e9b2a325bb84cb3f578..93f036dec248effc5f1f462eb0ab5063ad528da4 100644 (file)
@@ -137,6 +137,7 @@ extern void do_rm(int argc, char **argv);
 extern void do_link(int argc, char **argv);
 extern void do_undel(int argc, char **argv);
 extern void do_unlink(int argc, char **argv);
+extern void do_copy_inode(int argc, char *argv[]);
 extern void do_find_free_block(int argc, char **argv);
 extern void do_find_free_inode(int argc, char **argv);
 extern void do_stat(int argc, char **argv);
index 6c32712ac4db9124ed99e2a5234ae5364c12c16b..c29761ec9840c7ff32a2d9e4632a2d8ec321ca30 100644 (file)
@@ -406,7 +406,6 @@ static void dump_xattr_raw_entries(FILE *f, unsigned char *buf,
                                   unsigned value_start)
 {
        struct ext2_ext_attr_entry ent;
-       char *name;
        unsigned int off = start;
        unsigned int vstart;
 
@@ -417,7 +416,6 @@ static void dump_xattr_raw_entries(FILE *f, unsigned char *buf,
                        break;
                }
                if ((off + sizeof(struct ext2_ext_attr_entry)) >= len) {
-               overrun:
                        fprintf(f, "xattr buffer overrun at %u (len = %u)\n",
                                off, len);
                        break;
@@ -456,7 +454,7 @@ static void dump_xattr_raw_entries(FILE *f, unsigned char *buf,
                                   ent.e_value_size);
                else {
                        fprintf(f, "<hexdump>\n");
-                       do_byte_hexdump(f, (char *)(buf + vstart),
+                       do_byte_hexdump(f, (unsigned char *)(buf + vstart),
                                        ent.e_value_size);
                }
                fputc('\n', f);
index e930d816ffcbdf373703732f17836d7172b3a271..cd5cba2f6031e54771f7befe6ff547a6c9197ddd 100644 (file)
@@ -635,7 +635,8 @@ extern blk64_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs,
                           const char *name, io_manager manager);
 extern int ext2_file_type(unsigned int mode);
 extern int write_all(int fd, char *buf, size_t count);
-void dump_mmp_msg(struct mmp_struct *mmp, const char *fmt, ...);
+void dump_mmp_msg(struct mmp_struct *mmp, const char *fmt, ...)
+       E2FSCK_ATTR((format(printf, 2, 3)));
 errcode_t e2fsck_mmp_update(ext2_filsys fs);
 
 extern void e2fsck_set_bitmap_type(ext2_filsys fs,
index ef3146d8b4cec6f5fea18dc770d3094af1db7d8f..3073725ab55b2c48dceb339ef25aeb864437d9e6 100644 (file)
@@ -171,7 +171,7 @@ static int find_blocks(ext2_filsys fs, blk64_t *blocknr, e2_blkcnt_t blockcnt,
                                             list->count - 1;
                blk64_t end = last->e_len + 1;
 
-               if (last->e_lblk + last->e_len == blockcnt &&
+               if (last->e_lblk + last->e_len == (__u64) blockcnt &&
                    last->e_pblk + last->e_len == *blocknr &&
                    end < (1ULL << 32)) {
                        last->e_len++;
index d30b728d1e8525210964d377f8612ee0abe6348c..828979514643f96e574cafa22426f618d5b8b16d 100644 (file)
 #include "e2fsck.h"
 #endif
 
+#if __STDC_VERSION__ < 199901L
+# if __GNUC__ >= 2 || _MSC_VER >= 1300
+#  define __func__ __FUNCTION__
+# else
+#  define __func__ "<unknown>"
+# endif
+#endif
+
 struct buffer_head {
 #ifdef DEBUGFS
        ext2_filsys     b_fs;
@@ -100,6 +108,9 @@ typedef struct {
 extern lkmem_cache_t *do_cache_create(int len);
 extern void do_cache_destroy(lkmem_cache_t *cache);
 extern size_t journal_tag_bytes(journal_t *journal);
+extern __u32 __hash_32(__u32 val);
+extern __u32 hash_32(__u32 val, unsigned int bits);
+extern __u32 hash_64(__u64 val, unsigned int bits);
 #endif
 
 #if (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
@@ -121,7 +132,6 @@ extern size_t journal_tag_bytes(journal_t *journal);
 #endif /* __STDC_VERSION__ >= 199901L */
 #endif /* E2FSCK_INCLUDE_INLINE_FUNCS */
 
-
 _INLINE_ lkmem_cache_t *do_cache_create(int len)
 {
        lkmem_cache_t *new_cache;
@@ -201,7 +211,7 @@ extern e2fsck_t e2fsck_global_ctx;  /* Try your very best not to use this! */
        do { if (!(assert)) {                                           \
                printf ("Assertion failure in %s() at %s line %d: "     \
                        "\"%s\"\n",                                     \
-                       __FUNCTION__, __FILE__, __LINE__, # assert);    \
+                       __func__, __FILE__, __LINE__, # assert);        \
                fatal_error(e2fsck_global_ctx, 0);                      \
        } } while (0)
 
index 8dfa82a078fe07fc1d67ad2aa19e04479ffaaa12..f1fa5d948deaf5d9fe1c2958e035cd30ff8500d4 100644 (file)
@@ -819,7 +819,6 @@ extern errcode_t e2fsck_setup_icount(e2fsck_t ctx, const char *icount_name,
        errcode_t               retval;
        char                    *tdb_dir;
        int                     enable;
-       int                     full_map;
 
        *ret = 0;
 
@@ -1173,8 +1172,8 @@ void e2fsck_pass1(e2fsck_t ctx)
        const char      *old_op;
        int             imagic_fs, extent_fs, inlinedata_fs;
        int             low_dtime_check = 1;
-       int             inode_size = EXT2_INODE_SIZE(fs->super);
-       int             bufsize;
+       unsigned int    inode_size = EXT2_INODE_SIZE(fs->super);
+       unsigned int    bufsize;
        int             failed_csum = 0;
        ext2_ino_t      ino_threshold = 0;
        dgrp_t          ra_group = 0;
@@ -2295,7 +2294,8 @@ static _INLINE_ void mark_blocks_used(e2fsck_t ctx, blk64_t block,
        if (ext2fs_test_block_bitmap_range2(ctx->block_found_map, block, num))
                ext2fs_mark_block_bitmap_range2(ctx->block_found_map, block, num);
        else {
-               int i;
+               unsigned int i;
+
                for (i = 0; i < num; i += EXT2FS_CLUSTER_RATIO(ctx->fs))
                        mark_block_used(ctx, block + i);
        }
@@ -2574,7 +2574,7 @@ static int check_ext_attr(e2fsck_t ctx, struct problem_context *pctx,
                        return 0;
        }
 
-       if (quota_blocks != EXT2FS_C2B(fs, 1)) {
+       if (quota_blocks != EXT2FS_C2B(fs, 1U)) {
                if (!ctx->ea_block_quota_blocks) {
                        pctx->errcode = ea_refcount_create(0,
                                                &ctx->ea_block_quota_blocks);
index c6aff71a53a899917407e1469b08e358d5c91539..b92eec1e149f3e9e30f0fd61e47a705e69c2f430 100644 (file)
@@ -129,7 +129,7 @@ void e2fsck_pass2(e2fsck_t ctx)
 #endif
        struct check_dir_struct cd;
        struct dx_dir_info      *dx_dir;
-       struct dx_dirblock_info *dx_db, *dx_parent;
+       struct dx_dirblock_info *dx_db;
        int                     b;
        int                     i, depth;
        problem_t               code;
index b0f9af6373d694b39043ab9368e11366f79e2e22..3d48284f1f726686106368eeb0fe7cf603e0f42c 100644 (file)
@@ -92,7 +92,6 @@ void e2fsck_validate_quota_inodes(e2fsck_t ctx)
        struct problem_context  pctx;
        ext2_filsys             fs = ctx->fs;
        enum quota_type qtype;
-       ext2_ino_t quota_ino;
 
        clear_problem_context(&pctx);
 
index 486e1f21be6d5c6201120b06922cdfadc0510299..7c4ab0836482dd33ad0a669ad2e8107a800de2c4 100644 (file)
@@ -653,7 +653,6 @@ static errcode_t calculate_tree(ext2_filsys fs,
        struct ext2_dx_entry            *root, *int_ent, *dx_ent = 0;
        struct ext2_dx_countlimit       *root_limit, *int_limit, *limit;
        errcode_t                       retval;
-       char                            * block_start;
        int                             i, c1, c2, c3, nblks;
        int                             limit_offset, int_offset, root_offset;
 
index 61396f7f1a15cccd8bdcaaa7901855e9b3643b9d..42eef75401b688dd378f44710879e341ed8c0485 100644 (file)
@@ -287,7 +287,7 @@ static int is_on_batt(void)
 {
        FILE    *f;
        DIR     *d;
-       char    tmp[80], tmp2[80], fname[80];
+       char    tmp[80], tmp2[80], fname[NAME_MAX+30];
        unsigned int    acflag;
        struct dirent*  de;
 
@@ -311,7 +311,8 @@ static int is_on_batt(void)
                while ((de=readdir(d)) != NULL) {
                        if (!strncmp(".", de->d_name, 1))
                                continue;
-                       snprintf(fname, 80, "/proc/acpi/ac_adapter/%s/state",
+                       snprintf(fname, sizeof(fname),
+                                "/proc/acpi/ac_adapter/%s/state",
                                 de->d_name);
                        f = fopen(fname, "r");
                        if (!f)
@@ -934,6 +935,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
                        break;
                case 'L':
                        replace_bad_blocks++;
+                       /* fall through */
                case 'l':
                        if (bad_blocks_file)
                                free(bad_blocks_file);
index 5793b65a6a44b7c00ba3d4e72d08a6e4593470b2..db6a1cc11a23c309bd71427d870720eaf8491014 100644 (file)
@@ -204,9 +204,10 @@ int ask_yn(e2fsck_t ctx, const char * string, int def)
        static int      yes_answers;
 
 #ifdef HAVE_TERMIOS_H
-       struct termios  termios = {0, }, tmp;
+       struct termios  termios, tmp;
 
-       tcgetattr (0, &termios);
+       if (tcgetattr (0, &termios) < 0)
+               memset(&termios, 0, sizeof(termios));
        tmp = termios;
        tmp.c_lflag &= ~(ICANON | ECHO);
        tmp.c_cc[VMIN] = 1;
index bc553fde5a5ed5327463836330bcbd3bea12c438..4933016eae65a68271d86958072e60b7ff11b12b 100644 (file)
@@ -20,7 +20,7 @@
 #include "e2p.h"
 
 struct mode {
-       unsigned int    num;
+       int             num;
        const char      *string;
 };
 
index e96cdec8528c80202d2843e274abb2ed17b4729e..d70b59a5d358de49c6510ee54b2ba998ad8ec051 100644 (file)
@@ -77,3 +77,6 @@ char *e2p_os2string(int os_type);
 int e2p_string2os(char *str);
 
 unsigned int e2p_percent(int percent, unsigned int base);
+
+const char *e2p_encmode2string(int num);
+int e2p_string2encmode(char *string);
index 2db700b073e729127df26fc9c36c27827bcc9f94..0b1beadb048a2b72c754b0ab58e5c881c10d2acd 100644 (file)
@@ -52,8 +52,8 @@ void e2p_list_journal_super(FILE *f, char *journal_sb_buf,
        journal_superblock_t *jsb = (journal_superblock_t *) journal_sb_buf;
        __u32 *mask_ptr, mask, m;
        unsigned int size;
-       int i, j, printed = 0;
-       unsigned int nr_users;
+       int j, printed = 0;
+       unsigned int i, nr_users;
 
        fprintf(f, "%s", "Journal features:        ");
        for (i=0, mask_ptr=&jsb->s_feature_compat; i <3; i++,mask_ptr++) {
@@ -75,7 +75,7 @@ void e2p_list_journal_super(FILE *f, char *journal_sb_buf,
        else
                fprintf(f, "%uM\n", size >> 10);
        nr_users = (unsigned int) ntohl(jsb->s_nr_users);
-       if (exp_block_size != ntohl(jsb->s_blocksize))
+       if (exp_block_size != (int) ntohl(jsb->s_blocksize))
                fprintf(f, "Journal block size:       %u\n",
                        (unsigned int)ntohl(jsb->s_blocksize));
        fprintf(f, "Journal length:           %u\n",
index eb6c0926ae4ccc8dac4a20ac0d21eb77ccab5a7d..3d4afac4b67d8706196886a08505e62f9c41a3b7 100644 (file)
@@ -1738,6 +1738,7 @@ extern blk_t ext2fs_group_first_block(ext2_filsys fs, dgrp_t group);
 extern blk_t ext2fs_group_last_block(ext2_filsys fs, dgrp_t group);
 extern blk_t ext2fs_inode_data_blocks(ext2_filsys fs,
                                      struct ext2_inode *inode);
+extern int ext2fs_htree_intnode_maxrecs(ext2_filsys fs, int blocks);
 extern unsigned int ext2fs_div_ceil(unsigned int a, unsigned int b);
 extern __u64 ext2fs_div64_ceil(__u64 a, __u64 b);
 extern int ext2fs_dirent_name_len(const struct ext2_dir_entry *entry);
@@ -1969,18 +1970,6 @@ _INLINE_ blk_t ext2fs_inode_data_blocks(ext2_filsys fs,
        return (blk_t) ext2fs_inode_data_blocks2(fs, inode);
 }
 
-/* htree levels for ext4 */
-#define EXT4_HTREE_LEVEL_COMPAT 2
-#define EXT4_HTREE_LEVEL       3
-
-static inline unsigned int ext2_dir_htree_level(ext2_filsys fs)
-{
-       if (ext2fs_has_feature_largedir(fs->super))
-               return EXT4_HTREE_LEVEL;
-
-       return EXT4_HTREE_LEVEL_COMPAT;
-}
-
 _INLINE_ int ext2fs_htree_intnode_maxrecs(ext2_filsys fs, int blocks)
 {
        return blocks * ((fs->blocksize - 8) / sizeof(struct ext2_dx_entry));
@@ -2039,6 +2028,18 @@ ext2fs_const_inode(const struct ext2_inode_large * large_inode)
 #undef _INLINE_
 #endif
 
+/* htree levels for ext4 */
+#define EXT4_HTREE_LEVEL_COMPAT 2
+#define EXT4_HTREE_LEVEL       3
+
+static inline unsigned int ext2_dir_htree_level(ext2_filsys fs)
+{
+       if (ext2fs_has_feature_largedir(fs->super))
+               return EXT4_HTREE_LEVEL;
+
+       return EXT4_HTREE_LEVEL_COMPAT;
+}
+
 #ifdef __cplusplus
 }
 #endif
index 69ff79d558346950c15f3c7ae0b5d2dbc9687c32..1f5245def5a8934ee1eef25905fb160d1dca14b1 100644 (file)
@@ -50,6 +50,9 @@ typedef struct {
 
 typedef struct {
         __le32                  a_version;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
         posix_acl_xattr_entry   a_entries[0];
+#pragma GCC diagnostic pop
 } posix_acl_xattr_header;
 
index 81b067ad55fd66ea7c0583d001a12cc2c6fe786c..77a036202b0c988699375f89f2fee6334b781789 100644 (file)
@@ -357,13 +357,13 @@ static const char *find_ea_prefix(int index)
        return NULL;
 }
 
-static int find_ea_index(const char *fullname, char **name, int *index)
+static int find_ea_index(const char *fullname, const char **name, int *index)
 {
        struct ea_name_index *e;
 
        for (e = ea_names; e->name; e++) {
                if (strncmp(fullname, e->name, strlen(e->name)) == 0) {
-                       *name = (char *)fullname + strlen(e->name);
+                       *name = fullname + strlen(e->name);
                        *index = e->index;
                        return 1;
                }
@@ -525,11 +525,13 @@ posix_acl_xattr_count(size_t size)
 static errcode_t convert_posix_acl_to_disk_buffer(const void *value, size_t size,
                                                  void *out_buf, size_t *size_out)
 {
-       posix_acl_xattr_header *header = (posix_acl_xattr_header*) value;
-       posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
+       const posix_acl_xattr_header *header =
+               (const posix_acl_xattr_header*) value;
+       const posix_acl_xattr_entry *end, *entry =
+               (const posix_acl_xattr_entry *)(header+1);
        ext4_acl_header *ext_acl;
        size_t s;
-       void *e;
+       char *e;
 
        int count;
 
@@ -579,7 +581,7 @@ static errcode_t convert_disk_buffer_to_posix_acl(const void *value, size_t size
 {
        posix_acl_xattr_header *header;
        posix_acl_xattr_entry *entry;
-       ext4_acl_header *ext_acl = (ext4_acl_header *) value;
+       const ext4_acl_header *ext_acl = (const ext4_acl_header *) value;
        errcode_t err;
        const char *cp;
        char *out;
@@ -597,7 +599,7 @@ static errcode_t convert_disk_buffer_to_posix_acl(const void *value, size_t size
        header->a_version = ext2fs_cpu_to_le32(POSIX_ACL_XATTR_VERSION);
        entry = (posix_acl_xattr_entry *) (out + sizeof(posix_acl_xattr_header));
 
-       cp = value + sizeof(ext4_acl_header);
+       cp = (const char *) value + sizeof(ext4_acl_header);
        size -= sizeof(ext4_acl_header);
 
        while (size > 0) {
@@ -640,9 +642,9 @@ write_xattrs_to_buffer(ext2_filsys fs, struct ext2_xattr *attrs, int count,
 {
        struct ext2_xattr *x;
        struct ext2_ext_attr_entry *e = entries_start;
-       void *end = entries_start + storage_size;
-       char *shortname;
-       unsigned int entry_size, value_size;
+       char *end = (char *) entries_start + storage_size;
+       const char *shortname;
+       unsigned int value_size;
        int idx, ret;
        errcode_t err;
 
@@ -652,10 +654,6 @@ write_xattrs_to_buffer(ext2_filsys fs, struct ext2_xattr *attrs, int count,
                shortname = x->name;
                ret = find_ea_index(x->name, &shortname, &idx);
 
-               /* Calculate entry and value size */
-               entry_size = (sizeof(*e) + strlen(shortname) +
-                             EXT2_EXT_ATTR_PAD - 1) &
-                            ~(EXT2_EXT_ATTR_PAD - 1);
                value_size = ((x->value_len + EXT2_EXT_ATTR_PAD - 1) /
                              EXT2_EXT_ATTR_PAD) * EXT2_EXT_ATTR_PAD;
 
@@ -672,8 +670,8 @@ write_xattrs_to_buffer(ext2_filsys fs, struct ext2_xattr *attrs, int count,
                        e->e_value_offs = 0;
                } else {
                        end -= value_size;
-                       e->e_value_offs = end - entries_start +
-                                                       value_offset_correction;
+                       e->e_value_offs = end - (char *) entries_start +
+                                               value_offset_correction;
                        memcpy(end, x->value, e->e_value_size);
                }
 
@@ -695,7 +693,7 @@ write_xattrs_to_buffer(ext2_filsys fs, struct ext2_xattr *attrs, int count,
 errcode_t ext2fs_xattrs_write(struct ext2_xattr_handle *handle)
 {
        ext2_filsys fs = handle->fs;
-       const int inode_size = EXT2_INODE_SIZE(fs->super);
+       const unsigned int inode_size = EXT2_INODE_SIZE(fs->super);
        struct ext2_inode_large *inode;
        char *start, *block_buf = NULL;
        struct ext2_ext_attr_header *header;
@@ -977,7 +975,7 @@ static errcode_t read_xattrs_from_buffer(struct ext2_xattr_handle *handle,
 static void xattrs_free_keys(struct ext2_xattr_handle *h)
 {
        struct ext2_xattr *a = h->attrs;
-       size_t i;
+       int i;
 
        for (i = 0; i < h->capacity; i++) {
                if (a[i].name)
@@ -1362,7 +1360,7 @@ static int xattr_find_position(struct ext2_xattr *attrs, int count,
 {
        struct ext2_xattr *x;
        int i;
-       char *shortname, *x_shortname;
+       const char *shortname, *x_shortname;
        int name_idx, x_name_idx;
        int shortname_len, x_shortname_len;
 
@@ -1398,7 +1396,7 @@ static errcode_t xattr_array_update(struct ext2_xattr_handle *h,
        int add_to_ibody;
        int needed;
        int name_len, name_idx;
-       char *shortname;
+       const char *shortname;
        int new_idx;
        int ret;
 
@@ -1504,7 +1502,7 @@ static int space_used(struct ext2_xattr *attrs, int count)
 {
        int total = 0;
        struct ext2_xattr *x;
-       char *shortname;
+       const char *shortname;
        int i, len, name_idx;
 
        for (i = 0, x = attrs; i < count; i++, x++) {
index a331bc12a52a29b7ca8a53dd7569576fa4c94eef..5c851b24b963343bfc55ba5dae0802b7c3ec8cac 100644 (file)
@@ -31,7 +31,10 @@ struct fiemap {
        __u32 fm_mapped_extents;/* number of extents that were mapped (out) */
        __u32 fm_extent_count;  /* size of fm_extents array (in) */
        __u32 fm_reserved;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
        struct fiemap_extent fm_extents[0]; /* array of mapped extents (out) */
+#pragma GCC diagnostic pop
 };
 
 #if defined(__linux__) && !defined(FS_IOC_FIEMAP)
index 71271866feae212183440e0df817c84c6f0a66d1..be1e8a76a8bf10d43674b48dd7a2596ba0d02f6e 100644 (file)
@@ -17,7 +17,10 @@ struct ext2fs_hashmap {
                struct ext2fs_hashmap_entry *next;
                struct ext2fs_hashmap_entry *list_next;
                struct ext2fs_hashmap_entry *list_prev;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
        } *entries[0];
+#pragma GCC diagnostic pop
 };
 
 struct ext2fs_hashmap *ext2fs_hashmap_create(
index 91373674a7ca7962fc7c82cf9a421057b44948e6..f1a3f968e86fddb0ccb3749593ff289199ae8008 100644 (file)
@@ -87,14 +87,6 @@ struct journal_s
        __u32                   j_csum_seed;
 };
 
-#define J_ASSERT(assert)                                               \
-       do { if (!(assert)) {                                           \
-               printf ("Assertion failure in %s() at %s line %d: "     \
-                       "\"%s\"\n",                                     \
-                       __FUNCTION__, __FILE__, __LINE__, # assert);    \
-               fatal_error(e2fsck_global_ctx, 0);                      \
-       } } while (0)
-
 #define is_journal_abort(x) 0
 
 #define BUFFER_TRACE(bh, info) do {} while (0)
index 0c8ad24e57815f08fb19ec57604d9a92de8fee72..85d73e2a429b3837ab3e3db07abbaffae0852d20 100644 (file)
@@ -127,7 +127,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
        blk64_t         group_block, blk;
        char            *dest, *cp;
        int             group_zero_adjust = 0;
-       int             inode_size;
+       unsigned int    inode_size;
        __u64           groups_cnt;
 #ifdef WORDS_BIGENDIAN
        unsigned int    groups_per_block;
index c6b058d1c927a81d445461fbe5a5bcd8ec28ecd3..53fbd28bf8032ea793f6e825d5e0d7ff1f15eea5 100644 (file)
@@ -349,7 +349,7 @@ bounce_write:
                                        retval = errno;
                                        goto error_out;
                                }
-                               memset(data->bounce + actual, 0,
+                               memset((char *) data->bounce + actual, 0,
                                       channel->block_size - actual);
                        }
                }
index d136a91577676667e981f259640e2487bdb235e9..0b9e76659118bc2a6b73b0f065a2cb4bf46ccc3a 100644 (file)
@@ -268,6 +268,7 @@ static inline qid_t get_qid(struct ext2_inode_large *inode, enum quota_type qtyp
                        inode->i_extra_isize;
                if (inode_includes(inode_size, i_projid))
                        return inode_projid(*inode);
+               return 0;
        default:
                return 0;
        }
@@ -567,7 +568,8 @@ static int scan_dquots_callback(struct dquot *dquot, void *cb_data)
  * Read all dquots from quota file into memory
  */
 static errcode_t quota_read_all_dquots(struct quota_handle *qh,
-                                       quota_ctx_t qctx, int update_limits)
+                                       quota_ctx_t qctx,
+                                      int update_limits EXT2FS_ATTR((unused)))
 {
        struct scan_dquots_data scan_data;
 
index 09fae5c2a64497d97e9896ac3c1260132dfef8eb..268fac96fb90a362e7ff2ccb73092a859b4c8d2c 100644 (file)
@@ -173,7 +173,7 @@ static int scan_online(ext2_filsys fs, struct chunk_info *info)
        int mount_flags;
        int fd;
        int ret;
-       int i;
+       unsigned int i;
 
        /* Try to open the mountpoint for a live query. */
        retval = ext2fs_check_mount_point(fs->device_name, &mount_flags,
@@ -182,7 +182,7 @@ static int scan_online(ext2_filsys fs, struct chunk_info *info)
                com_err(fs->device_name, retval, "while checking mount status");
                return 0;
        }
-       if (!mount_flags & EXT2_MF_MOUNTED)
+       if (!(mount_flags & EXT2_MF_MOUNTED))
                return 0;
        fd = open(mntpoint, O_RDONLY);
        if (fd < 0) {
index 6443ca2ce91cb1b307c71040897f41f0d416b49e..05937383bb9b48ecb7762515cb8da85992b1d04f 100644 (file)
@@ -81,8 +81,10 @@ struct undo_key_block {
        __le32 magic;           /* KEYBLOCK_MAGIC number */
        __le32 crc;             /* block checksum */
        __le64 reserved;        /* zero */
-
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
        struct undo_key keys[0];        /* keys, which come immediately after */
+#pragma GCC diagnostic pop
 };
 
 struct undo_key_info {
index c1ec9ab9fe1b82c7a15505c8aa2e7d67eefb5662..759a082b7b92b53b107809633fd3f1e546d46648 100644 (file)
@@ -676,8 +676,10 @@ static void do_add_key(int argc, char **argv, const struct cmd_desc *cmd)
                        options |= OPT_QUIET;
                        break;
                default:
-                       fprintf(stderr, "Unrecognized option: %c\n", opt);
                case '?':
+                       if (opt != '?')
+                               fprintf(stderr, "Unrecognized option: %c\n",
+                                       opt);
                        fputs("USAGE:\n  ", stderr);
                        fputs(cmd->cmd_help, stderr);
                        exit(1);
index d63343e943e10c88d21587c98eab178a2ac430ff..5ac251dc5c1aa33faee0808567bfee46768653a9 100644 (file)
@@ -1851,6 +1851,7 @@ int main(int argc, char *argv[])
                                /* "e4defrag mount_point_dir/else_dir" */
                                memset(lost_found_dir, 0, PATH_MAX + 1);
                        }
+                       /* fall through */
                case DEVNAME:
                        if (arg_type == DEVNAME) {
                                strncpy(lost_found_dir, dir_name,
index c8444d76dc1d9f5265c29e789f6eff52a65778ed..7f1c5bfc62240271fa7da33262d283cff90ae79c 100644 (file)
@@ -208,7 +208,7 @@ static int filefrag_fiemap(int fd, int blk_shift, int *num_extents,
        __u64 buf[2048];        /* __u64 for proper field alignment */
        struct fiemap *fiemap = (struct fiemap *)buf;
        struct fiemap_extent *fm_ext = &fiemap->fm_extents[0];
-       struct fiemap_extent fm_last = {0};
+       struct fiemap_extent fm_last;
        int count = (sizeof(buf) - sizeof(*fiemap)) /
                        sizeof(struct fiemap_extent);
        unsigned long long expected = 0;
@@ -221,6 +221,7 @@ static int filefrag_fiemap(int fd, int blk_shift, int *num_extents,
        int rc;
 
        memset(fiemap, 0, sizeof(struct fiemap));
+       memset(&fm_last, 0, sizeof(fm_last));
 
        if (sync_file)
                flags |= FIEMAP_FLAG_SYNC;
@@ -534,15 +535,17 @@ int main(int argc, char**argv)
                                char *end;
                                blocksize = strtoul(optarg, &end, 0);
                                if (end) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
                                        switch (end[0]) {
                                        case 'g':
                                        case 'G':
                                                blocksize *= 1024;
-                                               /* no break */
+                                               /* fall through */
                                        case 'm':
                                        case 'M':
                                                blocksize *= 1024;
-                                               /* no break */
+                                               /* fall through */
                                        case 'k':
                                        case 'K':
                                                blocksize *= 1024;
@@ -550,6 +553,7 @@ int main(int argc, char**argv)
                                        default:
                                                break;
                                        }
+#pragma GCC diagnostic pop
                                }
                        } else { /* Allow -b without argument for compat. Remove
                                  * this eventually so "-b {blocksize}" works */
index cd23537ad13d61ea24deee203f62ed75c325b923..4efe10eca4160fae9544fb9f3d26da94c8bb58d1 100644 (file)
@@ -408,9 +408,12 @@ static char *find_fsck(char *type)
   tpl = (strncmp(type, "fsck.", 5) ? "%s/fsck.%s" : "%s/%s");
 
   for(s = strtok(p, ":"); s; s = strtok(NULL, ":")) {
-       if (snprintf(prog, sizeof(prog), tpl, s, type) >= sizeof(prog))
-               continue;
-       if (stat(prog, &st) == 0) break;
+         int len = snprintf(prog, sizeof(prog), tpl, s, type);
+
+         if ((len < 0) || (len >= (int) sizeof(prog)))
+                 continue;
+         if (stat(prog, &st) == 0)
+                 break;
   }
   free(p);
   return(s ? prog : NULL);
@@ -437,11 +440,12 @@ static int execute(const char *type, const char *device, const char *mntpt,
                   int interactive)
 {
        char *s, *argv[80], prog[256];
-       int  argc, i;
+       int  argc, i, len;
        struct fsck_instance *inst, *p;
        pid_t   pid;
 
-       if (snprintf(prog, sizeof(prog), "fsck.%s", type) >= sizeof(prog))
+       len = snprintf(prog, sizeof(prog), "fsck.%s", type);
+       if ((len < 0) || (len >= (int) sizeof(prog)))
                return EINVAL;
 
        inst = malloc(sizeof(struct fsck_instance));
index 9feafd72577992065b15863b59de25749f0f62d9..056d34ec576257c2559d32d482b9e05d169b8dec 100644 (file)
@@ -118,7 +118,10 @@ typedef struct {
 
 typedef struct {
        u_int32_t       a_version;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
        acl_ea_entry    a_entries[0];
+#pragma GCC diagnostic pop
 } acl_ea_header;
 
 static inline size_t acl_ea_size(int count)
index fe35a4baf6f6ba1c581b006caf9f5e445f3d6436..76693faf763fc687986d7abd19a8559c24a158f5 100644 (file)
@@ -68,7 +68,7 @@ static char *fn_buf;
 static char *fn_numbuf;
 int zero_hugefile = 1;
 
-#define SYSFS_PATH_LEN 256
+#define SYSFS_PATH_LEN 300
 typedef char sysfs_path_t[SYSFS_PATH_LEN];
 
 #ifndef HAVE_SNPRINTF
index c0613578afcd0a01e781fc7e45216b5f048834c0..14311877cc8c56e003f86ac65bc82075b2da0382 100644 (file)
@@ -31,8 +31,8 @@
 
 int main (int argc, char ** argv)
 {
-       char name [EXT2_NAME_LEN];
-       char path [sizeof (LPF) + 1 + 256];
+       char name[EXT2_NAME_LEN + 2];
+       char path[sizeof (LPF) + 1 + 256];
        struct stat st;
        int i, j;
        int d;
index 93160c9a4dec1997058caccfa187d5d98cfab823..f1ddfe42c73e9272f42baa649dbff7df03b38392 100644 (file)
@@ -753,7 +753,8 @@ static void update_ea_inode_hash(struct rewrite_context *ctx, ext2_ino_t ino,
        if (retval)
                fatal_err(retval, "close ea_inode");
 
-       hash = ext2fs_crc32c_le(ctx->fs->csum_seed, ctx->ea_buf, inode->i_size);
+       hash = ext2fs_crc32c_le(ctx->fs->csum_seed,
+                               (unsigned char *) ctx->ea_buf, inode->i_size);
        ext2fs_set_ea_inode_hash(inode, hash);
 }
 
@@ -802,7 +803,7 @@ static void update_inline_xattr_hashes(struct rewrite_context *ctx,
 }
 
 static void update_block_xattr_hashes(struct rewrite_context *ctx,
-                                     void *block_buf)
+                                     char *block_buf)
 {
        struct ext2_ext_attr_header *header;
        struct ext2_ext_attr_entry *start, *end;
index 7afc1342bc88b054968b2fd1ee350beed8b2c87e..fe52a61798ebeeb3e229856de1738122154d4eda 100644 (file)
@@ -1991,7 +1991,6 @@ static int fix_ea_entries(ext2_extent imap, struct ext2_ext_attr_entry *entry,
 {
        int modified = 0;
        ext2_ino_t new_ino;
-       errcode_t retval;
 
        while (entry < end && !EXT2_EXT_IS_LAST_ENTRY(entry)) {
                if (entry->e_value_inum > last_ino) {
@@ -2061,10 +2060,12 @@ static errcode_t fix_ea_inode_refs(ext2_resize_t rfs, struct ext2_inode *inode,
        int             inode_size = EXT2_INODE_SIZE(fs->super);
        blk64_t         blk;
        int             modified;
-       struct blk_cache blk_cache = { 0 };
+       struct blk_cache blk_cache;
        struct ext2_ext_attr_header *header;
        errcode_t               retval;
 
+       memset(&blk_cache, 0, sizeof(blk_cache));
+
        header = (struct ext2_ext_attr_header *)block_buf;
 
        retval = ext2fs_open_inode_scan(fs, 0, &scan);
index d028a601ce2968c633b12c336d6c01a3a87fc92b..0a0f306de3ddb17c0aaafcf65f8a789502c82461 100644 (file)
@@ -93,6 +93,10 @@ void do_create_icount(int argc, char **argv)
 
 void do_free_icount(int argc, char **argv)
 {
+       if (argc != 1) {
+               printf("Usage: free_icount\n");
+               return;
+       }
        if (check_icount(argv[0]))
                return;
 
@@ -206,6 +210,10 @@ void do_dump(int argc, char **argv)
        ext2_ino_t      i;
        __u16           count;
 
+       if (argc != 1) {
+               printf("Usage: dump\n");
+               return;
+       }
        if (check_icount(argv[0]))
                return;
        for (i=1; i <= test_fs->super->s_inodes_count; i++) {
@@ -224,6 +232,10 @@ void do_validate(int argc, char **argv)
 {
        errcode_t       retval;
 
+       if (argc != 1) {
+               printf("Usage: validate\n");
+               return;
+       }
        if (check_icount(argv[0]))
                return;
        retval = ext2fs_icount_validate(test_icount, stdout);
@@ -238,6 +250,10 @@ void do_get_size(int argc, char **argv)
 {
        ext2_ino_t      size;
 
+       if (argc != 1) {
+               printf("Usage: get_size\n");
+               return;
+       }
        if (check_icount(argv[0]))
                return;
        size = ext2fs_get_icount_size(test_icount);