From b4450eadfa09dfdedd322af19ba3601335608632 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Tue, 2 Aug 2022 17:08:19 -0600 Subject: [PATCH] LU-16067 misc: cleanup compiler warnings Remove unused variables and various similar warnings. Signed-off-by: Andreas Dilger Change-Id: I2a773d118960deb42f77c1ae8b038029e6f6cd18 Reviewed-on: https://review.whamcloud.com/48110 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Artem Blagodarenko Reviewed-by: Li Dongyang --- e2fsck/dirinfo.c | 3 +-- e2fsck/e2fsck.h | 2 +- e2fsck/extents.c | 2 +- e2fsck/journal.c | 25 ++++++++++--------------- e2fsck/logfile.c | 1 - e2fsck/pass1.c | 6 ++---- e2fsck/pass2.c | 1 - e2fsck/rehash.c | 2 +- e2fsck/util.c | 1 - lib/e2p/errcode.c | 1 - lib/e2p/fgetflags.c | 2 +- lib/e2p/fsetflags.c | 1 - lib/ext2fs/ext_attr.c | 1 - lib/ext2fs/gen_bitmap64.c | 2 +- lib/ext2fs/mkjournal.c | 1 - lib/ext2fs/swapfs.c | 2 +- lib/ext2fs/unix_io.c | 1 - 17 files changed, 19 insertions(+), 35 deletions(-) diff --git a/e2fsck/dirinfo.c b/e2fsck/dirinfo.c index b4adaa6..322f4da 100644 --- a/e2fsck/dirinfo.c +++ b/e2fsck/dirinfo.c @@ -294,8 +294,7 @@ out: */ void e2fsck_add_dir_info(e2fsck_t ctx, ext2_ino_t ino, ext2_ino_t parent) { - struct dir_info *dir, *old_array; - ext2_ino_t i, j; + struct dir_info *old_array; errcode_t retval; unsigned long old_size; diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h index fb474a2..0c1c15a 100644 --- a/e2fsck/e2fsck.h +++ b/e2fsck/e2fsck.h @@ -299,7 +299,7 @@ struct e2fsck_thread { dgrp_t et_group_next; /* Scanned inode number */ ext2_ino_t et_inode_number; - char et_log_length; + int et_log_length; char et_log_buf[2048]; }; #endif diff --git a/e2fsck/extents.c b/e2fsck/extents.c index 4e6e261..0274e05 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 a425bbd..01c3bed 100644 --- a/e2fsck/journal.c +++ b/e2fsck/journal.c @@ -445,7 +445,6 @@ static int ex_len_compar(const void *arg1, const void *arg2) static void ex_sort_and_merge(e2fsck_t ctx, struct extent_list *list) { - blk64_t ex_end; int i, j; if (list->count < 2) @@ -493,7 +492,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++) { @@ -613,10 +612,9 @@ struct dentry_info_args { }; static inline void tl_to_darg(struct dentry_info_args *darg, - struct ext4_fc_tl *tl) + struct ext4_fc_tl *tl) { struct ext4_fc_dentry_info *fcd; - int tag = le16_to_cpu(tl->fc_tag); fcd = (struct ext4_fc_dentry_info *)ext4_fc_tag_val(tl); @@ -629,26 +627,25 @@ static inline void tl_to_darg(struct dentry_info_args *darg, memcpy(darg->dname, fcd->fc_dname, darg->dname_len); darg->dname[darg->dname_len] = 0; jbd_debug(1, "%s: %s, ino %d, parent %d\n", - tag == EXT4_FC_TAG_CREAT ? "create" : - (tag == EXT4_FC_TAG_LINK ? "link" : - (tag == EXT4_FC_TAG_UNLINK ? "unlink" : "error")), - darg->dname, darg->ino, darg->parent_ino); + le16_to_cpu(tl->fc_tag) == EXT4_FC_TAG_CREAT ? "create" : + (le16_to_cpu(tl->fc_tag) == EXT4_FC_TAG_LINK ? "link" : + (le16_to_cpu(tl->fc_tag) == EXT4_FC_TAG_UNLINK ? "unlink" : + "error")), + darg->dname, darg->ino, darg->parent_ino); } 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); ext4_fc_flush_extents(ctx, darg.ino); - ret = errcode_to_errno( - ext2fs_unlink(ctx->fs, darg.parent_ino, - darg.dname, darg.ino, 0)); + ret = errcode_to_errno(ext2fs_unlink(ctx->fs, darg.parent_ino, + darg.dname, darg.ino, 0)); /* It's okay if the above call fails */ free(darg.dname); + return ret; } @@ -727,7 +724,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; @@ -793,7 +789,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/logfile.c b/e2fsck/logfile.c index 60ab95f..1d71d8c 100644 --- a/e2fsck/logfile.c +++ b/e2fsck/logfile.c @@ -292,7 +292,6 @@ static FILE *set_up_log_file(e2fsck_t ctx, const char *key, const char *fn) struct string s, s1, s2; char *s0 = 0, *log_dir = 0, *log_fn = 0; int log_dir_wait = 0; - int string_size; char string_index[10]; s.s = s1.s = s2.s = 0; diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index 239766a..6905e49 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -1703,7 +1703,6 @@ static int precreated_object(struct ext2_inode *inode) void e2fsck_pass1_run(e2fsck_t ctx) { - int i; ext2_filsys fs = ctx->fs; ext2_ino_t ino = 0; struct ext2_inode *inode = NULL; @@ -1727,7 +1726,7 @@ void e2fsck_pass1_run(e2fsck_t ctx) dgrp_t ra_group = 0; struct ea_quota ea_ibody_quota; struct process_inode_block *inodes_to_process; - int process_inode_count, check_mmp; + int process_inode_count, check_mmp = 0; e2fsck_t global_ctx = ctx->global_ctx ? ctx->global_ctx : ctx; int inode_exp = 0; @@ -2215,6 +2214,7 @@ void e2fsck_pass1_run(e2fsck_t ctx) void *ehp; #ifdef WORDS_BIGENDIAN __u32 tmp_block[EXT2_N_BLOCKS]; + int i; for (i = 0; i < EXT2_N_BLOCKS; i++) tmp_block[i] = ext2fs_swab32(inode->i_block[i]); @@ -2941,7 +2941,6 @@ static void e2fsck_pass1_copy_invalid_bitmaps(e2fsck_t global_ctx, static void e2fsck_pass1_merge_invalid_bitmaps(e2fsck_t global_ctx, e2fsck_t thread_ctx) { - dgrp_t i, j; dgrp_t grp_start = thread_ctx->thread_info.et_group_start; dgrp_t grp_end = thread_ctx->thread_info.et_group_end; dgrp_t total = grp_end - grp_start; @@ -3881,7 +3880,6 @@ void e2fsck_mark_inode_bad_loc(e2fsck_t ctx, struct problem_context *pctx, const int line) { __u16 badness_before, badness_after; - __u64 pctx_num_sav = pctx->num; if (!ctx->inode_badness_threshold) /* badness is disabled */ return; diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c index 69a18da..13159f1 100644 --- a/e2fsck/pass2.c +++ b/e2fsck/pass2.c @@ -2026,7 +2026,6 @@ int e2fsck_process_bad_inode(e2fsck_t ctx, ext2_ino_t dir, unsigned char *frag, *fsize; struct problem_context pctx; problem_t problem = 0; - __u16 badness = 0; unsigned int flags = ctx->fs->flags; flags = ctx->fs->flags; diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c index 2048678..e3759a1 100644 --- a/e2fsck/rehash.c +++ b/e2fsck/rehash.c @@ -292,7 +292,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/e2fsck/util.c b/e2fsck/util.c index 7dd565c..6dff68e 100644 --- a/e2fsck/util.c +++ b/e2fsck/util.c @@ -107,7 +107,6 @@ void log_out(e2fsck_t ctx, const char *fmt, ...) int buf_size; int msg_size; int left_size; - int fmt_length = strlen(fmt); #ifdef HAVE_PTHREAD if ((ctx->options & E2F_OPT_MULTITHREAD) && ctx->global_ctx) { diff --git a/lib/e2p/errcode.c b/lib/e2p/errcode.c index 27d4b15..7e42655 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 0f1a059..93e130c 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 2851554..6455e38 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/ext_attr.c b/lib/ext2fs/ext_attr.c index a74c253..ad51371 100644 --- a/lib/ext2fs/ext_attr.c +++ b/lib/ext2fs/ext_attr.c @@ -1032,7 +1032,6 @@ errcode_t ext2fs_xattrs_read_inode(struct ext2_xattr_handle *handle, unsigned int storage_size; char *start, *block_buf = NULL; blk64_t blk; - size_t i; errcode_t err; EXT2_CHECK_MAGIC(handle, EXT2_ET_MAGIC_EA_HANDLE); diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c index 25e29a3..22e42e9 100644 --- a/lib/ext2fs/gen_bitmap64.c +++ b/lib/ext2fs/gen_bitmap64.c @@ -1010,7 +1010,7 @@ errcode_t ext2fs_count_used_clusters(ext2_filsys fs, blk64_t start, { blk64_t next; blk64_t tot_set = 0; - errcode_t retval; + errcode_t retval = 0;; while (start < end) { retval = ext2fs_find_first_set_block_bitmap2(fs->block_map, diff --git a/lib/ext2fs/mkjournal.c b/lib/ext2fs/mkjournal.c index 4a71155..2be1009 100644 --- a/lib/ext2fs/mkjournal.c +++ b/lib/ext2fs/mkjournal.c @@ -658,7 +658,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/lib/ext2fs/swapfs.c b/lib/ext2fs/swapfs.c index 1006b2d..cd160b3 100644 --- a/lib/ext2fs/swapfs.c +++ b/lib/ext2fs/swapfs.c @@ -244,7 +244,7 @@ void ext2fs_swap_inode_full(ext2_filsys fs, struct ext2_inode_large *t, int bufsize) { unsigned i, extra_isize, attr_magic; - int has_extents, has_inline_data, islnk, fast_symlink; + int has_extents = 0, has_inline_data = 0, islnk = 0, fast_symlink = 0; unsigned int inode_size; __u32 *eaf, *eat; diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c index 09ea4fe..50e1956 100644 --- a/lib/ext2fs/unix_io.c +++ b/lib/ext2fs/unix_io.c @@ -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) -- 1.8.3.1