Fix gcc -Wall nits

This fixes the last set of gcc -Wall complaints.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
diff --git a/debugfs/extent_inode.c b/debugfs/extent_inode.c
index 69628a9..d726b2b 100644
--- a/debugfs/extent_inode.c
+++ b/debugfs/extent_inode.c
@@ -66,9 +66,8 @@
 
 void do_extent_open(int argc, char *argv[])
 {
-	struct ext3_extent_header *eh;
 	ext2_ino_t	inode;
-	int		i, ret;
+	int		ret;
 	errcode_t	retval;
 	char		*cp;
 
@@ -220,7 +219,6 @@
 {
 	struct ext2fs_extent extent;
 	errcode_t	retval;
-	int		err;
 
 	if (common_extent_args_process(argc, argv, 1, 1, "delete_node",
 				       "", CHECK_FS_RW | CHECK_FS_BITMAPS))
@@ -286,8 +284,6 @@
 void do_split_node(int argc, char *argv[])
 {
 	errcode_t	retval;
-	struct ext2fs_extent extent;
-	int err;
 
 	if (common_extent_args_process(argc, argv, 1, 1, "split_node",
 				       "", CHECK_FS_RW | CHECK_FS_BITMAPS))
@@ -465,8 +461,6 @@
 
 void do_fix_parents(int argc, char **argv)
 {
-	struct ext2fs_extent	extent;
-	struct ext2_extent_info	info;
 	errcode_t		retval;
 
 	if (common_extent_args_process(argc, argv, 1, 1, "fix_parents", "",
@@ -515,9 +509,7 @@
 
 void do_goto_block(int argc, char **argv)
 {
-	struct ext2fs_extent	extent;
 	errcode_t		retval;
-	int			op = EXT2_EXTENT_NEXT_LEAF;
 	blk64_t			blk;
 	int			level = 0, err;
 
diff --git a/debugfs/htree.c b/debugfs/htree.c
index 29ddf9c..24f8250 100644
--- a/debugfs/htree.c
+++ b/debugfs/htree.c
@@ -201,7 +201,6 @@
 	char		*buf = NULL;
 	struct 		ext2_dx_root_info  *rootnode;
 	struct 		ext2_dx_entry *ent;
-	struct		ext2_dx_countlimit *limit;
 	errcode_t	errcode;
 
 	if (check_fs_open(argv[0]))
@@ -255,7 +254,6 @@
 	fprintf(pager, "\t Flags: %d\n", rootnode->unused_flags);
 
 	ent = (struct ext2_dx_entry *) (buf + 24 + rootnode->info_length);
-	limit = (struct ext2_dx_countlimit *) ent;
 
 	htree_dump_int_node(current_fs, ino, &inode, rootnode, ent,
 			    buf + current_fs->blocksize,
diff --git a/debugfs/zap.c b/debugfs/zap.c
index 3f3620b..4a1afbe 100644
--- a/debugfs/zap.c
+++ b/debugfs/zap.c
@@ -32,9 +32,7 @@
 	ext2_ino_t	inode;
 	errcode_t	errcode;
 	blk64_t		block;
-	int		retval;
 	char		*file = NULL;
-	char		*in_file = NULL;
 	int		c, err;
 	int		offset = -1;
 	int		length = -1;
@@ -171,14 +169,11 @@
 
 void do_dump_block(int argc, char *argv[])
 {
-	unsigned long	pattern = 0;
 	unsigned char	*buf;
 	ext2_ino_t	inode;
 	errcode_t	errcode;
 	blk64_t		block;
-	int		retval;
 	char		*file = NULL;
-	char		*in_file = NULL;
 	int		c, err, i, j;
 	int		suppress = -1;
 
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index a8231f4..9c37515 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -274,7 +274,7 @@
 	struct ext2_super_block *sb = ctx->fs->super;
 	struct ext2_inode_large *inode;
 	struct ext2_ext_attr_entry *entry;
-	char *start, *end;
+	char *start;
 	unsigned int storage_size, remain;
 	int problem = 0;
 
@@ -283,7 +283,6 @@
 		inode->i_extra_isize;
 	start = ((char *) inode) + EXT2_GOOD_OLD_INODE_SIZE +
 		inode->i_extra_isize + sizeof(__u32);
-	end = (char *) inode + EXT2_INODE_SIZE(ctx->fs->super);
 	entry = (struct ext2_ext_attr_entry *) start;
 
 	/* scan all entry's headers first */
diff --git a/e2fsck/recovery.c b/e2fsck/recovery.c
index fcacabb..34c9e59 100644
--- a/e2fsck/recovery.c
+++ b/e2fsck/recovery.c
@@ -283,12 +283,9 @@
 int journal_skip_recovery(journal_t *journal)
 {
 	int			err;
-	journal_superblock_t *	sb;
-
 	struct recovery_info	info;
 
 	memset (&info, 0, sizeof(info));
-	sb = journal->j_superblock;
 
 	err = do_one_pass(journal, &info, PASS_SCAN);
 
@@ -363,11 +360,6 @@
 	int			tag_bytes = journal_tag_bytes(journal);
 	__u32			crc32_sum = ~0; /* Transactional Checksums */
 
-	/* Precompute the maximum metadata descriptors in a descriptor block */
-	int			MAX_BLOCKS_PER_DESC;
-	MAX_BLOCKS_PER_DESC = ((journal->j_blocksize-sizeof(journal_header_t))
-			       / tag_bytes);
-
 	/*
 	 * First thing is to establish what we expect to find in the log
 	 * (in terms of transaction IDs), and where (in terms of log
diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c
index aa7f406..1f0a0b8 100644
--- a/e2fsck/rehash.c
+++ b/e2fsck/rehash.c
@@ -828,7 +828,7 @@
 	struct dir_info_iter *	dirinfo_iter = 0;
 	ext2_ino_t		ino;
 	errcode_t		retval;
-	int			cur, max, all_dirs, dir_index, first = 1;
+	int			cur, max, all_dirs, first = 1;
 
 	init_resource_track(&rtrack, ctx->fs->io);
 	all_dirs = ctx->options & E2F_OPT_COMPRESS_DIRS;
@@ -840,7 +840,6 @@
 
 	clear_problem_context(&pctx);
 
-	dir_index = ctx->fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX;
 	cur = 0;
 	if (all_dirs) {
 		dirinfo_iter = e2fsck_dir_info_iter_begin(ctx);
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index 48db71a..6471592 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -204,8 +204,7 @@
 			ctx->fs_blockdev_count), ctx->fs_blockdev_count);
 	log_out(ctx, P_("%12u fifo\n", "%12u fifos\n", ctx->fs_fifo_count),
 		ctx->fs_fifo_count);
-	log_out(ctx, P_("%12u link\n", "%12u links\n",
-			ctx->fs_links_count - dir_links),
+	log_out(ctx, P_("%12u link\n", "%12u links\n", num_links),
 		ctx->fs_links_count - dir_links);
 	log_out(ctx, P_("%12u symbolic link", "%12u symbolic links",
 			ctx->fs_symlinks_count), ctx->fs_symlinks_count);
@@ -217,9 +216,8 @@
 			ctx->fs_sockets_count),
 		ctx->fs_sockets_count);
 	log_out(ctx, "------------\n");
-	log_out(ctx, P_("%12u file\n", "%12u files\n",
-			ctx->fs_total_count - dir_links),
-		ctx->fs_total_count - dir_links);
+	log_out(ctx, P_("%12u file\n", "%12u files\n", num_files),
+		num_files);
 }
 
 static void check_mount(e2fsck_t ctx)
diff --git a/e2fsck/util.c b/e2fsck/util.c
index f3ba645..a6b9e86 100644
--- a/e2fsck/util.c
+++ b/e2fsck/util.c
@@ -616,7 +616,7 @@
 errcode_t e2fsck_zero_blocks(ext2_filsys fs, blk_t blk, int num,
 			     blk_t *ret_blk, int *ret_count)
 {
-	int		j, count, next_update, next_update_incr;
+	int		j, count;
 	static char	*buf;
 	errcode_t	retval;
 
@@ -639,10 +639,6 @@
 		memset(buf, 0, fs->blocksize * STRIDE_LENGTH);
 	}
 	/* OK, do the write loop */
-	next_update = 0;
-	next_update_incr = num / 100;
-	if (next_update_incr < 1)
-		next_update_incr = 1;
 	for (j = 0; j < num; j += STRIDE_LENGTH, blk += STRIDE_LENGTH) {
 		count = num - j;
 		if (count > STRIDE_LENGTH)
diff --git a/lib/e2p/getversion.c b/lib/e2p/getversion.c
index e7c6fec..71031ff 100644
--- a/lib/e2p/getversion.c
+++ b/lib/e2p/getversion.c
@@ -31,7 +31,7 @@
 
 	r = ioctl (fd, EXT2_IOC_GETVERSION, &ver);
 	*version = ver;
-	return 0;
+	return r;
 #else /* ! HAVE_EXT2_IOCTLS */
 	extern int errno;
 	errno = EOPNOTSUPP;
diff --git a/lib/ext2fs/blkmap64_rb.c b/lib/ext2fs/blkmap64_rb.c
index 6007238..9a8938a 100644
--- a/lib/ext2fs/blkmap64_rb.c
+++ b/lib/ext2fs/blkmap64_rb.c
@@ -677,12 +677,11 @@
 	unsigned char *cp = in;
 	size_t i;
 	int first_set = -1;
-	int ret;
 
 	bp = (struct ext2fs_rb_private *) bitmap->private;
 
 	for (i = 0; i < num; i++) {
-		if (i & 7 == 0) {
+		if ((i & 7) == 0) {
 			unsigned char c = cp[i/8];
 			if (c == 0xFF) {
 				if (first_set == -1)
diff --git a/lib/ext2fs/imager.c b/lib/ext2fs/imager.c
index a0fb81e..7f3b25b 100644
--- a/lib/ext2fs/imager.c
+++ b/lib/ext2fs/imager.c
@@ -279,7 +279,7 @@
 errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags)
 {
 	ext2fs_generic_bitmap	bmap;
-	errcode_t		err, retval;
+	errcode_t		retval;
 	ssize_t			actual;
 	__u32			itr, cnt, size;
 	int			c, total_size;
@@ -292,7 +292,6 @@
 				return retval;
 		}
 		bmap = fs->inode_map;
-		err = EXT2_ET_MAGIC_INODE_BITMAP;
 		itr = 1;
 		cnt = EXT2_INODES_PER_GROUP(fs->super) * fs->group_desc_count;
 		size = (EXT2_INODES_PER_GROUP(fs->super) / 8);
@@ -303,7 +302,6 @@
 				return retval;
 		}
 		bmap = fs->block_map;
-		err = EXT2_ET_MAGIC_BLOCK_BITMAP;
 		itr = fs->super->s_first_data_block;
 		cnt = EXT2_BLOCKS_PER_GROUP(fs->super) * fs->group_desc_count;
 		size = EXT2_BLOCKS_PER_GROUP(fs->super) / 8;
@@ -356,7 +354,7 @@
 errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags)
 {
 	ext2fs_generic_bitmap	bmap;
-	errcode_t		err, retval;
+	errcode_t		retval;
 	__u32			itr, cnt;
 	char			buf[1024];
 	unsigned int		size;
@@ -369,7 +367,6 @@
 				return retval;
 		}
 		bmap = fs->inode_map;
-		err = EXT2_ET_MAGIC_INODE_BITMAP;
 		itr = 1;
 		cnt = EXT2_INODES_PER_GROUP(fs->super) * fs->group_desc_count;
 		size = (EXT2_INODES_PER_GROUP(fs->super) / 8);
@@ -380,7 +377,6 @@
 				return retval;
 		}
 		bmap = fs->block_map;
-		err = EXT2_ET_MAGIC_BLOCK_BITMAP;
 		itr = fs->super->s_first_data_block;
 		cnt = EXT2_BLOCKS_PER_GROUP(fs->super) * fs->group_desc_count;
 		size = EXT2_BLOCKS_PER_GROUP(fs->super) / 8;
diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c
index 482e4ab..d483bd9 100644
--- a/lib/ext2fs/openfs.c
+++ b/lib/ext2fs/openfs.c
@@ -99,10 +99,11 @@
 	errcode_t	retval;
 	unsigned long	i, first_meta_bg;
 	__u32		features;
-	unsigned int	groups_per_block, blocks_per_group, io_flags;
+	unsigned int	blocks_per_group, io_flags;
 	blk64_t		group_block, blk;
 	char		*dest, *cp;
 #ifdef WORDS_BIGENDIAN
+	unsigned int	groups_per_block;
 	struct ext2_group_desc *gdp;
 	int		j;
 #endif
@@ -332,7 +333,9 @@
 	if (group_block == 0 && fs->blocksize == 1024)
 		group_block = 1; /* Deal with 1024 blocksize && bigalloc */
 	dest = (char *) fs->group_desc;
+#ifdef WORDS_BIGENDIAN
 	groups_per_block = EXT2_DESC_PER_BLOCK(fs->super);
+#endif
 	if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
 		first_meta_bg = fs->super->s_first_meta_bg;
 	else
diff --git a/misc/e2initrd_helper.c b/misc/e2initrd_helper.c
index b2f39bc..aa97557 100644
--- a/misc/e2initrd_helper.c
+++ b/misc/e2initrd_helper.c
@@ -39,7 +39,7 @@
 #include "../version.h"
 #include "nls-enable.h"
 
-const char * program_name = "get_fstab";
+const char * program_name = "e2initrd_helper";
 char * device_name;
 static int open_flag;
 static int root_type;
@@ -327,7 +327,7 @@
 		usage();
 	device_name = blkid_get_devname(NULL, argv[optind], NULL);
 	if (!device_name) {
-		com_err("tune2fs", 0, _("Unable to resolve '%s'"),
+		com_err(program_name, 0, _("Unable to resolve '%s'"),
 			argv[optind]);
 		exit(1);
 	}
@@ -342,6 +342,10 @@
 	int		ret;
 
 	retval = get_file(fs, "/etc/fstab", &file);
+	if (retval) {
+		com_err(program_name, retval, "couldn't open /etc/fstab");
+		exit(1);
+	}
 
 	while (!mem_file_eof(&file)) {
 		buf = get_line(&file);
diff --git a/misc/filefrag.c b/misc/filefrag.c
index 13f5e15..ee03a07 100644
--- a/misc/filefrag.c
+++ b/misc/filefrag.c
@@ -336,7 +336,6 @@
 	static struct statfs fsinfo;
 	ext2fs_struct_stat st;
 	int		blk_shift;
-	int		bs;
 	long		fd;
 	unsigned long	numblocks;
 	int		data_blocks_per_cyl = 1;
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 84fe4ce..2c8b9e8 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -1092,7 +1092,7 @@
 		*io_options++ = 0;
 	device_name = blkid_get_devname(NULL, argv[optind], NULL);
 	if (!device_name) {
-		com_err("tune2fs", 0, _("Unable to resolve '%s'"),
+		com_err(program_name, 0, _("Unable to resolve '%s'"),
 			argv[optind]);
 		exit(1);
 	}