diff options
author | Theodore Ts'o <tytso@mit.edu> | 2003-12-07 01:28:50 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2003-12-07 01:28:50 -0500 |
commit | 544349270e4c74a6feb971123884a8cf5052a7ee (patch) | |
tree | 7c3c483148953f1cd5eadc9cf5eb6f7faabc31c5 /lib | |
parent | 3de085dd4109e6a7049dd6b85abf0313167cab5b (diff) | |
download | e2fsprogs-544349270e4c74a6feb971123884a8cf5052a7ee.tar.gz |
Fix gcc -Wall nitpicks
Diffstat (limited to 'lib')
35 files changed, 245 insertions, 160 deletions
diff --git a/lib/blkid/ChangeLog b/lib/blkid/ChangeLog index eebbf15d..f6d3bb1e 100644 --- a/lib/blkid/ChangeLog +++ b/lib/blkid/ChangeLog @@ -1,3 +1,7 @@ +2003-12-07 Theodore Ts'o <tytso@mit.edu> + + * probe.c, read.c, blkidP.h: Fix gcc -Wall nitpicks. + 2003-07-25 Theodore Ts'o <tytso@mit.edu> * Release of E2fsprogs 1.34 diff --git a/lib/blkid/blkidP.h b/lib/blkid/blkidP.h index 1ab29c5b..7d90b5e5 100644 --- a/lib/blkid/blkidP.h +++ b/lib/blkid/blkidP.h @@ -20,6 +20,13 @@ #include <blkid/list.h> +#ifdef __GNUC__ +#define __BLKID_ATTR(x) __attribute__(x) +#else +#define __BLKID_ATTR(x) +#endif + + /* * This describes the attributes of a specific device. * We can traverse all of the tags by bid_tags (linking to the tag bit_names). diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c index 505400c5..5b74c31f 100644 --- a/lib/blkid/probe.c +++ b/lib/blkid/probe.c @@ -78,7 +78,9 @@ static void set_uuid(blkid_dev dev, uuid_t uuid) } } -static int probe_ext2(int fd, blkid_cache cache, blkid_dev dev, +static int probe_ext2(int fd __BLKID_ATTR((unused)), + blkid_cache cache __BLKID_ATTR((unused)), + blkid_dev dev, struct blkid_magic *id, unsigned char *buf) { struct ext2_super_block *es; @@ -111,8 +113,11 @@ static int probe_ext2(int fd, blkid_cache cache, blkid_dev dev, return 0; } -static int probe_jbd(int fd, blkid_cache cache, blkid_dev dev, - struct blkid_magic *id, unsigned char *buf) +static int probe_jbd(int fd __BLKID_ATTR((unused)), + blkid_cache cache __BLKID_ATTR((unused)), + blkid_dev dev, + struct blkid_magic *id __BLKID_ATTR((unused)), + unsigned char *buf) { struct ext2_super_block *es = (struct ext2_super_block *) buf; @@ -123,8 +128,11 @@ static int probe_jbd(int fd, blkid_cache cache, blkid_dev dev, return (probe_ext2(fd, cache, dev, 0, buf)); } -static int probe_vfat(int fd, blkid_cache cache, blkid_dev dev, - struct blkid_magic *id, unsigned char *buf) +static int probe_vfat(int fd __BLKID_ATTR((unused)), + blkid_cache cache __BLKID_ATTR((unused)), + blkid_dev dev, + struct blkid_magic *id __BLKID_ATTR((unused)), + unsigned char *buf) { struct vfat_super_block *vs; char serno[10]; @@ -150,8 +158,11 @@ static int probe_vfat(int fd, blkid_cache cache, blkid_dev dev, return 0; } -static int probe_msdos(int fd, blkid_cache cache, blkid_dev dev, - struct blkid_magic *id, unsigned char *buf) +static int probe_msdos(int fd __BLKID_ATTR((unused)), + blkid_cache cache __BLKID_ATTR((unused)), + blkid_dev dev, + struct blkid_magic *id __BLKID_ATTR((unused)), + unsigned char *buf) { struct msdos_super_block *ms = (struct msdos_super_block *) buf; char serno[10]; @@ -175,8 +186,11 @@ static int probe_msdos(int fd, blkid_cache cache, blkid_dev dev, return 0; } -static int probe_xfs(int fd, blkid_cache cache, blkid_dev dev, - struct blkid_magic *id, unsigned char *buf) +static int probe_xfs(int fd __BLKID_ATTR((unused)), + blkid_cache cache __BLKID_ATTR((unused)), + blkid_dev dev, + struct blkid_magic *id __BLKID_ATTR((unused)), + unsigned char *buf) { struct xfs_super_block *xs; const char *label = 0; @@ -190,7 +204,9 @@ static int probe_xfs(int fd, blkid_cache cache, blkid_dev dev, return 0; } -static int probe_reiserfs(int fd, blkid_cache cache, blkid_dev dev, +static int probe_reiserfs(int fd __BLKID_ATTR((unused)), + blkid_cache cache __BLKID_ATTR((unused)), + blkid_dev dev, struct blkid_magic *id, unsigned char *buf) { struct reiserfs_super_block *rs = (struct reiserfs_super_block *) buf; @@ -215,8 +231,11 @@ static int probe_reiserfs(int fd, blkid_cache cache, blkid_dev dev, return 0; } -static int probe_jfs(int fd, blkid_cache cache, blkid_dev dev, - struct blkid_magic *id, unsigned char *buf) +static int probe_jfs(int fd __BLKID_ATTR((unused)), + blkid_cache cache __BLKID_ATTR((unused)), + blkid_dev dev, + struct blkid_magic *id __BLKID_ATTR((unused)), + unsigned char *buf) { struct jfs_super_block *js; const char *label = 0; @@ -230,8 +249,11 @@ static int probe_jfs(int fd, blkid_cache cache, blkid_dev dev, return 0; } -static int probe_romfs(int fd, blkid_cache cache, blkid_dev dev, - struct blkid_magic *id, unsigned char *buf) +static int probe_romfs(int fd __BLKID_ATTR((unused)), + blkid_cache cache __BLKID_ATTR((unused)), + blkid_dev dev, + struct blkid_magic *id __BLKID_ATTR((unused)), + unsigned char *buf) { struct romfs_super_block *ros; const char *label = 0; @@ -244,16 +266,18 @@ static int probe_romfs(int fd, blkid_cache cache, blkid_dev dev, return 0; } -static char +static const char *udf_magic[] = { "BEA01", "BOOT2", "CD001", "CDW02", "NSR02", "NSR03", "TEA01", 0 }; -static int probe_udf(int fd, blkid_cache cache, blkid_dev dev, - struct blkid_magic *id, unsigned char *buf) +static int probe_udf(int fd, blkid_cache cache __BLKID_ATTR((unused)), + blkid_dev dev __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), + unsigned char *buf __BLKID_ATTR((unused))) { int j, bs; struct iso_volume_descriptor isosb; - char **m; + const char ** m; /* determine the block size by scanning in 2K increments (block sizes larger than 2K will be null padded) */ diff --git a/lib/blkid/read.c b/lib/blkid/read.c index b07cf795..0a8e3f3c 100644 --- a/lib/blkid/read.c +++ b/lib/blkid/read.c @@ -403,10 +403,12 @@ void blkid_read_cache(blkid_cache cache) while (fgets(buf, sizeof(buf), file)) { blkid_dev dev; - - int end = strlen(buf) - 1; + unsigned int end; lineno++; + if (buf[0] == 0) + continue; + end = strlen(buf) - 1; /* Continue reading next line if it ends with a backslash */ while (buf[end] == '\\' && end < sizeof(buf) - 2 && fgets(buf + end, sizeof(buf) - end, file)) { diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 377f5941..586abc11 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,3 +1,13 @@ +2003-12-02 Theodore Ts'o <tytso@mit.edu> + + * alloc.c, bb_inode.c, bitops.c, block.c, check_desc.c, closefs.c, + dir_iterate.c, dirblock.c, expanddir.c, ext2fs.h, + get_pathname.c, icount.c, imager.c, initalize.c, inode.c, + lookup.c, openfs.c, read_bb.c, read_bb_file.c, + rw_bitmaps.c, unix_io.c, unlink.c, write_bb_file.c: Fix + gcc -Wall complaints. Mainly marking variables as being + unsued, and catching signed vs. unsigned comparisons. + 2003-09-03 Theodore Ts'o <tytso@mit.edu> * closefs.c (ext2fs_super_and_bgd_loc): New function which diff --git a/lib/ext2fs/alloc.c b/lib/ext2fs/alloc.c index 3356006f..7385123b 100644 --- a/lib/ext2fs/alloc.c +++ b/lib/ext2fs/alloc.c @@ -32,7 +32,8 @@ * * Should have a special policy for directories. */ -errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, int mode, +errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, + int mode EXT2FS_ATTR((unused)), ext2fs_inode_bitmap map, ext2_ino_t *ret) { ext2_ino_t dir_group = 0; diff --git a/lib/ext2fs/bb_inode.c b/lib/ext2fs/bb_inode.c index f601787d..dd8e7c31 100644 --- a/lib/ext2fs/bb_inode.c +++ b/lib/ext2fs/bb_inode.c @@ -151,7 +151,8 @@ cleanup: #endif static int clear_bad_block_proc(ext2_filsys fs, blk_t *block_nr, e2_blkcnt_t blockcnt, - blk_t ref_block, int ref_offset, + blk_t ref_block EXT2FS_ATTR((unused)), + int ref_offset EXT2FS_ATTR((unused)), void *priv_data) { struct set_badblock_record *rec = (struct set_badblock_record *) @@ -206,8 +207,10 @@ static int clear_bad_block_proc(ext2_filsys fs, blk_t *block_nr, #pragma argsused #endif static int set_bad_block_proc(ext2_filsys fs, blk_t *block_nr, - e2_blkcnt_t blockcnt, blk_t ref_block, - int ref_offset, void *priv_data) + e2_blkcnt_t blockcnt, + blk_t ref_block EXT2FS_ATTR((unused)), + int ref_offset EXT2FS_ATTR((unused)), + void *priv_data) { struct set_badblock_record *rec = (struct set_badblock_record *) priv_data; diff --git a/lib/ext2fs/bitops.c b/lib/ext2fs/bitops.c index e27c5a0f..886eb5ec 100644 --- a/lib/ext2fs/bitops.c +++ b/lib/ext2fs/bitops.c @@ -71,9 +71,9 @@ void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg, { #ifndef OMIT_COM_ERR if (description) - com_err(0, errcode, "#%u for %s", arg, description); + com_err(0, errcode, "#%lu for %s", arg, description); else - com_err(0, errcode, "#%u", arg); + com_err(0, errcode, "#%lu", arg); #endif } @@ -83,9 +83,9 @@ void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap, #ifndef OMIT_COM_ERR if (bitmap->description) com_err(0, bitmap->base_error_code+code, - "#%u for %s", arg, bitmap->description); + "#%lu for %s", arg, bitmap->description); else - com_err(0, bitmap->base_error_code + code, "#%u", arg); + com_err(0, bitmap->base_error_code + code, "#%lu", arg); #endif } diff --git a/lib/ext2fs/block.c b/lib/ext2fs/block.c index 338b9180..f64c0af3 100644 --- a/lib/ext2fs/block.c +++ b/lib/ext2fs/block.c @@ -467,7 +467,9 @@ struct xlate { #pragma argsused #endif static int xlate_func(ext2_filsys fs, blk_t *blocknr, e2_blkcnt_t blockcnt, - blk_t ref_block, int ref_offset, void *priv_data) + blk_t ref_block EXT2FS_ATTR((unused)), + int ref_offset EXT2FS_ATTR((unused)), + void *priv_data) { struct xlate *xl = (struct xlate *) priv_data; diff --git a/lib/ext2fs/check_desc.c b/lib/ext2fs/check_desc.c index 902c4b64..2a754c7f 100644 --- a/lib/ext2fs/check_desc.c +++ b/lib/ext2fs/check_desc.c @@ -31,7 +31,7 @@ */ errcode_t ext2fs_check_desc(ext2_filsys fs) { - int i; + dgrp_t i; blk_t block = fs->super->s_first_data_block; blk_t next; diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c index 56be2923..1256385b 100644 --- a/lib/ext2fs/closefs.c +++ b/lib/ext2fs/closefs.c @@ -53,7 +53,8 @@ int ext2fs_super_and_bgd_loc(ext2_filsys fs, int *ret_meta_bg) { blk_t group_block, super_blk = 0, old_desc_blk = 0, new_desc_blk = 0; - int numblocks, j, has_super, meta_bg_size, meta_bg; + unsigned int meta_bg, meta_bg_size; + int numblocks, has_super; int old_desc_blocks; group_block = fs->super->s_first_data_block + diff --git a/lib/ext2fs/dir_iterate.c b/lib/ext2fs/dir_iterate.c index 9a6ac915..003c0a3b 100644 --- a/lib/ext2fs/dir_iterate.c +++ b/lib/ext2fs/dir_iterate.c @@ -96,7 +96,8 @@ struct xlate { void *real_private; }; -static int xlate_func(ext2_ino_t dir, int entry, +static int xlate_func(ext2_ino_t dir EXT2FS_ATTR((unused)), + int entry EXT2FS_ATTR((unused)), struct ext2_dir_entry *dirent, int offset, int blocksize, char *buf, void *priv_data) { @@ -130,16 +131,16 @@ extern errcode_t ext2fs_dir_iterate(ext2_filsys fs, * Helper function which is private to this module. Used by * ext2fs_dir_iterate() and ext2fs_dblist_dir_iterate() */ -int ext2fs_process_dir_block(ext2_filsys fs, - blk_t *blocknr, - e2_blkcnt_t blockcnt, - blk_t ref_block, - int ref_offset, - void *priv_data) +int ext2fs_process_dir_block(ext2_filsys fs, + blk_t *blocknr, + e2_blkcnt_t blockcnt, + blk_t ref_block EXT2FS_ATTR((unused)), + int ref_offset EXT2FS_ATTR((unused)), + void *priv_data) { struct dir_context *ctx = (struct dir_context *) priv_data; - int offset = 0; - int next_real_entry = 0; + unsigned int offset = 0; + unsigned int next_real_entry = 0; int ret = 0; int changed = 0; int do_abort = 0; @@ -191,8 +192,9 @@ next: size = ((dirent->name_len & 0xFF) + 11) & ~3; if (dirent->rec_len != size) { - int final_offset = offset + dirent->rec_len; - + unsigned int final_offset; + + final_offset = offset + dirent->rec_len; offset += size; while (offset < final_offset && !ext2fs_validate_entry(ctx->buf, diff --git a/lib/ext2fs/dirblock.c b/lib/ext2fs/dirblock.c index 0cb07c72..ebfc72c5 100644 --- a/lib/ext2fs/dirblock.c +++ b/lib/ext2fs/dirblock.c @@ -20,7 +20,7 @@ #include "ext2fs.h" errcode_t ext2fs_read_dir_block2(ext2_filsys fs, blk_t block, - void *buf, int flags) + void *buf, int flags EXT2FS_ATTR((unused))) { errcode_t retval; char *p, *end; @@ -71,7 +71,7 @@ errcode_t ext2fs_read_dir_block(ext2_filsys fs, blk_t block, errcode_t ext2fs_write_dir_block2(ext2_filsys fs, blk_t block, - void *inbuf, int flags) + void *inbuf, int flags EXT2FS_ATTR((unused))) { #ifdef EXT2FS_ENABLE_SWAPFS int do_swap = 0; diff --git a/lib/ext2fs/expanddir.c b/lib/ext2fs/expanddir.c index 3c2c8037..10a5149c 100644 --- a/lib/ext2fs/expanddir.c +++ b/lib/ext2fs/expanddir.c @@ -24,12 +24,12 @@ struct expand_dir_struct { errcode_t err; }; -static int expand_dir_proc(ext2_filsys fs, - blk_t *blocknr, - e2_blkcnt_t blockcnt, - blk_t ref_block, - int ref_offset, - void *priv_data) +static int expand_dir_proc(ext2_filsys fs, + blk_t *blocknr, + e2_blkcnt_t blockcnt, + blk_t ref_block EXT2FS_ATTR((unused)), + int ref_offset EXT2FS_ATTR((unused)), + void *priv_data) { struct expand_dir_struct *es = (struct expand_dir_struct *) priv_data; blk_t new_blk; diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index d0bd2807..92f273eb 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -12,6 +12,12 @@ #ifndef _EXT2FS_EXT2FS_H #define _EXT2FS_EXT2FS_H +#ifdef __GNUC__ +#define EXT2FS_ATTR(x) __attribute__(x) +#else +#define EXT2FS_ATTR(x) +#endif + #ifdef __cplusplus extern "C" { #endif @@ -201,7 +207,7 @@ struct struct_ext2_filsys { int flags; char * device_name; struct ext2_super_block * super; - int blocksize; + unsigned int blocksize; int fragsize; dgrp_t group_desc_count; unsigned long desc_blocks; @@ -482,6 +488,7 @@ extern errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group, /* badblocks.c */ extern errcode_t ext2fs_u32_list_create(ext2_u32_list *ret, int size); extern errcode_t ext2fs_u32_list_add(ext2_u32_list bb, __u32 blk); +extern int ext2fs_u32_list_find(ext2_u32_list bb, __u32 blk); extern int ext2fs_u32_list_test(ext2_u32_list bb, blk_t blk); extern errcode_t ext2fs_u32_list_iterate_begin(ext2_u32_list bb, ext2_u32_iterate *ret); @@ -754,9 +761,11 @@ extern errcode_t ext2fs_initialize(const char *name, int flags, /* icount.c */ extern void ext2fs_free_icount(ext2_icount_t icount); -extern errcode_t ext2fs_create_icount2(ext2_filsys fs, int flags, int size, +extern errcode_t ext2fs_create_icount2(ext2_filsys fs, int flags, + unsigned int size, ext2_icount_t hint, ext2_icount_t *ret); -extern errcode_t ext2fs_create_icount(ext2_filsys fs, int flags, int size, +extern errcode_t ext2fs_create_icount(ext2_filsys fs, int flags, + unsigned int size, ext2_icount_t *ret); extern errcode_t ext2fs_icount_fetch(ext2_icount_t icount, ext2_ino_t ino, __u16 *ret); @@ -839,7 +848,7 @@ extern errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, /* openfs.c */ extern errcode_t ext2fs_open(const char *name, int flags, int superblock, - int block_size, io_manager manager, + unsigned int block_size, io_manager manager, ext2_filsys *ret_fs); extern blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block, dgrp_t i); @@ -968,7 +977,7 @@ _INLINE_ errcode_t ext2fs_free_mem(void *ptr) /* * Resize memory */ -_INLINE_ errcode_t ext2fs_resize_mem(unsigned long old_size, +_INLINE_ errcode_t ext2fs_resize_mem(unsigned long old_size EXT2FS_ATTR((unused)), unsigned long size, void *ptr) { void *p; diff --git a/lib/ext2fs/get_pathname.c b/lib/ext2fs/get_pathname.c index a8449c64..23f593f6 100644 --- a/lib/ext2fs/get_pathname.c +++ b/lib/ext2fs/get_pathname.c @@ -38,9 +38,9 @@ struct get_pathname_struct { #pragma argsused #endif static int get_pathname_proc(struct ext2_dir_entry *dirent, - int offset, - int blocksize, - char *buf, + int offset EXT2FS_ATTR((unused)), + int blocksize EXT2FS_ATTR((unused)), + char *buf EXT2FS_ATTR((unused)), void *priv_data) { struct get_pathname_struct *gp; diff --git a/lib/ext2fs/icount.c b/lib/ext2fs/icount.c index e08b3356..59977928 100644 --- a/lib/ext2fs/icount.c +++ b/lib/ext2fs/icount.c @@ -49,7 +49,7 @@ struct ext2_icount { ext2_ino_t count; ext2_ino_t size; ext2_ino_t num_inodes; - int cursor; + ext2_ino_t cursor; struct ext2_icount_el *list; }; @@ -68,13 +68,13 @@ void ext2fs_free_icount(ext2_icount_t icount) ext2fs_free_mem(&icount); } -errcode_t ext2fs_create_icount2(ext2_filsys fs, int flags, int size, +errcode_t ext2fs_create_icount2(ext2_filsys fs, int flags, unsigned int size, ext2_icount_t hint, ext2_icount_t *ret) { ext2_icount_t icount; errcode_t retval; size_t bytes; - int i; + ext2_ino_t i; if (hint) { EXT2_CHECK_MAGIC(hint, EXT2_ET_MAGIC_ICOUNT); @@ -148,7 +148,8 @@ errout: return(retval); } -errcode_t ext2fs_create_icount(ext2_filsys fs, int flags, int size, +errcode_t ext2fs_create_icount(ext2_filsys fs, int flags, + unsigned int size, ext2_icount_t *ret) { return ext2fs_create_icount2(fs, flags, size, 0, ret); @@ -273,7 +274,7 @@ static struct ext2_icount_el *get_icount_el(ext2_icount_t icount, errcode_t ext2fs_icount_validate(ext2_icount_t icount, FILE *out) { errcode_t ret = 0; - int i; + unsigned int i; const char *bad = "bad icount"; EXT2_CHECK_MAGIC(icount, EXT2_ET_MAGIC_ICOUNT); diff --git a/lib/ext2fs/imager.c b/lib/ext2fs/imager.c index b72a9fb2..596fbbeb 100644 --- a/lib/ext2fs/imager.c +++ b/lib/ext2fs/imager.c @@ -108,7 +108,7 @@ errcode_t ext2fs_image_inode_write(ext2_filsys fs, int fd, int flags) retval = errno; goto errout; } - if (actual != fs->blocksize * d) { + if (actual != (ssize_t) (fs->blocksize * d)) { retval = EXT2_ET_SHORT_WRITE; goto errout; } @@ -129,7 +129,8 @@ errout: /* * Read in the inode table and stuff it into place */ -errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd, int flags) +errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd, + int flags EXT2FS_ATTR((unused))) { unsigned int group, c, left; char *buf; @@ -157,7 +158,7 @@ errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd, int flags) retval = errno; goto errout; } - if (actual != fs->blocksize * c) { + if (actual != (ssize_t) (fs->blocksize * c)) { retval = EXT2_ET_SHORT_READ; goto errout; } @@ -179,7 +180,8 @@ errout: /* * Write out superblock and group descriptors */ -errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd, int flags) +errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd, + int flags EXT2FS_ATTR((unused))) { char *buf, *cp; ssize_t actual; @@ -199,7 +201,7 @@ errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd, int flags) retval = errno; goto errout; } - if (actual != fs->blocksize) { + if (actual != (ssize_t) fs->blocksize) { retval = EXT2_ET_SHORT_WRITE; goto errout; } @@ -213,7 +215,7 @@ errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd, int flags) retval = errno; goto errout; } - if (actual != fs->blocksize * fs->desc_blocks) { + if (actual != (ssize_t) (fs->blocksize * fs->desc_blocks)) { retval = EXT2_ET_SHORT_WRITE; goto errout; } @@ -228,7 +230,8 @@ errout: /* * Read the superblock and group descriptors and overwrite them. */ -errcode_t ext2fs_image_super_read(ext2_filsys fs, int fd, int flags) +errcode_t ext2fs_image_super_read(ext2_filsys fs, int fd, + int flags EXT2FS_ATTR((unused))) { char *buf; ssize_t actual, size; @@ -312,7 +315,7 @@ errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags) size = fs->blocksize - size; while (size) { c = size; - if (c > sizeof(zero_buf)) + if (c > (int) sizeof(zero_buf)) c = sizeof(zero_buf); actual = write(fd, zero_buf, c); if (actual == -1) { diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c index d1cb7506..74f20a70 100644 --- a/lib/ext2fs/initialize.c +++ b/lib/ext2fs/initialize.c @@ -66,11 +66,11 @@ errcode_t ext2fs_initialize(const char *name, int flags, errcode_t retval; struct ext2_super_block *super; int frags_per_block; - int rem; - int overhead = 0; + unsigned int rem; + unsigned int overhead = 0; blk_t group_block; - int ipg; - int i, j; + unsigned int ipg; + dgrp_t i; blk_t numblocks; char *buf; @@ -205,7 +205,7 @@ retry: return EXT2_ET_TOO_MANY_INODES; } - if (ipg > EXT2_MAX_INODES_PER_GROUP(super)) + if (ipg > (unsigned) EXT2_MAX_INODES_PER_GROUP(super)) ipg = EXT2_MAX_INODES_PER_GROUP(super); super->s_inodes_per_group = ipg; @@ -262,8 +262,8 @@ retry: * necessary data structures. If not, we need to get rid of * it. */ - rem = (int) ((super->s_blocks_count - super->s_first_data_block) % - super->s_blocks_per_group); + rem = ((super->s_blocks_count - super->s_first_data_block) % + super->s_blocks_per_group); if ((fs->group_desc_count == 1) && rem && (rem < overhead)) return EXT2_ET_TOOSMALL; if (rem && (rem < overhead+50)) { diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c index d80f6c01..50420b76 100644 --- a/lib/ext2fs/inode.c +++ b/lib/ext2fs/inode.c @@ -483,7 +483,8 @@ errcode_t ext2fs_read_inode (ext2_filsys fs, ext2_ino_t ino, unsigned long group, block, block_nr, offset; char *ptr; errcode_t retval; - int clen, length, i, inodes_per_block; + int clen, i, inodes_per_block; + unsigned int length; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); @@ -539,7 +540,7 @@ errcode_t ext2fs_read_inode (ext2_filsys fs, ext2_ino_t ino, if (length > sizeof(struct ext2_inode)) length = sizeof(struct ext2_inode); - if ((offset + length) > EXT2_BLOCK_SIZE(fs->super)) { + if ((offset + length) > (unsigned) EXT2_BLOCK_SIZE(fs->super)) { clen = (int) (EXT2_BLOCK_SIZE(fs->super) - offset); memcpy((char *) inode, ptr, clen); length -= clen; @@ -579,7 +580,8 @@ errcode_t ext2fs_write_inode(ext2_filsys fs, ext2_ino_t ino, errcode_t retval; struct ext2_inode temp_inode; char *ptr; - int clen, length, i; + int clen, i; + unsigned int length; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); @@ -641,7 +643,7 @@ errcode_t ext2fs_write_inode(ext2_filsys fs, ext2_ino_t ino, fs->icache->buffer_blk = block_nr; } - if ((offset + length) > EXT2_BLOCK_SIZE(fs->super)) { + if ((offset + length) > (unsigned) EXT2_BLOCK_SIZE(fs->super)) { clen = (int) (EXT2_BLOCK_SIZE(fs->super) - offset); length -= clen; } else { diff --git a/lib/ext2fs/jfs_compat.h b/lib/ext2fs/jfs_compat.h index c8dc5af7..30ad1ef5 100644 --- a/lib/ext2fs/jfs_compat.h +++ b/lib/ext2fs/jfs_compat.h @@ -18,7 +18,7 @@ #define cpu_to_be32(n) htonl(n) #define be32_to_cpu(n) ntohl(n) -typedef int tid_t; +typedef unsigned int tid_t; typedef struct journal_s journal_t; struct buffer_head; diff --git a/lib/ext2fs/lookup.c b/lib/ext2fs/lookup.c index af9fdd1d..1745f33a 100644 --- a/lib/ext2fs/lookup.c +++ b/lib/ext2fs/lookup.c @@ -29,9 +29,9 @@ struct lookup_struct { #pragma argsused #endif static int lookup_proc(struct ext2_dir_entry *dirent, - int offset, - int blocksize, - char *buf, + int offset EXT2FS_ATTR((unused)), + int blocksize EXT2FS_ATTR((unused)), + char *buf EXT2FS_ATTR((unused)), void *priv_data) { struct lookup_struct *ls = (struct lookup_struct *) priv_data; diff --git a/lib/ext2fs/mkjournal.c b/lib/ext2fs/mkjournal.c index abf162e7..427a08e7 100644 --- a/lib/ext2fs/mkjournal.c +++ b/lib/ext2fs/mkjournal.c @@ -94,7 +94,8 @@ static errcode_t write_journal_file(ext2_filsys fs, char *filename, { errcode_t retval; char *buf = 0; - int i, fd, ret_size; + int fd, ret_size; + blk_t i; if ((retval = ext2fs_create_journal_superblock(fs, size, flags, &buf))) return retval; @@ -112,7 +113,7 @@ static errcode_t write_journal_file(ext2_filsys fs, char *filename, retval = errno; goto errout; } - if (ret_size != fs->blocksize) + if (ret_size != (int) fs->blocksize) goto errout; memset(buf, 0, fs->blocksize); @@ -122,7 +123,7 @@ static errcode_t write_journal_file(ext2_filsys fs, char *filename, retval = errno; goto errout; } - if (ret_size != fs->blocksize) + if (ret_size != (int) fs->blocksize) goto errout; } close(fd); @@ -143,12 +144,12 @@ struct mkjournal_struct { errcode_t err; }; -static int mkjournal_proc(ext2_filsys fs, - blk_t *blocknr, - e2_blkcnt_t blockcnt, - blk_t ref_block, - int ref_offset, - void *priv_data) +static int mkjournal_proc(ext2_filsys fs, + blk_t *blocknr, + e2_blkcnt_t blockcnt, + blk_t ref_block EXT2FS_ATTR((unused)), + int ref_offset EXT2FS_ATTR((unused)), + void *priv_data) { struct mkjournal_struct *es = (struct mkjournal_struct *) priv_data; blk_t new_blk; @@ -255,8 +256,8 @@ errcode_t ext2fs_add_journal_device(ext2_filsys fs, ext2_filsys journal_dev) errcode_t retval; char buf[1024]; journal_superblock_t *jsb; - int i, start; - __u32 nr_users; + int start; + __u32 i, nr_users; /* Make sure the device exists and is a block device */ if (stat(journal_dev->device_name, &st) < 0) @@ -277,7 +278,7 @@ errcode_t ext2fs_add_journal_device(ext2_filsys fs, ext2_filsys journal_dev) (jsb->s_header.h_blocktype != (unsigned) ntohl(JFS_SUPERBLOCK_V2))) return EXT2_ET_NO_JOURNAL_SB; - if (ntohl(jsb->s_blocksize) != fs->blocksize) + if (ntohl(jsb->s_blocksize) != (unsigned long) fs->blocksize) return EXT2_ET_UNEXPECTED_BLOCK_SIZE; /* Check and see if this filesystem has already been added */ diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c index 7dd5737e..bc7c5bb3 100644 --- a/lib/ext2fs/openfs.c +++ b/lib/ext2fs/openfs.c @@ -71,11 +71,13 @@ blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block, dgrp_t i) * EXT2_FLAG_JOURNAL_DEV_OK - Open an ext3 journal device */ errcode_t ext2fs_open(const char *name, int flags, int superblock, - int block_size, io_manager manager, ext2_filsys *ret_fs) + unsigned int block_size, io_manager manager, + ext2_filsys *ret_fs) { ext2_filsys fs; errcode_t retval; - int i, j, groups_per_block, blocks_per_group; + unsigned long i; + int j, groups_per_block, blocks_per_group; blk_t group_block, blk; char *dest; struct ext2_group_desc *gdp; diff --git a/lib/ext2fs/read_bb.c b/lib/ext2fs/read_bb.c index d0f31391..c717adcd 100644 --- a/lib/ext2fs/read_bb.c +++ b/lib/ext2fs/read_bb.c @@ -38,8 +38,10 @@ struct read_bb_record { #pragma argsused #endif static int mark_bad_block(ext2_filsys fs, blk_t *block_nr, - e2_blkcnt_t blockcnt, blk_t ref_block, - int ref_offset, void *priv_data) + e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)), + blk_t ref_block EXT2FS_ATTR((unused)), + int ref_offset EXT2FS_ATTR((unused)), + void *priv_data) { struct read_bb_record *rb = (struct read_bb_record *) priv_data; diff --git a/lib/ext2fs/read_bb_file.c b/lib/ext2fs/read_bb_file.c index f671b92b..40c34ee3 100644 --- a/lib/ext2fs/read_bb_file.c +++ b/lib/ext2fs/read_bb_file.c @@ -72,7 +72,8 @@ errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f, } static void call_compat_invalid(ext2_filsys fs, blk_t blk, - char *badstr, void *priv_data) + char *badstr EXT2FS_ATTR((unused)), + void *priv_data) { void (*invalid)(ext2_filsys, blk_t); diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c index 2c5f3976..ff3dd591 100644 --- a/lib/ext2fs/rw_bitmaps.c +++ b/lib/ext2fs/rw_bitmaps.c @@ -96,9 +96,9 @@ errcode_t ext2fs_write_inode_bitmap(ext2_filsys fs) errcode_t ext2fs_write_block_bitmap (ext2_filsys fs) { dgrp_t i; - int j; + unsigned int j; int nbytes; - int nbits; + unsigned int nbits; errcode_t retval; char * block_bitmap = fs->block_map->bitmap; char * bitmap_block = NULL; @@ -119,9 +119,9 @@ errcode_t ext2fs_write_block_bitmap (ext2_filsys fs) memcpy(bitmap_block, block_bitmap, nbytes); if (i == fs->group_desc_count - 1) { /* Force bitmap padding for the last group */ - nbits = (int) ((fs->super->s_blocks_count - - fs->super->s_first_data_block) - % EXT2_BLOCKS_PER_GROUP(fs->super)); + nbits = ((fs->super->s_blocks_count + - fs->super->s_first_data_block) + % EXT2_BLOCKS_PER_GROUP(fs->super)); if (nbits) for (j = nbits; j < fs->blocksize * 8; j++) ext2fs_set_bit(j, bitmap_block); diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c index 2c732e9c..5b2f364b 100644 --- a/lib/ext2fs/unix_io.c +++ b/lib/ext2fs/unix_io.c @@ -113,7 +113,7 @@ static errcode_t raw_read_blk(io_channel channel, int count, void *buf) { errcode_t retval; - size_t size; + ssize_t size; ext2_loff_t location; int actual = 0; @@ -199,7 +199,7 @@ static errcode_t raw_write_blk(io_channel channel, unsigned long block, int count, const void *buf) { - size_t size; + ssize_t size; ext2_loff_t location; int actual = 0; errcode_t retval; @@ -260,8 +260,7 @@ static errcode_t alloc_cache(io_channel channel, } /* Free the cache buffers */ -static void free_cache(io_channel channel, - struct unix_private_data *data) +static void free_cache(struct unix_private_data *data) { struct unix_cache *cache; int i; @@ -284,8 +283,7 @@ static void free_cache(io_channel channel, * eldest is a non-zero pointer, then fill in eldest with the cache * entry to that should be reused. */ -static struct unix_cache *find_cached_block(io_channel channel, - struct unix_private_data *data, +static struct unix_cache *find_cached_block(struct unix_private_data *data, unsigned long block, struct unix_cache **eldest) { @@ -451,7 +449,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) cleanup: if (data) { - free_cache(io, data); + free_cache(data); ext2fs_free_mem(&data); } if (io) @@ -477,7 +475,7 @@ static errcode_t unix_close(io_channel channel) if (close(data->dev) < 0) retval = errno; - free_cache(channel, data); + free_cache(data); ext2fs_free_mem(&channel->private_data); if (channel->name) @@ -502,7 +500,7 @@ static errcode_t unix_set_blksize(io_channel channel, int blksize) #endif channel->block_size = blksize; - free_cache(channel, data); + free_cache(data); if ((retval = alloc_cache(channel, data))) return retval; } @@ -539,8 +537,7 @@ static errcode_t unix_read_blk(io_channel channel, unsigned long block, cp = buf; while (count > 0) { /* If it's in the cache, use it! */ - if ((cache = find_cached_block(channel, data, block, - &reuse[0]))) { + if ((cache = find_cached_block(data, block, &reuse[0]))) { #ifdef DEBUG printf("Using cached block %d\n", block); #endif @@ -555,8 +552,7 @@ static errcode_t unix_read_blk(io_channel channel, unsigned long block, * single read request */ for (i=1; i < count; i++) - if (find_cached_block(channel, data, block+i, - &reuse[i])) + if (find_cached_block(data, block+i, &reuse[i])) break; #ifdef DEBUG printf("Reading %d blocks starting at %d\n", i, block); @@ -614,7 +610,7 @@ static errcode_t unix_write_blk(io_channel channel, unsigned long block, cp = buf; while (count > 0) { - cache = find_cached_block(channel, data, block, &reuse); + cache = find_cached_block(data, block, &reuse); if (!cache) { cache = reuse; reuse_cache(channel, data, cache, block); @@ -634,7 +630,7 @@ static errcode_t unix_write_byte(io_channel channel, unsigned long offset, { struct unix_private_data *data; errcode_t retval = 0; - size_t actual; + ssize_t actual; EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); data = (struct unix_private_data *) channel->private_data; diff --git a/lib/ext2fs/unlink.c b/lib/ext2fs/unlink.c index 03825c49..5612b3dd 100644 --- a/lib/ext2fs/unlink.c +++ b/lib/ext2fs/unlink.c @@ -30,9 +30,9 @@ struct link_struct { #pragma argsused #endif static int unlink_proc(struct ext2_dir_entry *dirent, - int offset, - int blocksize, - char *buf, + int offset EXT2FS_ATTR((unused)), + int blocksize EXT2FS_ATTR((unused)), + char *buf EXT2FS_ATTR((unused)), void *priv_data) { struct link_struct *ls = (struct link_struct *) priv_data; @@ -55,7 +55,7 @@ static int unlink_proc(struct ext2_dir_entry *dirent, #endif errcode_t ext2fs_unlink(ext2_filsys fs, ext2_ino_t dir, const char *name, ext2_ino_t ino, - int flags) + int flags EXT2FS_ATTR((unused))) { errcode_t retval; struct link_struct ls; diff --git a/lib/ext2fs/write_bb_file.c b/lib/ext2fs/write_bb_file.c index 011c480a..269b576b 100644 --- a/lib/ext2fs/write_bb_file.c +++ b/lib/ext2fs/write_bb_file.c @@ -15,7 +15,7 @@ #include "ext2fs.h" errcode_t ext2fs_write_bb_FILE(ext2_badblocks_list bb_list, - unsigned int flags, + unsigned int flags EXT2FS_ATTR((unused)), FILE *f) { badblocks_iterate bb_iter; diff --git a/lib/ss/ChangeLog b/lib/ss/ChangeLog index 25e84e16..dbe8a056 100644 --- a/lib/ss/ChangeLog +++ b/lib/ss/ChangeLog @@ -1,3 +1,8 @@ +2003-12-07 Theodore Ts'o <tytso@mit.edu> + + * list_rqs.c, listen.c, requests.c, ss.h, ss_internal.h: Fix gcc + -Wall nitpicks. + 2003-07-25 Theodore Ts'o <tytso@mit.edu> * Release of E2fsprogs 1.34 diff --git a/lib/ss/list_rqs.c b/lib/ss/list_rqs.c index b1fc5ed6..770f5f02 100644 --- a/lib/ss/list_rqs.c +++ b/lib/ss/list_rqs.c @@ -17,26 +17,18 @@ typedef void sigret_t; -#ifdef lint /* "lint returns a value which is sometimes ignored" */ -#define DONT_USE(x) x=x; -#else /* !lint */ -#define DONT_USE(x) ; -#endif /* lint */ - static char const twentyfive_spaces[26] = " "; static char const NL[2] = "\n"; -void ss_list_requests(argc, argv, sci_idx, info_ptr) - int argc; - char const * const * argv; - int sci_idx; - pointer info_ptr; +void ss_list_requests(int argc __SS_ATTR((unused)), + const char * const *argv __SS_ATTR((unused)), + int sci_idx, void *infop __SS_ATTR((unused))) { - register ss_request_entry *entry; - register char const * const *name; - register int spacing; - register ss_request_table **table; + ss_request_entry *entry; + char const * const *name; + int spacing; + ss_request_table **table; char buffer[BUFSIZ]; FILE *output; @@ -47,9 +39,6 @@ void ss_list_requests(argc, argv, sci_idx, info_ptr) int waitb; #endif - DONT_USE(argc); - DONT_USE(argv); - sigemptyset(&igmask); sigaddset(&igmask, SIGINT); sigprocmask(SIG_BLOCK, &igmask, &omask); @@ -69,7 +58,7 @@ void ss_list_requests(argc, argv, sci_idx, info_ptr) if (entry->flags & SS_OPT_DONT_LIST) continue; for (name = entry->command_names; *name; name++) { - register int len = strlen(*name); + int len = strlen(*name); strncat(buffer, *name, len); spacing += len + 2; if (name[1]) { diff --git a/lib/ss/listen.c b/lib/ss/listen.c index 784af444..05d0dc06 100644 --- a/lib/ss/listen.c +++ b/lib/ss/listen.c @@ -28,7 +28,7 @@ static ss_data *current_info; static jmp_buf listen_jmpb; static sigret_t (*sig_cont)(int); -static sigret_t print_prompt(int sig) +static sigret_t print_prompt(int sig __SS_ATTR((unused))) { if (current_info->redisplay) (*current_info->redisplay)(); @@ -38,7 +38,7 @@ static sigret_t print_prompt(int sig) } } -static sigret_t listen_int_handler(int sig) +static sigret_t listen_int_handler(int sig __SS_ATTR((unused))) { putc('\n', stdout); signal(SIGINT, listen_int_handler); @@ -133,7 +133,9 @@ void ss_abort_subsystem(int sci_idx, int code) } -void ss_quit(int argc, const char * const *argv, int sci_idx, pointer infop) +void ss_quit(int argc __SS_ATTR((unused)), + const char * const *argv __SS_ATTR((unused)), + int sci_idx, pointer infop __SS_ATTR((unused))) { ss_abort_subsystem(sci_idx, 0); } @@ -185,7 +187,8 @@ static char *cmd_generator(const char *text, int state) return 0; } -char **ss_rl_completion(const char *text, int start, int end) +char **ss_rl_completion(const char *text, int start, + int end __SS_ATTR((unused))) { if ((start == 0) && current_info->rl_completion_matches) return (*current_info->rl_completion_matches) diff --git a/lib/ss/requests.c b/lib/ss/requests.c index 7f1805d4..80133688 100644 --- a/lib/ss/requests.c +++ b/lib/ss/requests.c @@ -22,8 +22,9 @@ /* * ss_self_identify -- assigned by default to the "." request */ -void ss_self_identify(int argc,const char * const *argv, - int sci_idx, void *infop) +void ss_self_identify(int argc __SS_ATTR((unused)), + const char * const *argv __SS_ATTR((unused)), + int sci_idx, void *infop __SS_ATTR((unused))) { register ss_data *info = ss_info(sci_idx); printf("%s version %s\n", info->subsystem_name, @@ -33,8 +34,10 @@ void ss_self_identify(int argc,const char * const *argv, /* * ss_subsystem_name -- print name of subsystem */ -void ss_subsystem_name(int argc,const char * const *argv, - int sci_idx, void *infop) +void ss_subsystem_name(int argc __SS_ATTR((unused)), + const char * const *argv __SS_ATTR((unused)), + int sci_idx, + void *infop __SS_ATTR((unused))) { printf("%s\n", ss_info(sci_idx)->subsystem_name); } @@ -42,8 +45,10 @@ void ss_subsystem_name(int argc,const char * const *argv, /* * ss_subsystem_version -- print version of subsystem */ -void ss_subsystem_version(int argc,const char * const *argv, - int sci_idx, void *infop) +void ss_subsystem_version(int argc __SS_ATTR((unused)), + const char * const *argv __SS_ATTR((unused)), + int sci_idx, + void *infop __SS_ATTR((unused))) { printf("%s\n", ss_info(sci_idx)->subsystem_version); } @@ -52,8 +57,9 @@ void ss_subsystem_version(int argc,const char * const *argv, * ss_unimplemented -- routine not implemented (should be * set up as (dont_list,dont_summarize)) */ -void ss_unimplemented(int argc,const char * const *argv, - int sci_idx, void *infop) +void ss_unimplemented(int argc __SS_ATTR((unused)), + const char * const *argv __SS_ATTR((unused)), + int sci_idx, void *infop __SS_ATTR((unused))) { ss_perror(sci_idx, SS_ET_UNIMPLEMENTED, ""); } diff --git a/lib/ss/ss.h b/lib/ss/ss.h index 90a268aa..6cc050bd 100644 --- a/lib/ss/ss.h +++ b/lib/ss/ss.h @@ -28,6 +28,13 @@ #define __SS_CONST const #define __SS_PROTO (int, const char * const *, int, void *) +#ifdef __GNUC__ +#define __SS_ATTR(x) __attribute__(x) +#else +#define __SS_ATTR(x) +#endif + + typedef __SS_CONST struct _ss_request_entry { __SS_CONST char * __SS_CONST *command_names; /* whatever */ void (* __SS_CONST function) __SS_PROTO; /* foo */ @@ -60,8 +67,10 @@ char *ss_current_request(); /* This is actually a macro */ #endif char *ss_name(int sci_idx); -void ss_error (int, long, char const *, ...); +void ss_error (int, long, char const *, ...) + __SS_ATTR((format(printf, 3, 4))); void ss_perror (int, long, char const *); + int ss_create_invocation(const char *, const char *, void *, ss_request_table *, int *); void ss_delete_invocation(int); |