misc: clean up compiler warnings
Fix several types of compiler warnings (unused variables/labels),
uninitialized variables, etc that are hit with gcc -Wall.
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index a035411..889c771 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -1414,7 +1414,8 @@
if (align == 0)
align = 8;
- if (retval = posix_memalign((void **) ptr, align, size)) {
+ retval = posix_memalign((void **) ptr, align, size);
+ if (retval) {
if (retval == ENOMEM)
return EXT2_ET_NO_MEMORY;
return retval;
diff --git a/lib/ext2fs/fileio.c b/lib/ext2fs/fileio.c
index 4b62c2d..d62ef35 100644
--- a/lib/ext2fs/fileio.c
+++ b/lib/ext2fs/fileio.c
@@ -377,7 +377,7 @@
truncate_block = ((size + file->fs->blocksize - 1) >>
EXT2_BLOCK_SIZE_BITS(file->fs->super)) + 1;
old_size = file->inode.i_size +
- ((blk64_t) file->inode.i_size_high) << 32;
+ ((blk64_t)file->inode.i_size_high << 32);
old_truncate = ((old_size + file->fs->blocksize - 1) >>
EXT2_BLOCK_SIZE_BITS(file->fs->super)) + 1;
diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c
index 2ef3f27..283daee 100644
--- a/lib/ext2fs/openfs.c
+++ b/lib/ext2fs/openfs.c
@@ -365,7 +365,6 @@
*/
if (superblock > 1 && EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
- struct ext2_group_desc *gd;
dgrp_t group;
for (group = 0; group < fs->group_desc_count; group++) {
diff --git a/lib/ext2fs/progress.c b/lib/ext2fs/progress.c
index ec4f553..1b9bf9c 100644
--- a/lib/ext2fs/progress.c
+++ b/lib/ext2fs/progress.c
@@ -77,8 +77,6 @@
struct ext2fs_numeric_progress_struct * progress,
const char *message)
{
- unsigned int len;
-
if (!(fs->flags & EXT2_FLAG_PRINT_PROGRESS))
return;
fprintf(stdout, "%.*s", (2*progress->log_max)+1, spaces);
diff --git a/lib/ext2fs/res_gdt.c b/lib/ext2fs/res_gdt.c
index bf10995..f3b3969 100644
--- a/lib/ext2fs/res_gdt.c
+++ b/lib/ext2fs/res_gdt.c
@@ -75,7 +75,7 @@
retval = ext2fs_get_array(2, fs->blocksize, &dindir_buf);
if (retval)
- goto out_free;
+ return retval;
gdt_buf = (__u32 *)((char *)dindir_buf + fs->blocksize);
retval = ext2fs_read_inode(fs, EXT2_RESIZE_INO, &inode);
diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c
index 82e0fe4..6e480b7 100644
--- a/lib/ext2fs/unix_io.c
+++ b/lib/ext2fs/unix_io.c
@@ -17,7 +17,9 @@
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif
#include <stdio.h>
#include <string.h>