[Ocfs2-tools-devel] [PATCH 2/5] tools: Fix build warnings

Sunil Mushran sunil.mushran at oracle.com
Thu Feb 9 16:54:24 PST 2012


o2cb_abi.c:1265:5: warning: ‘hb_refs’ may be used uninitialized in this function [-Wuninitialized]
mkjournal.c:278:31: warning: variable ‘jsb’ set but not used [-Wunused-but-set-variable]
fsck.c:417:11: warning: variable ‘dir_links’ set but not used [-Wunused-but-set-variable]
mkfs.c:166:6: warning: unused variable ‘len’ [-Wunused-variable]
mounted.c:412:29: warning: variable ‘rocompat’ set but not used [-Wunused-but-set-variable]
mounted.c:412:11: warning: variable ‘compat’ set but not used [-Wunused-but-set-variable]
ocfs2ne.c:883:7: warning: variable ‘error’ set but not used [-Wunused-but-set-variable]
find_inode_paths.c:46:11: warning: variable ‘oldval’ set but not used [-Wunused-but-set-variable]
o2image.c:99:9: warning: variable ‘bits’ set but not used [-Wunused-but-set-variable]
o2image.c:501:28: warning: variable ‘super’ set but not used [-Wunused-but-set-variable]
o2info.c:379:7: warning: variable ‘error’ set but not used [-Wunused-but-set-variable]

Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
 debugfs.ocfs2/find_inode_paths.c |    4 +---
 extras/find_inode_paths.c        |    4 +---
 fsck.ocfs2/fsck.c                |    3 +--
 libo2cb/o2cb_abi.c               |    2 +-
 libocfs2/mkjournal.c             |    3 +--
 mkfs.ocfs2/mkfs.c                |    2 --
 mounted.ocfs2/mounted.c          |    4 +---
 o2image/o2image.c                |    6 ------
 o2info/libo2info.c               |    3 +--
 o2info/o2info.c                  |    2 --
 o2info/utils.c                   |    2 +-
 ocfs2_hb_ctl/ocfs2_hb_ctl.c      |    4 ++--
 tunefs.ocfs2/ocfs2ne.c           |    2 --
 13 files changed, 10 insertions(+), 31 deletions(-)

diff --git a/debugfs.ocfs2/find_inode_paths.c b/debugfs.ocfs2/find_inode_paths.c
index d24963a..03d6a3b 100644
--- a/debugfs.ocfs2/find_inode_paths.c
+++ b/debugfs.ocfs2/find_inode_paths.c
@@ -43,7 +43,7 @@ static int walk_tree_func(struct ocfs2_dir_entry *dentry,
 			  int blocksize, char *buf, void *priv_data)
 {
 	errcode_t ret;
-	int len, oldval;
+	int len;
 	int reti = 0;
 	int i = 0;
 	int print = 0;
@@ -74,8 +74,6 @@ static int walk_tree_func(struct ocfs2_dir_entry *dentry,
 	if (dentry->file_type == OCFS2_FT_DIR)
 		path[len + dentry->name_len] = '/';
 
-	oldval = 0;
-
 	for (i = 0; i < wp->count; ++i) {
 		if (dentry->inode == wp->inode[i]) {
 			if (!print)
diff --git a/extras/find_inode_paths.c b/extras/find_inode_paths.c
index b9ad920..5cee21d 100644
--- a/extras/find_inode_paths.c
+++ b/extras/find_inode_paths.c
@@ -60,7 +60,7 @@ static int walk_tree_func(struct ocfs2_dir_entry *dentry,
 			  void *priv_data)
 {
 	errcode_t ret;
-	int len, oldval;
+	int len;
 	int reti = 0;
 	char *old_path, *path;
 	struct walk_path *wp = priv_data;
@@ -89,8 +89,6 @@ static int walk_tree_func(struct ocfs2_dir_entry *dentry,
 	if (dentry->file_type == OCFS2_FT_DIR)
 		path[len + dentry->name_len] = '/';
 
-	oldval = 0;
-
 	if (!wp->quiet)
 		fprintf(stdout, "[trace] %13"PRIu64" %s\n",
 			(uint64_t)dentry->inode, path);
diff --git a/fsck.ocfs2/fsck.c b/fsck.ocfs2/fsck.c
index 181125f..4b7d4b3 100644
--- a/fsck.ocfs2/fsck.c
+++ b/fsck.ocfs2/fsck.c
@@ -414,12 +414,11 @@ static void print_version(void)
 
 static void show_stats(o2fsck_state *ost)
 {
-	uint32_t dir_links, num_links;
+	uint32_t num_links;
 
 	if (!ost->ost_show_stats)
 		return;
 
-	dir_links = ost->ost_dir_count;
 	num_links = ost->ost_links_count - ost->ost_dir_count;
 
 	printf("\n  # of inodes with depth 0/1/2/3/4/5: %u/%u/%u/%u/%u/%u\n",
diff --git a/libo2cb/o2cb_abi.c b/libo2cb/o2cb_abi.c
index d789620..ae03595 100644
--- a/libo2cb/o2cb_abi.c
+++ b/libo2cb/o2cb_abi.c
@@ -1238,7 +1238,7 @@ errcode_t o2cb_stop_heartbeat(struct o2cb_cluster_desc *cluster,
 			      struct o2cb_region_desc *region)
 {
 	errcode_t ret, up_ret;
-	int hb_refs;
+	int hb_refs = 0;
 	int semid;
 
 	ret = o2cb_mutex_down_lookup(region->r_name, &semid);
diff --git a/libocfs2/mkjournal.c b/libocfs2/mkjournal.c
index cb0e2ee..5389b51 100644
--- a/libocfs2/mkjournal.c
+++ b/libocfs2/mkjournal.c
@@ -275,7 +275,7 @@ errcode_t ocfs2_write_journal_superblock(ocfs2_filesys *fs, uint64_t blkno,
 {
 	errcode_t ret;
 	char *blk;
-	journal_superblock_t *disk, *jsb;
+	journal_superblock_t *disk;
 	
 	if (!(fs->fs_flags & OCFS2_FLAG_RW))
 		return OCFS2_ET_RO_FILESYS;
@@ -289,7 +289,6 @@ errcode_t ocfs2_write_journal_superblock(ocfs2_filesys *fs, uint64_t blkno,
 		return ret;
 
 	disk = (journal_superblock_t *)blk;
-	jsb = (journal_superblock_t *)jsb_buf;
 
 	memcpy(blk, jsb_buf, fs->fs_blocksize);
 	ocfs2_swap_journal_superblock(disk);
diff --git a/mkfs.ocfs2/mkfs.c b/mkfs.ocfs2/mkfs.c
index 8a6017a..7abea73 100644
--- a/mkfs.ocfs2/mkfs.c
+++ b/mkfs.ocfs2/mkfs.c
@@ -163,8 +163,6 @@ static void translate_uuid(char *uuid_32, char *uuid_36)
 static int is_cluster_info_valid(State *s, char *stack_name,
 				 char *cluster_name, int globalhb)
 {
-	int len = 0;
-
 	if (!stack_name && !cluster_name && !globalhb)
 		return 1;
 
diff --git a/mounted.ocfs2/mounted.c b/mounted.ocfs2/mounted.c
index 383a9c8..2ed66bf 100644
--- a/mounted.ocfs2/mounted.c
+++ b/mounted.ocfs2/mounted.c
@@ -409,7 +409,7 @@ static ssize_t do_pread(int fd, void *buf, size_t count, off_t offset)
 
 static void populate_sb_info(ocfs2_devices *dev, struct ocfs2_super_block *sb)
 {
-	uint32_t compat, incompat, rocompat;
+	uint32_t incompat;
 
 	if (!sb)
 		return;
@@ -419,9 +419,7 @@ static void populate_sb_info(ocfs2_devices *dev, struct ocfs2_super_block *sb)
 	memcpy(dev->label, sb->s_label, sizeof(dev->label));
 	memcpy(dev->uuid, sb->s_uuid, sizeof(dev->uuid));
 
-	compat = le32_to_cpu(sb->s_feature_compat);
 	incompat = le32_to_cpu(sb->s_feature_incompat);
-	rocompat = le32_to_cpu(sb->s_feature_ro_compat);
 
 	memcpy(dev->label, sb->s_label, sizeof(dev->label));
 	memcpy(dev->uuid, sb->s_uuid, sizeof(dev->uuid));
diff --git a/o2image/o2image.c b/o2image/o2image.c
index 2b455db..465e7fe 100644
--- a/o2image/o2image.c
+++ b/o2image/o2image.c
@@ -90,17 +90,13 @@ static errcode_t mark_dealloc_bits(ocfs2_filesys *ofs,
 static errcode_t traverse_extents(ocfs2_filesys *ofs,
 				  struct ocfs2_extent_list *el)
 {
-	struct ocfs2_super_block *super;
 	struct ocfs2_extent_block *eb;
 	struct ocfs2_extent_rec *rec;
 	struct ocfs2_image_state *ost = ofs->ost;
 	errcode_t ret = 0;
 	char *buf = NULL;
-	__le32 bits;
 	int i, j;
 
-	super = OCFS2_RAW_SB(ofs->fs_super);
-	bits = super->s_clustersize_bits - super->s_blocksize_bits;
 	ret = ocfs2_malloc_block(ofs->fs_io, &buf);
 	if (ret)
 		goto out;
@@ -498,13 +494,11 @@ out:
 
 static errcode_t write_raw_image_file(ocfs2_filesys *ofs, int fd)
 {
-	struct ocfs2_super_block *super;
 	char *blk_buf = NULL;
 	uint64_t blk = -1;
 	ssize_t count;
 	errcode_t ret;
 
-	super = OCFS2_RAW_SB(ofs->fs_super);
 	ret = ocfs2_malloc_block(ofs->fs_io, &blk_buf);
 	if (ret) {
 		com_err(program_name, ret, "while allocating I/O buffer");
diff --git a/o2info/libo2info.c b/o2info/libo2info.c
index 7bd8567..c98a58e 100644
--- a/o2info/libo2info.c
+++ b/o2info/libo2info.c
@@ -414,7 +414,7 @@ static int do_fiemap(int fd, int flags, struct o2info_fiemap *ofp)
 	uint32_t num_extents = 0, extents_got = 0, i;
 
 	uint32_t prev_start = 0, prev_len = 0;
-	uint32_t start = 0, len = 0, phy_pos = 0;
+	uint32_t start = 0, len = 0;
 
 	if (ofp->clustersize)
 		cluster_shift = ul_log2(ofp->clustersize);
@@ -456,7 +456,6 @@ static int do_fiemap(int fd, int flags, struct o2info_fiemap *ofp)
 
 			start = fm_ext[i].fe_logical >> cluster_shift;
 			len = fm_ext[i].fe_length >> cluster_shift;
-			phy_pos = fm_ext[i].fe_physical >> blk_shift;
 
 			if (fiemap->fm_flags & FIEMAP_FLAG_XATTR) {
 				ofp->xattr += len;
diff --git a/o2info/o2info.c b/o2info/o2info.c
index ef9468c..e64564a 100644
--- a/o2info/o2info.c
+++ b/o2info/o2info.c
@@ -376,7 +376,6 @@ static errcode_t parse_options(int argc, char *argv[], char **device_or_file)
 	int c, lopt_idx = 0;
 	errcode_t err;
 	struct option *long_options = NULL;
-	char error[PATH_MAX];
 	char *optstring = NULL;
 	struct o2info_option *opt;
 
@@ -385,7 +384,6 @@ static errcode_t parse_options(int argc, char *argv[], char **device_or_file)
 		goto out;
 
 	opterr = 0;
-	error[0] = '\0';
 	while ((c = getopt_long(argc, argv, optstring,
 				long_options, &lopt_idx)) != EOF) {
 		opt = NULL;
diff --git a/o2info/utils.c b/o2info/utils.c
index 90c7567..74a4266 100644
--- a/o2info/utils.c
+++ b/o2info/utils.c
@@ -437,7 +437,7 @@ bail:
 	if (s_nsec)
 		free(s_nsec);
 
-	return 0;
+	return ret;
 }
 
 int o2info_get_human_time(char **htime, struct timespec t)
diff --git a/ocfs2_hb_ctl/ocfs2_hb_ctl.c b/ocfs2_hb_ctl/ocfs2_hb_ctl.c
index 3fe45ed..e4daa92 100644
--- a/ocfs2_hb_ctl/ocfs2_hb_ctl.c
+++ b/ocfs2_hb_ctl/ocfs2_hb_ctl.c
@@ -258,7 +258,7 @@ static errcode_t scan_devices(errcode_t (*func)(const char *,
 			      struct hb_ctl_options *hbo)
 {
 	errcode_t err = 0;
-	int rc, major, minor;
+	int major, minor;
 	FILE *f;
 	char *buffer, *name;
 
@@ -276,7 +276,7 @@ static errcode_t scan_devices(errcode_t (*func)(const char *,
 	f = fopen("/proc/partitions", "r");
 	if (!f)
 	{
-		rc = -errno;
+		err = -errno;
 		goto out_free;
 	}
 
diff --git a/tunefs.ocfs2/ocfs2ne.c b/tunefs.ocfs2/ocfs2ne.c
index df4beb9..38afbf6 100644
--- a/tunefs.ocfs2/ocfs2ne.c
+++ b/tunefs.ocfs2/ocfs2ne.c
@@ -880,7 +880,6 @@ static errcode_t parse_options(int argc, char *argv[], char **device)
 	int c;
 	errcode_t err;
 	struct option *long_options = NULL;
-	char error[PATH_MAX];
 	char *optstring = NULL;
 	struct tunefs_option *opt;
 
@@ -889,7 +888,6 @@ static errcode_t parse_options(int argc, char *argv[], char **device)
 		goto out;
 
 	opterr = 0;
-	error[0] = '\0';
 	while ((c = getopt_long(argc, argv, optstring,
 				long_options, NULL)) != EOF) {
 		opt = NULL;
-- 
1.7.7.6




More information about the Ocfs2-tools-devel mailing list