[U-Boot] [PATCH 2/2] ext4: Fix unused variable warnings

Simon Glass sjg at chromium.org
Wed Oct 3 21:53:48 CEST 2012


This patch fixes the following warnings with my gcc 4.6:

ext4fs.c:932:6: error: variable 'delayed_skipfirst' set but not used [-Werror=unused-but-set-variable]
ext4_common.c:381:8: error: variable 'ptr' set but not used [-Werror=unused-but-set-variable]
ext4_common.c:1170:8: error: variable 'status' set but not used [-Werror=unused-but-set-variable]

I'm not exactly sure whether this is the best fix, but it did look like
each variable is actually needed.

Signed-off-by: Simon Glass <sjg at chromium.org>
---
 common/cmd_ext4.c      |    2 +-
 fs/ext4/ext4_common.c  |    7 ++++---
 fs/ext4/ext4_journal.c |    4 ++--
 fs/ext4/ext4fs.c       |    1 +
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/common/cmd_ext4.c b/common/cmd_ext4.c
index ca46561..75bb8c1 100644
--- a/common/cmd_ext4.c
+++ b/common/cmd_ext4.c
@@ -107,7 +107,7 @@ int do_ext4_write(cmd_tbl_t *cmdtp, int flag, int argc,
 
 	/* mount the filesystem */
 	if (!ext4fs_mount(info.size)) {
-		printf("Bad ext4 partition %s %d:%lu\n", argv[1], dev, part);
+		printf("Bad ext4 partition %s %d:%d\n", argv[1], dev, part);
 		goto fail;
 	}
 
diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index d6d55b9..b66beaa 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -36,6 +36,7 @@
 #include <ext4fs.h>
 #include <malloc.h>
 #include <stddef.h>
+#include <linux/compiler.h>
 #include <linux/stat.h>
 #include <linux/time.h>
 #include <asm/byteorder.h>
@@ -378,7 +379,7 @@ void ext4fs_update_parent_dentry(char *filename, int *p_ino, int file_type)
 	struct ext_filesystem *fs = get_fs();
 	/* directory entry */
 	struct ext2_dirent *dir;
-	char *ptr = NULL;
+	__maybe_unused char *ptr = NULL;
 	char *temp_dir = NULL;
 
 	zero_buffer = zalloc(fs->blksz);
@@ -531,7 +532,7 @@ static int search_dir(struct ext2_inode *parent_inode, char *dirname)
 	int direct_blk_idx;
 	long int blknr;
 	int found = 0;
-	char *ptr = NULL;
+	__maybe_unused char *ptr = NULL;
 	unsigned char *block_buffer = NULL;
 	struct ext2_dirent *dir = NULL;
 	struct ext2_dirent *previous_dir = NULL;
@@ -1170,7 +1171,7 @@ static void alloc_double_indirect_block(struct ext2_inode *file_inode,
 {
 	short i;
 	short j;
-	short status;
+	__maybe_unused short status;
 	long int actual_block_no;
 	/* di:double indirect */
 	long int di_blockno_parent;
diff --git a/fs/ext4/ext4_journal.c b/fs/ext4/ext4_journal.c
index 8a252d6..7281269 100644
--- a/fs/ext4/ext4_journal.c
+++ b/fs/ext4/ext4_journal.c
@@ -34,6 +34,7 @@
 #include <malloc.h>
 #include <ext_common.h>
 #include "ext4_common.h"
+#include <linux/compiler.h>
 
 static struct revoke_blk_list *revk_blk_list;
 static struct revoke_blk_list *prev_node;
@@ -410,7 +411,7 @@ int ext4fs_check_journal_state(int recovery_flag)
 	int transaction_state = TRANSACTION_COMPLETE;
 	int prev_desc_logical_no = 0;
 	int curr_desc_logical_no = 0;
-	int ofs, flags, block;
+	int ofs, flags;
 	struct ext2_inode inode_journal;
 	struct journal_superblock_t *jsb = NULL;
 	struct journal_header_t *jdb = NULL;
@@ -453,7 +454,6 @@ int ext4fs_check_journal_state(int recovery_flag)
 
 	i = be32_to_cpu(jsb->s_first);
 	while (1) {
-		block = be32_to_cpu(jsb->s_first);
 		blknr = read_allocated_block(&inode_journal, i);
 		memset(temp_buff1, '\0', fs->blksz);
 		ext4fs_devread(blknr * fs->sect_perblk,
diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
index 4eded1a..ccdaa15 100644
--- a/fs/ext4/ext4fs.c
+++ b/fs/ext4/ext4fs.c
@@ -37,6 +37,7 @@
 #include <malloc.h>
 #include <ext_common.h>
 #include <ext4fs.h>
+#include <linux/compiler.h>
 #include <linux/stat.h>
 #include <linux/time.h>
 #include <asm/byteorder.h>
-- 
1.7.7.3



More information about the U-Boot mailing list