Fix miscellaneous gcc -Wall warnings

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
bitmap-optimize
Theodore Ts'o 2008-03-17 23:17:13 -04:00
parent a7c9cb7d0d
commit 2d328bb76d
20 changed files with 62 additions and 49 deletions

View File

@ -39,7 +39,7 @@ extern char *optarg;
extern ss_request_table debug_cmds;
ss_request_table *extra_cmds;
char *debug_prog_name;
const char *debug_prog_name;
ext2_filsys current_fs = NULL;
ext2_ino_t root, cwd;

View File

@ -366,7 +366,7 @@ static void dump_journal(char *cmdname, FILE *out_file,
fprintf(out_file, "\tuuid=%s\n", jsb_buffer);
fprintf(out_file, "\tblocksize=%d\n", blocksize);
fprintf(out_file, "\tjournal data size %lu\n",
sb->s_blocks_count);
(unsigned long) sb->s_blocks_count);
}
}

View File

@ -121,7 +121,7 @@ ext2_ino_t string_to_inode(char *str)
retval = ext2fs_namei(current_fs, root, cwd, str, &ino);
if (retval) {
com_err(str, retval, "");
com_err(str, retval, 0);
return 0;
}
return ino;

View File

@ -802,7 +802,6 @@ int check_backup_super_block(e2fsck_t ctx)
{
ext2_filsys fs = ctx->fs;
ext2_filsys tfs = 0;
io_manager io_ptr;
errcode_t retval;
dgrp_t g;
blk_t sb;

View File

@ -364,6 +364,7 @@ errcode_t ext2fs_block_iterate2(ext2_filsys fs,
e2_blkcnt_t blockcnt;
blk_t blk;
int op = EXT2_EXTENT_ROOT;
unsigned int j;
if (!(flags & BLOCK_FLAG_READ_ONLY))
return EXT2_ET_EXTENT_NOT_SUPPORTED;
@ -396,9 +397,9 @@ errcode_t ext2fs_block_iterate2(ext2_filsys fs,
extent_errout);
continue;
}
for (blockcnt = extent.e_lblk, i = 0;
i < extent.e_len;
blk++, blockcnt++, i++) {
for (blockcnt = extent.e_lblk, j = 0;
j < extent.e_len;
blk++, blockcnt++, j++) {
ret |= (*ctx.func)(fs, &blk,
blockcnt,
0, 0, priv_data);

View File

@ -158,7 +158,7 @@ errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode,
if (inode->i_flags & EXT4_EXTENTS_FL) {
struct ext2fs_extent extent;
int offset;
unsigned int offset;
if (bmap_flags & BMAP_SET) {
retval = EXT2_ET_EXTENT_NOT_SUPPORTED;

View File

@ -203,13 +203,16 @@ static errcode_t write_backup_super(ext2_filsys fs, dgrp_t group,
errcode_t ext2fs_flush(ext2_filsys fs)
{
dgrp_t i,j;
dgrp_t i;
errcode_t retval;
unsigned long fs_state;
__u32 feature_incompat;
struct ext2_super_block *super_shadow = 0;
struct ext2_group_desc *group_shadow = 0;
#ifdef WORDS_BIGENDIAN
struct ext2_group_desc *s, *t;
dgrp_t j;
#endif
char *group_ptr;
int old_desc_blocks;

View File

@ -263,8 +263,6 @@ int ext2fs_dblist_count(ext2_dblist dblist)
errcode_t ext2fs_dblist_get_last(ext2_dblist dblist,
struct ext2_db_entry **entry)
{
errcode_t retval;
EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST);
if (dblist->count == 0)

View File

@ -803,6 +803,7 @@ extern errcode_t ext2fs_adjust_ea_refcount(ext2_filsys fs, blk_t blk,
extern errcode_t ext2fs_extent_header_verify(void *ptr, int size);
extern errcode_t ext2fs_extent_open(ext2_filsys fs, ext2_ino_t ino,
ext2_extent_handle_t *handle);
extern void ext2fs_extent_free(ext2_extent_handle_t handle);
extern errcode_t ext2fs_extent_get(ext2_extent_handle_t handle,
int flags, struct ext2fs_extent *extent);
extern errcode_t ext2fs_extent_replace(ext2_extent_handle_t handle, int flags,

View File

@ -151,7 +151,6 @@ errcode_t ext2fs_extent_header_verify(void *ptr, int size)
/*
* Begin functions to handle an inode's extent information
*/
extern void ext2fs_extent_free(ext2_extent_handle_t handle)
{
int i;
@ -178,7 +177,6 @@ extern errcode_t ext2fs_extent_open(ext2_filsys fs, ext2_ino_t ino,
errcode_t retval;
int isize = EXT2_INODE_SIZE(fs->super);
struct ext3_extent_header *eh;
struct ext3_extent_idx *ix;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
@ -204,7 +202,7 @@ extern errcode_t ext2fs_extent_open(ext2_filsys fs, ext2_ino_t ino,
if (!(handle->inode->i_flags & EXT4_EXTENTS_FL))
return EXT2_ET_INODE_NOT_EXTENT;
eh = (struct ext3_extent_header *) &handle->inode->i_block;
eh = (struct ext3_extent_header *) &handle->inode->i_block[0];
retval = ext2fs_extent_header_verify(eh, sizeof(handle->inode->i_block));
if (retval)
@ -498,7 +496,6 @@ retry:
static errcode_t update_path(ext2_extent_handle_t handle)
{
struct extent_path *path;
blk64_t blk;
errcode_t retval;
struct ext3_extent_idx *ix;
@ -517,6 +514,7 @@ static errcode_t update_path(ext2_extent_handle_t handle)
return retval;
}
#if 0
errcode_t ext2fs_extent_save_path(ext2_extent_handle_t handle,
ext2_extent_path_t *ret_path)
{
@ -553,11 +551,12 @@ errcode_t ext2fs_extent_free_path(ext2_extent_path_t path)
ext2fs_free_mem(&path);
return 0;
}
#endif
static errcode_t extent_goto(ext2_extent_handle_t handle,
int leaf_level, blk64_t blk)
{
struct ext2fs_extent extent, next;
struct ext2fs_extent extent;
errcode_t retval;
retval = ext2fs_extent_get(handle, EXT2_EXTENT_ROOT, &extent);
@ -618,7 +617,8 @@ errcode_t ext2fs_extent_goto(ext2_extent_handle_t handle,
return extent_goto(handle, 0, blk);
}
errcode_t ext2fs_extent_replace(ext2_extent_handle_t handle, int flags,
errcode_t ext2fs_extent_replace(ext2_extent_handle_t handle,
int flags EXT2FS_ATTR((unused)),
struct ext2fs_extent *extent)
{
struct extent_path *path;
@ -713,7 +713,8 @@ errout:
return retval;
}
errcode_t ext2fs_extent_delete(ext2_extent_handle_t handle, int flags)
errcode_t ext2fs_extent_delete(ext2_extent_handle_t handle,
int flags EXT2FS_ATTR((unused)))
{
struct extent_path *path;
char *cp;
@ -759,8 +760,6 @@ errcode_t ext2fs_extent_get_info(ext2_extent_handle_t handle,
struct ext2_extent_info *info)
{
struct extent_path *path;
struct ext3_extent_idx *ix;
struct ext3_extent *ex;
EXT2_CHECK_MAGIC(handle, EXT2_ET_MAGIC_EXTENT_HANDLE);
@ -796,7 +795,7 @@ errcode_t ext2fs_extent_get_info(ext2_extent_handle_t handle,
/*
* Hook in new commands into debugfs
*/
char *debug_prog_name = "tst_extents";
const char *debug_prog_name = "tst_extents";
extern ss_request_table extent_cmds;
ss_request_table *extra_cmds = &extent_cmds;

View File

@ -22,9 +22,11 @@
errcode_t ext2fs_read_ind_block(ext2_filsys fs, blk_t blk, void *buf)
{
errcode_t retval;
#ifdef WORDS_BIGENDIAN
blk_t *block_nr;
int i;
int limit = fs->blocksize >> 2;
#endif
if ((fs->flags & EXT2_FLAG_IMAGE_FILE) &&
(fs->io != fs->image_io))
@ -44,9 +46,11 @@ errcode_t ext2fs_read_ind_block(ext2_filsys fs, blk_t blk, void *buf)
errcode_t ext2fs_write_ind_block(ext2_filsys fs, blk_t blk, void *buf)
{
#ifdef WORDS_BIGENDIAN
blk_t *block_nr;
int i;
int limit = fs->blocksize >> 2;
#endif
if (fs->flags & EXT2_FLAG_IMAGE_FILE)
return 0;

View File

@ -86,10 +86,13 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
errcode_t retval;
unsigned long i;
__u32 features;
int j, groups_per_block, blocks_per_group, io_flags;
int groups_per_block, blocks_per_group, io_flags;
blk_t group_block, blk;
char *dest, *cp;
#ifdef WORDS_BIGENDIAN
struct ext2_group_desc *gdp;
int j;
#endif
EXT2_CHECK_MAGIC(manager, EXT2_ET_MAGIC_IO_MANAGER);

View File

@ -185,9 +185,9 @@ static int decode_arg (int * i, int argc, char ** argv)
return 1;
}
static int chattr_dir_proc (const char *, struct dirent *, void *);
static int chattr_dir_proc(const char *, struct dirent *, void *);
static int change_attributes (const char * name, int cmdline)
static int change_attributes(const char * name)
{
unsigned long flags;
STRUCT_STAT st;
@ -265,7 +265,7 @@ static int chattr_dir_proc (const char * dir_name, struct dirent * de,
return -1;
}
sprintf(path, "%s/%s", dir_name, de->d_name);
ret = change_attributes(path, 0);
ret = change_attributes(path);
free(path);
}
return ret;
@ -314,7 +314,7 @@ int main (int argc, char ** argv)
fprintf (stderr, "chattr %s (%s)\n",
E2FSPROGS_VERSION, E2FSPROGS_DATE);
for (j = i; j < argc; j++) {
err = change_attributes (argv[j], 1);
err = change_attributes (argv[j]);
if (err)
retval = 1;
}

View File

@ -336,9 +336,9 @@ static void print_journal_information(ext2_filsys fs)
static void parse_extended_opts(const char *opts, blk_t *superblock,
int *blocksize)
{
char *buf, *token, *next, *p, *arg, *badopt = "";
char *buf, *token, *next, *p, *arg, *badopt = 0;
int len;
int usage = 0;
int do_usage = 0;
len = strlen(opts);
buf = malloc(len+1);
@ -363,7 +363,7 @@ static void parse_extended_opts(const char *opts, blk_t *superblock,
if (strcmp(token, "superblock") == 0 ||
strcmp(token, "sb") == 0) {
if (!arg) {
usage++;
do_usage++;
badopt = token;
continue;
}
@ -372,13 +372,13 @@ static void parse_extended_opts(const char *opts, blk_t *superblock,
fprintf(stderr,
_("Invalid superblock parameter: %s\n"),
arg);
usage++;
do_usage++;
continue;
}
} else if (strcmp(token, "blocksize") == 0 ||
strcmp(token, "bs") == 0) {
if (!arg) {
usage++;
do_usage++;
badopt = token;
continue;
}
@ -387,15 +387,15 @@ static void parse_extended_opts(const char *opts, blk_t *superblock,
fprintf(stderr,
_("Invalid blocksize parameter: %s\n"),
arg);
usage++;
do_usage++;
continue;
}
} else {
usage++;
do_usage++;
badopt = token;
}
}
if (usage) {
if (do_usage) {
fprintf(stderr, _("\nBad extended option(s) specified: %s\n\n"
"Extended options are separated by commas, "
"and may take an argument which\n"
@ -403,7 +403,7 @@ static void parse_extended_opts(const char *opts, blk_t *superblock,
"Valid extended options are:\n"
"\tsuperblock=<superblock number>\n"
"\tblocksize=<blocksize>\n"),
badopt);
badopt ? badopt : "");
free(buf);
exit(1);
}
@ -415,7 +415,7 @@ int main (int argc, char ** argv)
errcode_t retval;
ext2_filsys fs;
int print_badblocks = 0;
int use_superblock = 0;
blk_t use_superblock = 0;
int use_blocksize = 0;
int image_dump = 0;
int force = 0;

View File

@ -800,7 +800,7 @@ static void compile_fs_type(char *fs_type, struct fs_type_compile *cmp)
* This function returns true if a particular option appears in a
* comma-delimited options list
*/
static int opt_in_list(char *opt, char *optlist)
static int opt_in_list(const char *opt, char *optlist)
{
char *list, *s;

View File

@ -68,3 +68,6 @@ struct fsck_instance {
extern char *base_device(const char *device);
extern const char *identify_fs(const char *fs_name, const char *fs_types);
/* ismounted.h */
extern int is_mounted(const char *file);

View File

@ -28,6 +28,9 @@
#endif
#include <string.h>
#include <sys/stat.h>
#include <ctype.h>
#include "fsck.h"
/*
* ext2fs_check_if_mounted flags
@ -80,7 +83,6 @@ static errcode_t check_mntent_file(const char *mtab_file, const char *file,
ino_t file_ino=0;
FILE *f;
char buf[1024], *device = 0, *mnt_dir = 0, *cp;
int fd;
*mount_flags = 0;
if ((f = fopen(mtab_file, "r")) == NULL)

View File

@ -513,11 +513,11 @@ static void create_root_dir(ext2_filsys fs)
static void create_lost_and_found(ext2_filsys fs)
{
unsigned int lpf_size = 0;
errcode_t retval;
ext2_ino_t ino;
const char *name = "lost+found";
int i;
int lpf_size = 0;
fs->umask = 077;
retval = ext2fs_mkdir(fs, EXT2_ROOT_INO, 0, name);
@ -757,7 +757,7 @@ static int set_os(struct ext2_super_block *sb, char *os)
static void parse_extended_opts(struct ext2_super_block *param,
const char *opts)
{
char *buf, *token, *next, *p, *arg, *badopt = "";
char *buf, *token, *next, *p, *arg, *badopt = 0;
int len;
int r_usage = 0;
@ -884,7 +884,7 @@ static void parse_extended_opts(struct ext2_super_block *param,
"\tstripe-width=<RAID stride * data disks in blocks>\n"
"\tresize=<resize maximum size in blocks>\n\n"
"\ttest_fs\n"),
badopt);
badopt ? badopt : "");
free(buf);
exit(1);
}

View File

@ -315,7 +315,6 @@ static void update_mntopts(ext2_filsys fs, char *mntopts)
static void update_feature_set(ext2_filsys fs, char *features)
{
struct ext2_super_block *sb= fs->super;
__u32 old_compat, old_incompat, old_ro_compat;
__u32 old_features[3];
int type_err;
unsigned int mask_err;

View File

@ -206,12 +206,12 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
int debug, int timeout, int quiet)
{
struct sockaddr_un my_addr, from_addr;
unsigned char reply_buf[1024], *cp;
struct flock fl;
socklen_t fromlen;
int32_t reply_len = 0;
uuid_t uu;
mode_t save_umask;
char reply_buf[1024], *cp;
char op, str[37];
int i, s, ns, len, num;
int fd_pidfile, ret;
@ -329,12 +329,12 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
switch(op) {
case UUIDD_OP_GETPID:
sprintf((char *) reply_buf, "%d", getpid());
reply_len = strlen((char *) reply_buf)+1;
sprintf(reply_buf, "%d", getpid());
reply_len = strlen(reply_buf)+1;
break;
case UUIDD_OP_GET_MAXOP:
sprintf((char *) reply_buf, "%d", UUIDD_MAX_OP);
reply_len = strlen((char *) reply_buf)+1;
sprintf(reply_buf, "%d", UUIDD_MAX_OP);
reply_len = strlen(reply_buf)+1;
break;
case UUIDD_OP_TIME_UUID:
num = 1;
@ -375,12 +375,13 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
num = 1000;
if (num*16 > (int) (sizeof(reply_buf)-sizeof(num)))
num = (sizeof(reply_buf)-sizeof(num)) / 16;
uuid__generate_random(reply_buf+sizeof(num), &num);
uuid__generate_random((unsigned char *) reply_buf +
sizeof(num), &num);
if (debug) {
printf(_("Generated %d UUID's:\n"), num);
for (i=0, cp=reply_buf+sizeof(num);
i < num; i++, cp+=16) {
uuid_unparse(cp, str);
uuid_unparse((unsigned char *)cp, str);
printf("\t%s\n", str);
}
}