diff options
36 files changed, 139 insertions, 90 deletions
diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index a270e8c2..2bf6a30c 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -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; } diff --git a/debugfs/debugfs.h b/debugfs/debugfs.h index 3322d05a..93f036de 100644 --- a/debugfs/debugfs.h +++ b/debugfs/debugfs.h @@ -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); diff --git a/debugfs/xattrs.c b/debugfs/xattrs.c index 6c32712a..c29761ec 100644 --- a/debugfs/xattrs.c +++ b/debugfs/xattrs.c @@ -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); diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h index e930d816..cd5cba2f 100644 --- a/e2fsck/e2fsck.h +++ b/e2fsck/e2fsck.h @@ -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, diff --git a/e2fsck/extents.c b/e2fsck/extents.c index ef3146d8..3073725a 100644 --- a/e2fsck/extents.c +++ b/e2fsck/extents.c @@ -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++; diff --git a/e2fsck/jfs_user.h b/e2fsck/jfs_user.h index d30b728d..82897951 100644 --- a/e2fsck/jfs_user.h +++ b/e2fsck/jfs_user.h @@ -30,6 +30,14 @@ #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) diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index 8dfa82a0..f1fa5d94 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -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); diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c index c6aff71a..b92eec1e 100644 --- a/e2fsck/pass2.c +++ b/e2fsck/pass2.c @@ -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; diff --git a/e2fsck/quota.c b/e2fsck/quota.c index b0f9af63..3d48284f 100644 --- a/e2fsck/quota.c +++ b/e2fsck/quota.c @@ -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); diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c index 486e1f21..7c4ab083 100644 --- a/e2fsck/rehash.c +++ b/e2fsck/rehash.c @@ -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; diff --git a/e2fsck/unix.c b/e2fsck/unix.c index 61396f7f..42eef754 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -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); diff --git a/e2fsck/util.c b/e2fsck/util.c index 5793b65a..db6a1cc1 100644 --- a/e2fsck/util.c +++ b/e2fsck/util.c @@ -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; diff --git a/lib/e2p/crypto_mode.c b/lib/e2p/crypto_mode.c index bc553fde..4933016e 100644 --- a/lib/e2p/crypto_mode.c +++ b/lib/e2p/crypto_mode.c @@ -20,7 +20,7 @@ #include "e2p.h" struct mode { - unsigned int num; + int num; const char *string; }; diff --git a/lib/e2p/e2p.h b/lib/e2p/e2p.h index e96cdec8..d70b59a5 100644 --- a/lib/e2p/e2p.h +++ b/lib/e2p/e2p.h @@ -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); diff --git a/lib/e2p/ljs.c b/lib/e2p/ljs.c index 2db700b0..0b1beadb 100644 --- a/lib/e2p/ljs.c +++ b/lib/e2p/ljs.c @@ -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", diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index eb6c0926..3d4afac4 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -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 diff --git a/lib/ext2fs/ext4_acl.h b/lib/ext2fs/ext4_acl.h index 69ff79d5..1f5245de 100644 --- a/lib/ext2fs/ext4_acl.h +++ b/lib/ext2fs/ext4_acl.h @@ -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; diff --git a/lib/ext2fs/ext_attr.c b/lib/ext2fs/ext_attr.c index 81b067ad..77a03620 100644 --- a/lib/ext2fs/ext_attr.c +++ b/lib/ext2fs/ext_attr.c @@ -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++) { diff --git a/lib/ext2fs/fiemap.h b/lib/ext2fs/fiemap.h index a331bc12..5c851b24 100644 --- a/lib/ext2fs/fiemap.h +++ b/lib/ext2fs/fiemap.h @@ -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) diff --git a/lib/ext2fs/hashmap.h b/lib/ext2fs/hashmap.h index 71271866..be1e8a76 100644 --- a/lib/ext2fs/hashmap.h +++ b/lib/ext2fs/hashmap.h @@ -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( diff --git a/lib/ext2fs/jfs_compat.h b/lib/ext2fs/jfs_compat.h index 91373674..f1a3f968 100644 --- a/lib/ext2fs/jfs_compat.h +++ b/lib/ext2fs/jfs_compat.h @@ -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) diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c index 0c8ad24e..85d73e2a 100644 --- a/lib/ext2fs/openfs.c +++ b/lib/ext2fs/openfs.c @@ -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; diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c index c6b058d1..53fbd28b 100644 --- a/lib/ext2fs/unix_io.c +++ b/lib/ext2fs/unix_io.c @@ -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); } } diff --git a/lib/support/mkquota.c b/lib/support/mkquota.c index d136a915..0b9e7665 100644 --- a/lib/support/mkquota.c +++ b/lib/support/mkquota.c @@ -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; diff --git a/misc/e2freefrag.c b/misc/e2freefrag.c index 09fae5c2..268fac96 100644 --- a/misc/e2freefrag.c +++ b/misc/e2freefrag.c @@ -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) { diff --git a/misc/e2undo.c b/misc/e2undo.c index 6443ca2c..05937383 100644 --- a/misc/e2undo.c +++ b/misc/e2undo.c @@ -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 { diff --git a/misc/e4crypt.c b/misc/e4crypt.c index c1ec9ab9..759a082b 100644 --- a/misc/e4crypt.c +++ b/misc/e4crypt.c @@ -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); diff --git a/misc/e4defrag.c b/misc/e4defrag.c index d63343e9..5ac251dc 100644 --- a/misc/e4defrag.c +++ b/misc/e4defrag.c @@ -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, diff --git a/misc/filefrag.c b/misc/filefrag.c index c8444d76..7f1c5bfc 100644 --- a/misc/filefrag.c +++ b/misc/filefrag.c @@ -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 */ diff --git a/misc/fsck.c b/misc/fsck.c index cd23537a..4efe10ec 100644 --- a/misc/fsck.c +++ b/misc/fsck.c @@ -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)); diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index 9feafd72..056d34ec 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -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) diff --git a/misc/mk_hugefiles.c b/misc/mk_hugefiles.c index fe35a4ba..76693faf 100644 --- a/misc/mk_hugefiles.c +++ b/misc/mk_hugefiles.c @@ -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 diff --git a/misc/mklost+found.c b/misc/mklost+found.c index c0613578..14311877 100644 --- a/misc/mklost+found.c +++ b/misc/mklost+found.c @@ -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; diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 93160c9a..f1ddfe42 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -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; diff --git a/resize/resize2fs.c b/resize/resize2fs.c index 7afc1342..fe52a617 100644 --- a/resize/resize2fs.c +++ b/resize/resize2fs.c @@ -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); diff --git a/tests/progs/test_icount.c b/tests/progs/test_icount.c index d028a601..0a0f306d 100644 --- a/tests/progs/test_icount.c +++ b/tests/progs/test_icount.c @@ -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); |