e2fsprogs: fix compiler warnings introduced since v1.45.4
cover e2fsprogs: fix compiler warnings introduced since v1.45.4
Fix various compiler warnings that were introduced since e2fsprogs v1.45.4, including the following types of warnings:
-Wunused-variable (enabled by -Wall)
-Wunused-label (enabled by -Wall)
-Wunused-parameter
Note, there were also -Wpointer-arith (arithmetic on a void pointer is a GNU extension) warnings introduced, but I don't find those to be very useful. But I can send out a patch for those too if people want it.
Also fix a -Wincompatible-pointer-types warning in the Windows build.
Eric Biggers (6):
libext2fs: improve jbd_debug() implementation
e2fsck: sync fc_do_one_pass() changes from kernel
mke2fs: use ext2fs_get_device_size2() on all platforms Fix -Wunused-parameter warnings
Fix -Wunused-variable warnings
libext2fs: fix a -Wunused-label warning
debugfs/journal.c | 7 ++----- e2fsck/extents.c | 2 +- e2fsck/jfs_user.h | 3 ++- e2fsck/journal.c | 18 +++++------------- e2fsck/pass1b.c | 3 ++- e2fsck/pass2.c | 3 ++- e2fsck/recovery.c | 5 ++--- e2fsck/rehash.c | 2 +- lib/e2p/errcode.c | 1 - lib/e2p/fgetflags.c | 2 +- lib/e2p/fsetflags.c | 1 - lib/ext2fs/kernel-jbd.h | 26 +++++--------------------- lib/ext2fs/mkjournal.c | 1 - lib/ext2fs/unix_io.c | 1 - lib/support/mkquota.c | 3 ++- misc/mke2fs.c | 8 ++------ 16 files changed, 27 insertions(+), 59 deletions(-)
base-commit: 32fda1e5a338ff676ae7f7e3e2bc256e7a7e2855
Signature · 1 line
2.32.0.272.g935e593368-goog
PATCH 1/6 libext2fs: improve jbd_debug() implementation
From: Eric Biggers <[email protected]>
Make jbd_debug() do format string checking (but still get compiled away to nothing) when --enable-jbd-debug isn't specified, similar to commit d556435156b7 ("jbd2: avoid -Wempty-body warnings") on the kernel side. This should prevent --enable-jbd-debug from getting broken due to bad jbd_debug() statements. It also eliminates a -Wunused-variable warning where a variable was only used in a jbd_debug() statement.
Also remove an alternative definition of jbd_debug() that was conditional on CONFIG_JBD_DEBUG && !CONFIG_JBD_DEBUG, so was dead code.
--- debugfs/journal.c | 4 ---- e2fsck/journal.c | 4 ---- lib/ext2fs/kernel-jbd.h | 26 +++++--------------------- 3 files changed, 5 insertions(+), 29 deletions(-)
debugfs/journal.c +0 -4
@@ -26,9 +26,7 @@#include "uuid/uuid.h" #include "journal.h" -#ifdef CONFIG_JBD_DEBUG /* Enabled by configure --enable-jfs-debug */ static int bh_count =0 ; -#endif #if EXT2_FLAT_INCLUDES #include "blkid.h"
@@ -135,10 +133,8 @@ struct buffer_head *getblk(kdev_t kdev, unsigned long long blocknr,if (retval)return NULL ; -#ifdef CONFIG_JBD_DEBUG if (journal_enable_debug >=3 ) bh_count++; -#endif jfs_debug (4 ,"getblk for block %llu (%d bytes)(total %d)\n" , blocknr, blocksize, bh_count);
e2fsck/journal.c +0 -4
@@ -27,9 +27,7 @@#include "problem.h" #include "uuid/uuid.h" -#ifdef CONFIG_JBD_DEBUG /* Enabled by configure --enable-jfs-debug */ static int bh_count =0 ; -#endif /* * Define USE_INODE_IO to use the inode_io.c / fileio.c codepaths.
@@ -129,10 +127,8 @@ struct buffer_head *getblk(kdev_t kdev, unsigned long long blocknr,if (!bh)return NULL ; -#ifdef CONFIG_JBD_DEBUG if (journal_enable_debug >=3 ) bh_count++; -#endif jfs_debug (4 ,"getblk for block %llu (%d bytes)(total %d)\n" , blocknr, blocksize, bh_count);
lib/ext2fs/kernel-jbd.h +5 -21
@@ -26,7 +26,6 @@#define journal_oom_retry 0 -#ifdef __STDC__#ifdef CONFIG_JBD_DEBUG /* * Define JBD_EXPENSIVE_CHECKING to enable more expensive internal
@@ -35,7 +34,11 @@*/ #define JBD_EXPENSIVE_CHECKING extern int journal_enable_debug; +#else +#define journal_enable_debug (-1) +#endif /* !CONFIG_JBD_DEBUG */ +#ifdef __STDC__ #define jbd_debug(n, f, a...) \ do { \ if ((n) <= journal_enable_debug) { \
@@ -45,27 +48,8 @@ extern int journal_enable_debug; } \ } while (0)#else -#ifdef __GNUC__ -#if defined(__KERNEL__) || !defined(CONFIG_JBD_DEBUG ) -#define jbd_debug(f, a...) /**/ -#else -extern int journal_enable_debug; -#define jbd_debug(n, f, a...) \ - do { \ - if ((n) <= journal_enable_debug) { \ - printf("(%s, %d): %s: ", \ - __FILE__, __LINE__, __func__); \ - printf(f, ## a); \ - } \ - } while (0) -#endif /*__KERNEL__ */ -#else -#define jbd_debug (f, ...)/**/ -#endif -#endif -#else #define jbd_debug (x)/* AIX doesn't do STDC */ -#endif +#endif /* !__STDC__ */ extern void *__jbd_kmalloc (char *where,size_t size,int flags,int retry);#define jbd_kmalloc (size, flags) \
Signature · 1 line
2.32.0.272.g935e593368-goog
Theodore Ts'o
AppliedRe: [PATCH 1/6] libext2fs: improve jbd_debug() implementation
Quoted 9 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Make
jbd_debug()do format string checking (but still get compiled away to nothing) when --enable-jbd-debug isn't specified, similar to commitd556435156b7("jbd2: avoid -Wempty-body warnings") on the kernel side. This should prevent --enable-jbd-debug from getting broken due to badjbd_debug()statements. It also eliminates a -Wunused-variable warning where a variable was only used in ajbd_debug()statement.
Quoted 4 lines
Also remove an alternative definition of
jbd_debug()that was conditional onCONFIG_JBD_DEBUG&& !CONFIG_JBD_DEBUG, so was dead code.Signed-off-by Eric Biggers <[email protected]>
Thanks, applied.
- Ted
PATCH 2/6 e2fsck: sync fc_do_one_pass() changes from kernel
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Sync the changes to fc_do_one_pass() from the kernel's recovery.c so that e2fsck picks up the fixes to the jbd_debug() statements.
--- e2fsck/recovery.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
e2fsck/recovery.c +2 -3
@@ -245,15 +245,14 @@ static int fc_do_one_pass(journal_t *journal,return 0 ;while (next_fc_block <= journal->j_fc_last) { -jbd_debug (3 ,"Fast commit replay: next block %ld" , +jbd_debug (3 ,"Fast commit replay: next block %ld\n" , next_fc_block); err =jread (&bh, journal, next_fc_block);if (err) { -jbd_debug (3 ,"Fast commit replay: read error" ); +jbd_debug (3 ,"Fast commit replay: read error\n" );break ; } -jbd_debug (3 ,"Processing fast commit blk with seq %d" ); err = journal->j_fc_replay_callback (journal, bh, pass, next_fc_block - journal->j_fc_first, expected_commit_id);
Signature · 1 line
2.32.0.272.g935e593368-goog
Theodore Ts'o
AppliedRe: [PATCH 2/6] e2fsck: sync fc_do_one_pass() changes from kernel
Quoted 6 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Sync the changes to
fc_do_one_pass()from the kernel'srecovery.cso that e2fsck picks up the fixes to thejbd_debug()statements.Signed-off-by Eric Biggers <[email protected]>
Applied, thanks.
- Ted
PATCH 3/6 mke2fs: use ext2fs_get_device_size2() on all platforms
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Since commit e8c858047be6 ("libext2fs: fix build issue for on Windows/Cygwin systems"), ext2fs_get_device_size2() is available in Windows builds of libext2fs. So there is no need for mke2fs to call ext2fs_get_device_size() instead.
This fixes a -Wincompatible-pointer-types warning because ext2fs_get_device_size() was being passed a 'blk64_t *', but it expected a 'blk_t *'.
--- misc/mke2fs.c | 6 ------ 1 file changed, 6 deletions(-)
misc/mke2fs.c +0 -6
@@ -1989,15 +1989,9 @@ profile_error: dev_size = fs_blocks_count; retval =0 ; }else -#ifndef _WIN32 retval =ext2fs_get_device_size2 (device_name,EXT2_BLOCK_SIZE (&fs_param), &dev_size); -#else - retval =ext2fs_get_device_size (device_name, -EXT2_BLOCK_SIZE (&fs_param), - &dev_size); -#endif if (retval && (retval !=EXT2_ET_UNIMPLEMENTED )) {com_err (program_name, retval,"%s" ,_ ("while trying to determine filesystem size" ));
Signature · 1 line
2.32.0.272.g935e593368-goog
Theodore Ts'o
AppliedRe: [PATCH 3/6] mke2fs: use ext2fs_get_device_size2() on all platforms
Quoted 7 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Since commit
e8c858047be6("libext2fs: fix build issue for on Windows/Cygwin systems"),ext2fs_get_device_size2()is available in Windows builds of libext2fs. So there is no need for mke2fs to callext2fs_get_device_size()instead.
Quoted 5 lines
This fixes a -Wincompatible-pointer-types warning because
ext2fs_get_device_size()was being passed a 'blk64_t*', but it expected a 'blk_t*'.Signed-off-by Eric Biggers <[email protected]>
Applied, thanks.
- Ted
PATCH 4/6 Fix -Wunused-parameter warnings
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Fix all warnings about unused function parameters that were introduced since e2fsprogs v1.45.4, by adding EXT2FS_ATTR((unused)) or removing parameters as appropriate.
--- debugfs/journal.c | 3 ++- e2fsck/jfs_user.h | 3 ++- e2fsck/journal.c | 7 ++++--- e2fsck/pass1b.c | 3 ++- e2fsck/pass2.c | 3 ++- lib/support/mkquota.c | 3 ++- 6 files changed, 14 insertions(+), 8 deletions(-)
debugfs/journal.c +2 -1
@@ -161,7 +161,8 @@ int sync_blockdev(kdev_t kdev)return io_channel_flush (io) ?EIO :0 ; } -void ll_rw_block (int rw,int op_flags,int nr,struct buffer_head *bhp[]) +void ll_rw_block(int rw, int op_flags EXT2FS_ATTR((unused)), int nr, + struct buffer_head *bhp[]) { errcode_t retval;struct buffer_head *bh;
e2fsck/jfs_user.h +2 -1
@@ -92,7 +92,8 @@ typedef struct kmem_cache {#define kmalloc (len, flags) malloc(len)#define kfree (p) free(p) -static inline void *kmalloc_array (unsigned n,unsigned size,int flags) +static inline void *kmalloc_array (unsigned n,unsigned size, + int flags EXT2FS_ATTR((unused))) {if (n && (~0U )/n < size)return NULL ;
e2fsck/journal.c +4 -3
@@ -155,7 +155,8 @@ int sync_blockdev(kdev_t kdev)return io_channel_flush (io) ? -EIO :0 ; } -void ll_rw_block (int rw,int op_flags,int nr,struct buffer_head *bhp[]) +void ll_rw_block(int rw, int op_flags EXT2FS_ATTR((unused)), int nr, + struct buffer_head *bhp[]) { errcode_t retval;struct buffer_head *bh;
@@ -439,7 +440,7 @@ static int ex_len_compar(const void *arg1, const void *arg2)return 0 ; } -static void ex_sort_and_merge (e2fsck_t ctx,struct extent_list *list) +static void ex_sort_and_merge (struct extent_list *list) {blk64_t ex_end;int i, j;
@@ -549,7 +550,7 @@ static int ext4_modify_extent_list(e2fsck_t ctx, struct extent_list *list, list->extents[list->count -1 ] = add_ex; } -ex_sort_and_merge (ctx, list); +ex_sort_and_merge (list);/* Mark all occupied blocks allocated */ for (i =0 ; i < list->count; i++)
e2fsck/pass1b.c +2 -1
@@ -104,7 +104,8 @@ static dict_t clstr_dict, ino_dict;static ext2fs_inode_bitmap inode_dup_map; -static int dict_int_cmp (const void * cmp_ctx,const void *a,const void *b) +static int dict_int_cmp(const void *cmp_ctx EXT2FS_ATTR((unused)), + const void *a, const void *b) {intptr_t ia, ib;
e2fsck/pass2.c +2 -1
@@ -332,7 +332,8 @@ static short htree_depth(struct dx_dir_info *dx_dir,return depth; } -static int dict_de_cmp (const void *cmp_ctx,const void *a,const void *b) +static int dict_de_cmp(const void *cmp_ctx EXT2FS_ATTR((unused)), + const void *a, const void *b) {const struct ext2_dir_entry *de_a, *de_b;int a_len, b_len;
lib/support/mkquota.c +2 -1
@@ -234,7 +234,8 @@ out:/* Helper functions for computing quota in memory. */ /******************************************************************/ -static int dict_uint_cmp (const void *cmp_ctx,const void *a,const void *b) +static int dict_uint_cmp(const void *cmp_ctx EXT2FS_ATTR((unused)), + const void *a, const void *b) {unsigned int c, d;
Signature · 1 line
2.32.0.272.g935e593368-goog
Theodore Ts'o
AppliedRe: [PATCH 4/6] Fix -Wunused-parameter warnings
Quoted 7 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Fix all warnings about unused function parameters that were introduced since e2fsprogs v1.45.4, by adding EXT2FS_ATTR((unused)) or removing parameters as appropriate.
Signed-off-by Eric Biggers <[email protected]>
Applied, thanks.
- Ted
PATCH 5/6 Fix -Wunused-variable warnings
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Fix all warnings about unused variables that were introduced since e2fsprogs v1.45.4.
--- e2fsck/extents.c | 2 +- e2fsck/journal.c | 7 +------ e2fsck/rehash.c | 2 +- lib/e2p/errcode.c | 1 - lib/e2p/fgetflags.c | 2 +- lib/e2p/fsetflags.c | 1 - lib/ext2fs/mkjournal.c | 1 - misc/mke2fs.c | 2 ++ 8 files changed, 6 insertions(+), 12 deletions(-)
e2fsck/extents.c +1 -1
@@ -203,7 +203,7 @@ errcode_t rewrite_extent_replay(e2fsck_t ctx, struct extent_list *list,ext2_extent_handle_t handle;unsigned int i, ext_written;struct ext2fs_extent *ex, extent; -blk64_t start_val, delta, blkcount; +blk64_t start_val, delta;/* Reset extent tree */ inode->i_flags &= ~EXT4_EXTENTS_FL ;
e2fsck/journal.c +1 -6
@@ -442,7 +442,6 @@ static int ex_len_compar(const void *arg1, const void *arg2)static void ex_sort_and_merge (struct extent_list *list) { -blk64_t ex_end;int i, j;if (list->count <2 )
@@ -490,7 +489,7 @@ static int ext4_modify_extent_list(e2fsck_t ctx, struct extent_list *list, {int ret;int i, offset; -struct ext2fs_extent add_ex = *ex, add_ex2; +struct ext2fs_extent add_ex = *ex;/* First let's create a hole from ex->e_lblk of length ex->e_len */ for (i =0 ; i < list->count; i++) {
@@ -634,9 +633,7 @@ static inline void tl_to_darg(struct dentry_info_args *darg,static int ext4_fc_handle_unlink (e2fsck_t ctx,struct ext4_fc_tl *tl) { -struct ext2_inode inode;struct dentry_info_args darg; -ext2_filsys fs = ctx->fs;int ret;tl_to_darg (&darg, tl);
@@ -724,7 +721,6 @@ static void ext4_fc_replay_fixup_iblocks(struct ext2_inode_large *ondisk_inode,static int ext4_fc_handle_inode (e2fsck_t ctx,struct ext4_fc_tl *tl) { -struct e2fsck_fc_replay_state *state = &ctx->fc_replay_state;int ino, inode_len =EXT2_GOOD_OLD_INODE_SIZE ;struct ext2_inode_large *inode =NULL , *fc_inode =NULL ;struct ext4_fc_inode *fc_inode_val;
@@ -790,7 +786,6 @@ static int ext4_fc_handle_add_extent(e2fsck_t ctx, struct ext4_fc_tl *tl) {struct ext2fs_extent extent;struct ext4_fc_add_range *add_range; -struct ext4_fc_del_range *del_range;int ret =0 , ino; add_range = (struct ext4_fc_add_range *)ext4_fc_tag_val (tl);
e2fsck/rehash.c +1 -1
@@ -287,7 +287,7 @@ static EXT2_QSORT_TYPE name_cf_cmp(const struct name_cmp_ctx *ctx, {const struct hash_entry *he_a = (const struct hash_entry *) a;const struct hash_entry *he_b = (const struct hash_entry *) b; -unsigned int he_a_len, he_b_len, min_len; +unsigned int he_a_len, he_b_len;int ret; he_a_len =ext2fs_dirent_name_len (he_a->dir);
lib/e2p/errcode.c +0 -1
@@ -34,7 +34,6 @@ static const char *err_string[] = {/* Return the name of an encoding or NULL */ const char *e2p_errcode2str (int err) { -unsigned int i;static char buf[32 ];if (err <ARRAY_SIZE (err_string))
lib/e2p/fgetflags.c +1 -1
@@ -50,8 +50,8 @@int fgetflags (const char * name,unsigned long * flags) { -struct stat buf;#if HAVE_STAT_FLAGS && !(APPLE_DARWIN &&HAVE_EXT2_IOCTLS ) +struct stat buf;if (stat (name, &buf) ==-1 )return -1 ;
lib/e2p/fsetflags.c +0 -1
@@ -81,7 +81,6 @@ int fsetflags (const char * name, unsigned long flags)return syscall (SYS_fsctl, name,EXT2_IOC_SETFLAGS , &f,0 );#elif HAVE_EXT2_IOCTLS int fd, r, f, save_errno =0 ; -struct stat buf; fd =open (name,OPEN_FLAGS );if (fd ==-1 ) {
lib/ext2fs/mkjournal.c +0 -1
@@ -604,7 +604,6 @@ errcode_t ext2fs_add_journal_inode2(ext2_filsys fs, blk_t num_blocks, blk64_t goal, int flags) {struct ext2fs_journal_params jparams; -errcode_t ret; jparams.num_journal_blocks = num_blocks; jparams.num_fc_blocks =0 ;
misc/mke2fs.c +2 -0
@@ -1577,7 +1577,9 @@ static void PRS(int argc, char *argv[])int use_bsize;char *newpath;int pathlen =sizeof (PATH_SET ) +1 ; +#ifdef HAVE_BLKID_PROBE_GET_TOPOLOGY struct device_param dev_param; +#endif if (oldpath) pathlen +=strlen (oldpath);
Signature · 1 line
2.32.0.272.g935e593368-goog
Re: [PATCH 5/6] Fix -Wunused-variable warnings
Quoted 6 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Fix all warnings about unused variables that were introduced since e2fsprogs v1.45.4.
Signed-off-by Eric Biggers <[email protected]>
Fixed, although I had to drop a hunk which was already fixed by the commit:
1e0c8ca7 e2fsck: fix portability problems caused by unaligned accesses
- Ted
PATCH 6/6 libext2fs: fix a -Wunused-label warning
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Remove a label which isn't used.
--- lib/ext2fs/unix_io.c | 1 - 1 file changed, 1 deletion(-)
lib/ext2fs/unix_io.c +0 -1
@@ -329,7 +329,6 @@ success_unlock: error_unlock:mutex_unlock (data,BOUNCE_MTX ); -error_out:if (actual >=0 && actual < size)memset ((char *) buf+actual,0 , size-actual);if (channel->read_error)
Signature · 1 line
2.32.0.272.g935e593368-goog
Theodore Ts'o
AppliedRe: [PATCH 6/6] libext2fs: fix a -Wunused-label warning
Quoted 5 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Remove a label which isn't used.
Signed-off-by Eric Biggers <[email protected]>
Applied, thanks.
- Ted