2021-06-16 04:59:33

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 0/6] 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
--
2.32.0.272.g935e593368-goog


2021-06-16 04:59:33

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 3/6] mke2fs: use ext2fs_get_device_size2() on all platforms

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 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 *'.

Signed-off-by: Eric Biggers <[email protected]>
---
misc/mke2fs.c | 6 ------
1 file changed, 6 deletions(-)

diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index afbcf486..d5ab334e 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -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"));
--
2.32.0.272.g935e593368-goog

2021-06-16 04:59:33

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 5/6] Fix -Wunused-variable warnings

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]>
---
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(-)

diff --git a/e2fsck/extents.c b/e2fsck/extents.c
index 4e6e2611..0274e053 100644
--- a/e2fsck/extents.c
+++ b/e2fsck/extents.c
@@ -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;
diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index 5a06e26e..0aeaf416 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -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);
diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c
index 204ff7de..7d30ff00 100644
--- a/e2fsck/rehash.c
+++ b/e2fsck/rehash.c
@@ -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);
diff --git a/lib/e2p/errcode.c b/lib/e2p/errcode.c
index 27d4b15f..7e426553 100644
--- a/lib/e2p/errcode.c
+++ b/lib/e2p/errcode.c
@@ -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))
diff --git a/lib/e2p/fgetflags.c b/lib/e2p/fgetflags.c
index 0f1a059e..93e130c6 100644
--- a/lib/e2p/fgetflags.c
+++ b/lib/e2p/fgetflags.c
@@ -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;
diff --git a/lib/e2p/fsetflags.c b/lib/e2p/fsetflags.c
index 28515547..6455e386 100644
--- a/lib/e2p/fsetflags.c
+++ b/lib/e2p/fsetflags.c
@@ -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) {
diff --git a/lib/ext2fs/mkjournal.c b/lib/ext2fs/mkjournal.c
index bc8c57bf..11d73e30 100644
--- a/lib/ext2fs/mkjournal.c
+++ b/lib/ext2fs/mkjournal.c
@@ -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;
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index d5ab334e..54aa340a 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -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);
--
2.32.0.272.g935e593368-goog

2021-07-07 02:44:25

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH 3/6] mke2fs: use ext2fs_get_device_size2() on all platforms

On Tue, Jun 15, 2021 at 09:53:31PM -0700, Eric Biggers wrote:
> 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 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 *'.
>
> Signed-off-by: Eric Biggers <[email protected]>

Applied, thanks.

- Ted

2021-07-07 03:15:07

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH 5/6] Fix -Wunused-variable warnings

On Tue, Jun 15, 2021 at 09:53:33PM -0700, Eric Biggers wrote:
> 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