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>
bitmap-optimize
Andreas Dilger 2011-06-11 10:58:25 -04:00 committed by Theodore Ts'o
parent 44fe08f1fa
commit cf5301d7f2
21 changed files with 35 additions and 30 deletions

View File

@ -855,7 +855,7 @@ void do_stat(int argc, char *argv[])
return;
}
void do_dump_extents(int argc, char *argv[])
void do_dump_extents(int argc, char **argv)
{
struct ext2_inode inode;
ext2_ino_t ino;
@ -876,8 +876,7 @@ void do_dump_extents(int argc, char *argv[])
}
}
if (argc != optind+1) {
print_usage:
if (argc != optind + 1) {
com_err(0, 0, "Usage: dump_extents [-n] [-l] file");
return;
}

View File

@ -103,6 +103,7 @@ extern void do_unlink(int argc, char **argv);
extern void do_find_free_block(int argc, char **argv);
extern void do_find_free_inode(int argc, char **argv);
extern void do_stat(int argc, char **argv);
extern void do_dump_extents(int argc, char **argv);
extern void do_chroot(int argc, char **argv);
extern void do_clri(int argc, char **argv);

View File

@ -5,7 +5,9 @@
* under the terms of the GNU Public License.
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE /* for O_LARGEFILE */
#endif
#include <stdio.h>
#include <unistd.h>

View File

@ -263,7 +263,6 @@ static _INLINE_ void expand_inode_expression(ext2_filsys fs, char ch,
{
struct ext2_inode *inode;
struct ext2_inode_large *large_inode;
time_t t;
if (!ctx || !ctx->inode)
goto no_inode;

View File

@ -404,7 +404,7 @@ static void check_is_really_dir(e2fsck_t ctx, struct problem_context *pctx,
struct ext2_dir_entry *dirent;
const char *old_op;
errcode_t retval;
blk64_t blk, first_dir_blk;
blk64_t blk;
unsigned int i, rec_len, not_device = 0;
int extent_fs;
@ -436,7 +436,8 @@ static void check_is_really_dir(e2fsck_t ctx, struct problem_context *pctx,
* with it.
*/
extent_fs = (ctx->fs->super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS);
extent_fs = (ctx->fs->super->s_feature_incompat &
EXT3_FEATURE_INCOMPAT_EXTENTS);
if (extent_fs && (inode->i_flags & EXT4_EXTENTS_FL)) {
/* extent mapped */
if (ext2fs_bmap2(ctx->fs, pctx->ino, inode, 0, 0, 0, 0,

View File

@ -404,7 +404,8 @@ static int check_dotdot(e2fsck_t ctx,
struct ext2_dir_entry *dirent,
ext2_ino_t ino, struct problem_context *pctx)
{
int rec_len, problem = 0;
int problem = 0;
unsigned int rec_len;
if (!dirent->inode)
problem = PR_2_MISSING_DOT_DOT;

View File

@ -77,7 +77,6 @@ static void e2fsck_discard_blocks(e2fsck_t ctx, io_manager manager,
blk64_t start, blk64_t count)
{
ext2_filsys fs = ctx->fs;
int ret = 0;
/*
* If the filesystem has changed it means that there was an corruption

View File

@ -430,12 +430,13 @@ static errcode_t copy_dir_entries(e2fsck_t ctx,
return retval;
dirent = (struct ext2_dir_entry *) block_start;
prev_rec_len = 0;
rec_len = 0;
left = fs->blocksize;
slack = fd->compress ? 12 :
(fs->blocksize * ctx->htree_slack_percentage)/100;
if (slack < 12)
slack = 12;
for (i=0; i < fd->num_array; i++) {
for (i = 0; i < fd->num_array; i++) {
ent = fd->harray + i;
if (ent->dir->inode == 0)
continue;

View File

@ -212,6 +212,7 @@ exit 0
%{_includedir}/blkid
%{_includedir}/e2p
%{_includedir}/et
%{_includedir}/com_err.h
%{_includedir}/ext2fs
%{_includedir}/ss
%{_includedir}/uuid

View File

@ -248,7 +248,7 @@ static int linux_version_code()
{
#ifdef __linux__
struct utsname ut;
static version_code = -1;
static int version_code = -1;
int major, minor, rev;
char *endptr;
const char *cp;
@ -1175,7 +1175,7 @@ static int probe_hfs(struct blkid_probe *probe __BLKID_ATTR((unused)),
sprintf(uuid_str, "%016llX", uuid);
blkid_set_tag(probe->dev, "UUID", uuid_str, 0);
}
blkid_set_tag(probe->dev, "LABEL", hfs->label, hfs->label_len);
blkid_set_tag(probe->dev, "LABEL", (char *)hfs->label, hfs->label_len);
return 0;
}
@ -1296,7 +1296,8 @@ static int probe_hfsplus(struct blkid_probe *probe,
return 0;
label_len = blkid_be16(key->unicode_len) * 2;
unicode_16be_to_utf8(label, sizeof(label), key->unicode, label_len);
unicode_16be_to_utf8((unsigned char *)label, sizeof(label),
key->unicode, label_len);
blkid_set_tag(probe->dev, "LABEL", label, 0);
return 0;
}

View File

@ -383,7 +383,7 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
tm = sb->s_first_error_time;
fprintf(f, "First error time: %s", ctime(&tm));
memset(buf, 0, sizeof(buf));
strncpy(buf, sb->s_first_error_func,
strncpy(buf, (char *)sb->s_first_error_func,
sizeof(sb->s_first_error_func));
fprintf(f, "First error function: %s\n", buf);
fprintf(f, "First error line #: %u\n",
@ -397,7 +397,7 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
tm = sb->s_last_error_time;
fprintf(f, "Last error time: %s", ctime(&tm));
memset(buf, 0, sizeof(buf));
strncpy(buf, sb->s_last_error_func,
strncpy(buf, (char *)sb->s_last_error_func,
sizeof(sb->s_last_error_func));
fprintf(f, "Last error function: %s\n", buf);
fprintf(f, "Last error line #: %u\n",

View File

@ -1414,7 +1414,8 @@ _INLINE_ errcode_t ext2fs_get_memalign(unsigned long size,
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;

View File

@ -377,7 +377,7 @@ errcode_t ext2fs_file_set_size2(ext2_file_t file, ext2_off64_t size)
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;

View File

@ -365,7 +365,6 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
*/
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++) {

View File

@ -77,8 +77,6 @@ void ext2fs_numeric_progress_close(ext2_filsys fs,
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);

View File

@ -75,7 +75,7 @@ errcode_t ext2fs_create_resize_inode(ext2_filsys fs)
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);

View File

@ -17,7 +17,9 @@
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <stdio.h>
#include <string.h>

View File

@ -29,7 +29,9 @@
* list. (Work done by David Beattie)
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE /* for O_DIRECT */
#endif
#ifndef O_LARGEFILE
#define O_LARGEFILE 0

View File

@ -144,7 +144,7 @@ errcode_t get_chunk_info(ext2_filsys fs, struct chunk_info *info)
unsigned long total_chunks;
char *unitp = "KMGTPEZY";
int units = 10;
unsigned long start = 0, end, cum;
unsigned long start = 0, end;
int i, retval = 0;
scan_block_bitmap(fs, info);
@ -218,7 +218,7 @@ void close_device(char *device_name, ext2_filsys fs)
void collect_info(ext2_filsys fs, struct chunk_info *chunk_info)
{
unsigned int retval = 0, i, free_blks;
unsigned int retval = 0;
printf("Device: %s\n", fs->device_name);
printf("Blocksize: %u bytes\n", fs->blocksize);

View File

@ -29,12 +29,11 @@ unsigned char blksize_key[] = "filesystem BLKSIZE";
char *prg_name;
static void usage(char *prg_name)
static void usage(void)
{
fprintf(stderr,
_("Usage: %s <transaction file> <filesystem>\n"), prg_name);
exit(1);
}
static int check_filesystem(TDB_CONTEXT *tdb, io_channel channel)
@ -145,12 +144,12 @@ int main(int argc, char *argv[])
force = 1;
break;
default:
usage(prg_name);
usage();
}
}
if (argc != optind+2)
usage(prg_name);
if (argc != optind + 2)
usage();
tdb_file = argv[optind];
device_name = argv[optind+1];

View File

@ -348,7 +348,6 @@ static void update_feature_set(ext2_filsys fs, char *features)
{
struct ext2_super_block *sb = fs->super;
struct ext2_group_desc *gd;
errcode_t retval;
__u32 old_features[3];
int i, type_err;
unsigned int mask_err;
@ -992,7 +991,7 @@ static void parse_extended_opts(ext2_filsys fs, const char *opts)
"Extended mount options too long\n");
continue;
}
strcpy(fs->super->s_mount_opts, arg);
strcpy((char *)fs->super->s_mount_opts, arg);
ext2fs_mark_super_dirty(fs);
} else
r_usage++;
@ -1097,7 +1096,7 @@ static int move_block(ext2_filsys fs, ext2fs_block_bitmap bmap)
{
char *buf;
dgrp_t group;
dgrp_t group = 0;
errcode_t retval;
int meta_data = 0;
blk64_t blk, new_blk, goal;