Whamcloud - gitweb
Fix gcc -Wall nitpicks
authorTheodore Ts'o <tytso@mit.edu>
Sun, 7 Dec 2003 06:28:50 +0000 (01:28 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 7 Dec 2003 06:28:50 +0000 (01:28 -0500)
83 files changed:
debugfs/ChangeLog
debugfs/debugfs.c
debugfs/debugfs.h
debugfs/dump.c
debugfs/htree.c
debugfs/icheck.c
debugfs/logdump.c
debugfs/ls.c
debugfs/lsdel.c
debugfs/ncheck.c
debugfs/setsuper.c
debugfs/unused.c
e2fsck/ChangeLog
e2fsck/badblocks.c
e2fsck/dict.c
e2fsck/ea_refcount.c
e2fsck/ehandler.c
e2fsck/journal.c
e2fsck/pass1.c
e2fsck/pass1b.c
e2fsck/pass2.c
e2fsck/pass3.c
e2fsck/pass5.c
e2fsck/problem.c
e2fsck/rehash.c
e2fsck/super.c
e2fsck/swapfs.c
e2fsck/unix.c
e2fsck/util.c
lib/blkid/ChangeLog
lib/blkid/blkidP.h
lib/blkid/probe.c
lib/blkid/read.c
lib/ext2fs/ChangeLog
lib/ext2fs/alloc.c
lib/ext2fs/bb_inode.c
lib/ext2fs/bitops.c
lib/ext2fs/block.c
lib/ext2fs/check_desc.c
lib/ext2fs/closefs.c
lib/ext2fs/dir_iterate.c
lib/ext2fs/dirblock.c
lib/ext2fs/expanddir.c
lib/ext2fs/ext2fs.h
lib/ext2fs/get_pathname.c
lib/ext2fs/icount.c
lib/ext2fs/imager.c
lib/ext2fs/initialize.c
lib/ext2fs/inode.c
lib/ext2fs/jfs_compat.h
lib/ext2fs/lookup.c
lib/ext2fs/mkjournal.c
lib/ext2fs/openfs.c
lib/ext2fs/read_bb.c
lib/ext2fs/read_bb_file.c
lib/ext2fs/rw_bitmaps.c
lib/ext2fs/unix_io.c
lib/ext2fs/unlink.c
lib/ext2fs/write_bb_file.c
lib/ss/ChangeLog
lib/ss/list_rqs.c
lib/ss/listen.c
lib/ss/requests.c
lib/ss/ss.h
misc/ChangeLog
misc/badblocks.c
misc/blkid.c
misc/chattr.c
misc/dumpe2fs.c
misc/e2image.c
misc/fsck.c
misc/fsck.h
misc/lsattr.c
misc/mke2fs.c
misc/nls-enable.h
misc/tune2fs.c
misc/util.c
resize/ChangeLog
resize/main.c
resize/resize2fs.c
util/ChangeLog
util/gcc-wall-cleanup
util/subst.c

index fed2958..ae475fd 100644 (file)
@@ -1,3 +1,9 @@
+2003-12-07  Theodore Ts'o  <tytso@mit.edu>
+
+       * debugfs.c, debugfs.h, dump.c, htree.c, icheck.c, logdump.c,
+               ls.c, lsdel.c, ncheck.c, setsuper.c, unused.c: Fix gcc
+               -Wall nitpicks.
+
 2003-08-24  Theodore Ts'o  <tytso@mit.edu>
 
        * debugfs.8.in: Adjust description line so that apropos
index 1fcb9d3..2c13e4f 100644 (file)
@@ -229,7 +229,7 @@ static void print_features(struct ext2_super_block * s, FILE *f)
 
 void do_show_super_stats(int argc, char *argv[])
 {
-       int     i;
+       dgrp_t  i;
        FILE    *out;
        struct ext2_group_desc *gdp;
        int     c, header_only = 0;
@@ -285,7 +285,8 @@ void do_show_super_stats(int argc, char *argv[])
        close_pager(out);
 }
 
-void do_dirty_filesys(int argc, char **argv)
+void do_dirty_filesys(int argc EXT2FS_ATTR((unused)), 
+                     char **argv EXT2FS_ATTR((unused)))
 {
        if (check_fs_open(argv[0]))
                return;
@@ -323,9 +324,11 @@ static void finish_range(struct list_blocks_struct *lb)
        lb->first_block = 0;
 }
 
-static int list_blocks_proc(ext2_filsys fs, blk_t *blocknr,
-                           e2_blkcnt_t blockcnt, blk_t ref_block,
-                           int ref_offset, void *private)
+static int list_blocks_proc(ext2_filsys fs EXT2FS_ATTR((unused)), 
+                           blk_t *blocknr, e2_blkcnt_t blockcnt, 
+                           blk_t ref_block EXT2FS_ATTR((unused)),
+                           int ref_offset EXT2FS_ATTR((unused)), 
+                           void *private)
 {
        struct list_blocks_struct *lb = (struct list_blocks_struct *) private;
 
@@ -857,7 +860,8 @@ void do_link(int argc, char *argv[])
 }
 
 static int mark_blocks_proc(ext2_filsys fs, blk_t *blocknr,
-                           int blockcnt, void *private)
+                           int blockcnt EXT2FS_ATTR((unused)), 
+                           void *private EXT2FS_ATTR((unused)))
 {
        blk_t   block;
 
@@ -1131,11 +1135,11 @@ void do_write(int argc, char *argv[])
 
 void do_mknod(int argc, char *argv[])
 {
-       unsigned long   mode, major, minor, nr;
+       unsigned long   mode, major, minor;
        ext2_ino_t      newfile;
        errcode_t       retval;
        struct ext2_inode inode;
-       int             filetype;
+       int             filetype, nr;
 
        if (check_fs_open(argv[0]))
                return;
@@ -1243,7 +1247,8 @@ void do_mkdir(int argc, char *argv[])
 }
 
 static int release_blocks_proc(ext2_filsys fs, blk_t *blocknr,
-                              int blockcnt, void *private)
+                              int blockcnt EXT2FS_ATTR((unused)), 
+                              void *private EXT2FS_ATTR((unused)))
 {
        blk_t   block;
 
@@ -1318,12 +1323,12 @@ struct rd_struct {
        int             empty;
 };
 
-static int rmdir_proc(ext2_ino_t dir,
-                     int       entry,
+static int rmdir_proc(ext2_ino_t dir EXT2FS_ATTR((unused)),
+                     int       entry EXT2FS_ATTR((unused)),
                      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      *private)
 {
        struct rd_struct *rds = (struct rd_struct *) private;
@@ -1397,7 +1402,8 @@ void do_rmdir(int argc, char *argv[])
        }
 }
 
-void do_show_debugfs_params(int argc, char *argv[])
+void do_show_debugfs_params(int argc EXT2FS_ATTR((unused)), 
+                           char *argv[] EXT2FS_ATTR((unused)))
 {
        FILE *out = stdout;
 
@@ -1484,7 +1490,7 @@ void do_imap(int argc, char *argv[])
                EXT2_INODE_SIZE(current_fs->super);
        block = offset >> EXT2_BLOCK_SIZE_BITS(current_fs->super);
        if (!current_fs->group_desc[(unsigned)group].bg_inode_table) {
-               com_err(argv[0], 0, "Inode table for group %d is missing\n",
+               com_err(argv[0], 0, "Inode table for group %lu is missing\n",
                        group);
                return;
        }
index e8c77a8..cb6ba85 100644 (file)
@@ -73,6 +73,9 @@ extern void do_ncheck(int argc, char **argv);
 /* set_super.c */
 extern void do_set_super(int argc, char **);
 
+/* unused.c */
+extern void do_dump_unused(int argc, char **argv);
+
 /* debugfs.c */
 extern void internal_dump_inode(FILE *, const char *, ext2_ino_t, 
                                struct ext2_inode *, int);
index 0ea6e35..fbaf703 100644 (file)
@@ -120,7 +120,7 @@ static void dump_file(const char *cmdname, ext2_ino_t ino, int fd,
                if (got == 0)
                        break;
                nbytes = write(fd, buf, got);
-               if (nbytes != got)
+               if ((unsigned) nbytes != got)
                        com_err(cmdname, errno, "while writing file");
        }
        retval = ext2fs_file_close(e2_file);
@@ -287,8 +287,10 @@ errout:
        free(fullname);
 }
 
-static int rdump_dirent(struct ext2_dir_entry *dirent, int offset,
-                        int blocksize, char *buf, void *private)
+static int rdump_dirent(struct ext2_dir_entry *dirent, 
+                       int offset EXT2FS_ATTR((unused)),
+                       int blocksize EXT2FS_ATTR((unused)),
+                       char *buf EXT2FS_ATTR((unused)), void *private)
 {
        char name[EXT2_NAME_LEN];
        int thislen;
index 7084243..7af3d1b 100644 (file)
@@ -33,7 +33,8 @@ static void htree_dump_leaf_node(ext2_filsys fs, ext2_ino_t ino,
 {
        errcode_t       errcode;
        struct ext2_dir_entry *dirent;
-       int             thislen, col = 0, offset = 0;
+       int             thislen, col = 0;
+       unsigned int    offset = 0;
        char            name[EXT2_NAME_LEN];
        char            tmp[EXT2_NAME_LEN + 16];
        blk_t           pblk;
@@ -341,13 +342,15 @@ void do_dirsearch(int argc, char *argv[])
 
 
 static int search_dir_block(ext2_filsys fs, blk_t *blocknr,
-                           e2_blkcnt_t blockcnt, blk_t ref_blk, 
-                           int ref_offset, void *priv_data)
+                           e2_blkcnt_t blockcnt, 
+                           blk_t ref_blk EXT2FS_ATTR((unused)),
+                           int ref_offset EXT2FS_ATTR((unused)),
+                           void *priv_data)
 {
        struct process_block_struct *p;
        struct ext2_dir_entry *dirent;
        errcode_t               errcode;
-       int                     offset = 0;
+       unsigned int            offset = 0;
 
        if (blockcnt < 0)
                return 0;
@@ -357,7 +360,7 @@ static int search_dir_block(ext2_filsys fs, blk_t *blocknr,
        errcode = io_channel_read_blk(current_fs->io, *blocknr, 1, p->buf);
        if (errcode) {
                com_err("search_dir_block", errcode,
-                       "while reading block %lu", *blocknr);
+                       "while reading block %lu", (unsigned long) *blocknr);
                return BLOCK_ABORT;
        }
 
index c08d558..6c4b0a1 100644 (file)
@@ -30,11 +30,11 @@ struct block_walk_struct {
        ext2_ino_t              inode;
 };
 
-static int icheck_proc(ext2_filsys fs,
+static int icheck_proc(ext2_filsys fs EXT2FS_ATTR((unused)),
                       blk_t    *block_nr,
-                      e2_blkcnt_t blockcnt,
-                      blk_t ref_block,
-                      int ref_offset,
+                      e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)),
+                      blk_t ref_block EXT2FS_ATTR((unused)),
+                      int ref_offset EXT2FS_ATTR((unused)),
                       void *private)
 {
        struct block_walk_struct *bw = (struct block_walk_struct *) private;
index fcc12f0..ab85ffe 100644 (file)
@@ -36,6 +36,8 @@ extern char *optarg;
 
 enum journal_location {JOURNAL_IS_INTERNAL, JOURNAL_IS_EXTERNAL};
 
+#define ANY_BLOCK ((unsigned int) -1)
+
 int            dump_all, dump_contents, dump_descriptors;
 unsigned int   block_to_dump, group_to_dump, bitmap_to_dump;
 unsigned int   inode_block_to_dump, inode_offset_to_dump, bitmap_to_dump;
@@ -96,9 +98,9 @@ void do_logdump(int argc, char **argv)
        dump_all = 0;
        dump_contents = 0;
        dump_descriptors = 1;
-       block_to_dump = -1;
+       block_to_dump = ANY_BLOCK;
        bitmap_to_dump = -1;
-       inode_block_to_dump = -1;
+       inode_block_to_dump = ANY_BLOCK;
        inode_to_dump = -1;
        
        reset_getopt();
@@ -181,7 +183,7 @@ void do_logdump(int argc, char **argv)
                }
        }
 
-       if (block_to_dump != -1 && current_fs != NULL) {
+       if (block_to_dump != ANY_BLOCK && current_fs != NULL) {
                group_to_dump = ((block_to_dump - 
                                  es->s_first_data_block)
                                 / es->s_blocks_per_group);
@@ -299,7 +301,7 @@ static int read_journal_block(const char *cmd, struct journal_source *source,
        
        if (retval)
                com_err(cmd, retval, "while while reading journal");
-       else if (*got != size) {
+       else if (*got != (unsigned int) size) {
                com_err(cmd, 0, "short read (read %d, expected %d) while while reading journal", *got, size);
                retval = -1;
        }
@@ -332,7 +334,7 @@ static void dump_journal(char *cmdname, FILE *out_file,
        char                    jsb_buffer[1024];
        char                    buf[8192];
        journal_superblock_t    *jsb;
-       int                     blocksize = 1024;
+       unsigned int            blocksize = 1024;
        unsigned int            got;
        int                     retval;
        __u32                   magic, sequence, blocktype;
@@ -513,9 +515,10 @@ static void dump_descriptor_block(FILE *out_file,
 
 
 static void dump_revoke_block(FILE *out_file, char *buf,
-                                 journal_superblock_t *jsb, 
-                                 unsigned int blocknr, int blocksize,
-                                 tid_t transaction)
+                             journal_superblock_t *jsb EXT2FS_ATTR((unused)), 
+                             unsigned int blocknr, 
+                             int blocksize EXT2FS_ATTR((unused)),
+                             tid_t transaction)
 {
        int                     offset, max;
        journal_revoke_header_t *header;
@@ -561,7 +564,7 @@ static void show_indirect(FILE *out_file, const char *name, __u32 where)
 
 
 static void dump_metadata_block(FILE *out_file, struct journal_source *source,
-                               journal_superblock_t *jsb,
+                               journal_superblock_t *jsb EXT2FS_ATTR((unused)),
                                unsigned int log_blocknr, 
                                unsigned int fs_blocknr, 
                                int blocksize,
index 2c672fb..72874eb 100644 (file)
@@ -40,12 +40,12 @@ struct list_dir_struct {
 static const char *monstr[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
                                "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
                                        
-static int list_dir_proc(ext2_ino_t dir,
+static int list_dir_proc(ext2_ino_t dir EXT2FS_ATTR((unused)),
                         int    entry,
                         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   *private)
 {
        struct ext2_inode       inode;
index 9a57a41..71febd5 100644 (file)
@@ -49,7 +49,7 @@ static int deleted_info_compare(const void *a, const void *b)
 
 static int lsdel_proc(ext2_filsys fs,
                      blk_t     *block_nr,
-                     int blockcnt,
+                     int blockcnt EXT2FS_ATTR((unused)),
                      void *private)
 {
        struct lsdel_struct *lsd = (struct lsdel_struct *) private;
@@ -128,7 +128,7 @@ void do_lsdel(int argc, char **argv)
        
        while (ino) {
                if ((inode.i_dtime == 0) ||
-                   (secs && ((now - secs) > inode.i_dtime)))
+                   (secs && ((unsigned) abs(now - secs) > inode.i_dtime)))
                        goto next;
 
                lsd.inode = ino;
index 2c2845c..bb7f524 100644 (file)
@@ -33,9 +33,9 @@ struct inode_walk_struct {
 };
 
 static int ncheck_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     *private)
 {
        struct inode_walk_struct *iw = (struct inode_walk_struct *) private;
index b1061b2..1ff32e3 100644 (file)
@@ -25,7 +25,7 @@ static struct ext2_super_block set_sb;
 struct super_set_info {
        const char      *name;
        void    *ptr;
-       int     size;
+       unsigned int    size;
        errcode_t (*func)(struct super_set_info *info, char *arg);
 };
 
index c055db7..d0a5162 100644 (file)
@@ -24,11 +24,11 @@ extern char *optarg;
 
 #include "debugfs.h"
 
-void do_dump_unused(int argc, char **argv)
+void do_dump_unused(int argc EXT2FS_ATTR((unused)), char **argv)
 {
        unsigned long   blk;
        unsigned char buf[32768];
-       int     i;
+       unsigned int    i;
        errcode_t       retval;
 
        for (blk=current_fs->super->s_first_data_block;
index b97949c..4b92c1b 100644 (file)
@@ -1,5 +1,10 @@
 2003-12-07  Theodore Ts'o  <tytso@mit.edu>
 
+       * badblocks.c, dict.c, ea_refcount.c, ehandler.c, journal.c,
+               pass1.c, pass1b.c, pass2.c, pass3.c, pass5.c, problem.c,
+               rehash.c, super.c, swapfs.c, unix.c, util.c, e2fsck.h: Fix
+               gcc -Wall nitpicks.
+
        * recovery.c, jfs_user.h: Sync recovery.c with latest 2.5 kernel
                version.
 
index 572af20..09ef3ab 100644 (file)
@@ -17,7 +17,7 @@ static int check_bb_inode_blocks(ext2_filsys fs, blk_t *block_nr, int blockcnt,
                                 void *priv_data);
 
 
-static void invalid_block(ext2_filsys fs, blk_t blk)
+static void invalid_block(ext2_filsys fs EXT2FS_ATTR((unused)), blk_t blk)
 {
        printf(_("Bad block %u out of range; ignored.\n"), blk);
        return;
@@ -113,8 +113,10 @@ fatal:
        
 }
 
-static int check_bb_inode_blocks(ext2_filsys fs, blk_t *block_nr, int blockcnt,
-                                void *priv_data)
+static int check_bb_inode_blocks(ext2_filsys fs, 
+                                blk_t *block_nr, 
+                                int blockcnt EXT2FS_ATTR((unused)),
+                                void *priv_data EXT2FS_ATTR((unused)))
 {
        if (!*block_nr)
                return 0;
index 350ce75..bccab8b 100644 (file)
 
 #define NDEBUG
 
+#ifdef __GNUC__
+#define EXT2FS_ATTR(x) __attribute__(x)
+#else
+#define EXT2FS_ATTR(x)
+#endif
+
 #include <stdlib.h>
 #include <stddef.h>
 #include <assert.h>
@@ -963,12 +969,12 @@ int dict_contains(dict_t *dict, dnode_t *node)
     return verify_dict_has_node(dict_nil(dict), dict_root(dict), node);
 }
 
-static dnode_t *dnode_alloc(void *context)
+static dnode_t *dnode_alloc(void *context EXT2FS_ATTR((unused)))
 {
     return malloc(sizeof *dnode_alloc(NULL));
 }
 
-static void dnode_free(dnode_t *node, void *context)
+static void dnode_free(dnode_t *node, void *context EXT2FS_ATTR((unused)))
 {
     free(node);
 }
index de13316..6420c72 100644 (file)
@@ -28,7 +28,7 @@ struct ea_refcount_el {
 struct ea_refcount {
        blk_t           count;
        blk_t           size;
-       int             cursor;
+       blk_t           cursor;
        struct ea_refcount_el   *list;
 };
 
@@ -83,7 +83,7 @@ errout:
  */
 static void refcount_collapse(ext2_refcount_t refcount)
 {
-       int     i, j;
+       unsigned int    i, j;
        struct ea_refcount_el   *list;
 
        list = refcount->list;
index d4060c4..16d6d4f 100644 (file)
@@ -23,8 +23,8 @@ static errcode_t e2fsck_handle_read_error(io_channel channel,
                                          unsigned long block,
                                          int count,
                                          void *data,
-                                         size_t size,
-                                         int actual,
+                                         size_t size EXT2FS_ATTR((unused)),
+                                         int actual EXT2FS_ATTR((unused)),
                                          errcode_t error)
 {
        int     i;
@@ -69,8 +69,8 @@ static errcode_t e2fsck_handle_write_error(io_channel channel,
                                            unsigned long block,
                                            int count,
                                            const void *data,
-                                           size_t size,
-                                           int actual,
+                                           size_t size EXT2FS_ATTR((unused)),
+                                           int actual EXT2FS_ATTR((unused)),
                                            errcode_t error)
 {
        int             i;
index 615bd3e..c645f3b 100644 (file)
@@ -101,8 +101,8 @@ void ll_rw_block(int rw, int nr, struct buffer_head *bhp[])
                                                     1, bh->b_data);
                        if (retval) {
                                com_err(bh->b_ctx->device_name, retval,
-                                       "while reading block %ld\n", 
-                                       bh->b_blocknr);
+                                       "while reading block %lu\n", 
+                                       (unsigned long) bh->b_blocknr);
                                bh->b_err = retval;
                                continue;
                        }
@@ -115,8 +115,8 @@ void ll_rw_block(int rw, int nr, struct buffer_head *bhp[])
                                                      1, bh->b_data);
                        if (retval) {
                                com_err(bh->b_ctx->device_name, retval,
-                                       "while writing block %ld\n", 
-                                       bh->b_blocknr);
+                                       "while writing block %lu\n", 
+                                       (unsigned long) bh->b_blocknr);
                                bh->b_err = retval;
                                continue;
                        }
index 58edd0a..2062807 100644 (file)
@@ -113,7 +113,7 @@ static __u64 ext2_max_sizes[EXT2_MAX_BLOCK_LOG_SIZE -
  * Free all memory allocated by pass1 in preparation for restarting
  * things.
  */
-static void unwind_pass1(ext2_filsys fs)
+static void unwind_pass1(ext2_filsys fs EXT2FS_ATTR((unused)))
 {
        ext2fs_free_mem(&inodes_to_process);
        inodes_to_process = 0;
@@ -165,7 +165,7 @@ int e2fsck_pass1_check_device_inode(ext2_filsys fs, struct ext2_inode *inode)
 int e2fsck_pass1_check_symlink(ext2_filsys fs, struct ext2_inode *inode,
                               char *buf)
 {
-       int len;
+       unsigned int len;
        int i;
        blk_t   blocks;
 
@@ -757,7 +757,8 @@ endit:
  * When the inode_scan routines call this callback at the end of the
  * glock group, call process_inodes.
  */
-static errcode_t scan_callback(ext2_filsys fs, ext2_inode_scan scan,
+static errcode_t scan_callback(ext2_filsys fs, 
+                              ext2_inode_scan scan EXT2FS_ATTR((unused)),
                               dgrp_t group, void * priv_data)
 {
        struct scan_callback_struct *scan_struct;
@@ -1144,7 +1145,8 @@ clear_extattr:
 
 /* Returns 1 if bad htree, 0 if OK */
 static int handle_htree(e2fsck_t ctx, struct problem_context *pctx,
-                       ext2_ino_t ino, struct ext2_inode *inode,
+                       ext2_ino_t ino EXT2FS_ATTR((unused)),
+                       struct ext2_inode *inode,
                        char *block_buf)
 {
        struct ext2_dx_root_info        *root;
@@ -1320,7 +1322,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
        } else {
                size = EXT2_I_SIZE(inode);
                if ((pb.last_block >= 0) &&
-                   (size < pb.last_block * fs->blocksize))
+                   (size < (__u64) pb.last_block * fs->blocksize))
                        bad_size = 3;
                else if (size > ext2_max_sizes[fs->super->s_log_block_size])
                        bad_size = 4;
@@ -1410,8 +1412,8 @@ static char *describe_illegal_block(ext2_filsys fs, blk_t block)
 static int process_block(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 process_block_struct *p;
@@ -1545,14 +1547,14 @@ mark_dir:
 static int process_bad_block(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 process_block_struct *p;
        blk_t           blk = *block_nr;
-       int             first_block;
-       int             i;
+       blk_t           first_block;
+       dgrp_t          i;
        struct problem_context *pctx;
        e2fsck_t        ctx;
 
@@ -1772,7 +1774,7 @@ static void new_table_block(e2fsck_t ctx, blk_t first_block, int group,
 static void handle_fs_bad_blocks(e2fsck_t ctx)
 {
        ext2_filsys fs = ctx->fs;
-       int             i;
+       dgrp_t          i;
        int             first_block = fs->super->s_first_data_block;
 
        for (i = 0; i < fs->group_desc_count; i++) {
@@ -1803,7 +1805,8 @@ static void mark_table_blocks(e2fsck_t ctx)
 {
        ext2_filsys fs = ctx->fs;
        blk_t   block, b;
-       int     i, j;
+       dgrp_t  i;
+       int     j;
        struct problem_context pctx;
        
        clear_problem_context(&pctx);
index 39e9030..f368d84 100644 (file)
@@ -159,7 +159,8 @@ static void add_dupe(e2fsck_t ctx, ext2_ino_t ino, blk_t blk,
 /*
  * Free a duplicate inode record
  */
-static void inode_dnode_free(dnode_t *node, void *context)
+static void inode_dnode_free(dnode_t *node, 
+                            void *context EXT2FS_ATTR((unused)))
 {
        struct dup_inode        *di;
        struct block_el         *p, *next;
@@ -175,7 +176,8 @@ static void inode_dnode_free(dnode_t *node, void *context)
 /*
  * Free a duplicate block record
  */
-static void block_dnode_free(dnode_t *node, void *context)
+static void block_dnode_free(dnode_t *node, 
+                            void *context EXT2FS_ATTR((unused)))
 {
        struct dup_block        *db;
        struct inode_el         *p, *next;
@@ -298,11 +300,11 @@ static void pass1b(e2fsck_t ctx, char *block_buf)
        e2fsck_use_inode_shortcuts(ctx, 0);
 }
 
-static int process_pass1b_block(ext2_filsys fs,
+static int process_pass1b_block(ext2_filsys fs EXT2FS_ATTR((unused)),
                                blk_t   *block_nr,
-                               e2_blkcnt_t blockcnt,
-                               blk_t ref_blk, 
-                               int ref_offset,                          
+                               e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)),
+                               blk_t ref_blk EXT2FS_ATTR((unused))
+                               int ref_offset EXT2FS_ATTR((unused)),
                                void *priv_data)
 {
        struct process_block_struct *p;
@@ -342,8 +344,10 @@ struct search_dir_struct {
 
 static int search_dirent_proc(ext2_ino_t dir, int entry,
                              struct ext2_dir_entry *dirent,
-                             int offset, int blocksize,
-                             char *buf, void *priv_data)
+                             int offset EXT2FS_ATTR((unused)), 
+                             int blocksize EXT2FS_ATTR((unused)),
+                             char *buf EXT2FS_ATTR((unused)), 
+                             void *priv_data)
 {
        struct search_dir_struct *sd;
        struct dup_inode        *p;
@@ -521,9 +525,9 @@ static void decrement_badcount(e2fsck_t ctx, blk_t block, struct dup_block *p)
 
 static int delete_file_block(ext2_filsys fs,
                             blk_t      *block_nr,
-                            e2_blkcnt_t blockcnt,
-                            blk_t ref_block,
-                            int ref_offset
+                            e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)),
+                            blk_t ref_block EXT2FS_ATTR((unused)),
+                            int ref_offset EXT2FS_ATTR((unused)),
                             void *priv_data)
 {
        struct process_block_struct *pb;
@@ -623,8 +627,8 @@ struct clone_struct {
 static int clone_file_block(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 dup_block *p;
@@ -769,7 +773,7 @@ static int check_if_fs_block(e2fsck_t ctx, blk_t test_block)
 {
        ext2_filsys fs = ctx->fs;
        blk_t   block;
-       int     i;
+       dgrp_t  i;
        
        block = fs->super->s_first_data_block;
        for (i = 0; i < fs->group_desc_count; i++) {
index 6f2ac93..dee2c19 100644 (file)
@@ -96,7 +96,7 @@ void e2fsck_pass2(e2fsck_t ctx)
        struct check_dir_struct cd;
        struct dx_dir_info      *dx_dir;
        struct dx_dirblock_info *dx_db, *dx_parent;
-       blk_t                   b;
+       int                     b;
        int                     i, depth;
        problem_t               code;
        int                     bad_dir;
@@ -459,7 +459,8 @@ static int check_dotdot(e2fsck_t ctx,
  */
 static int check_name(e2fsck_t ctx,
                      struct ext2_dir_entry *dirent,
-                     ext2_ino_t dir_ino, struct problem_context *pctx)
+                     ext2_ino_t dir_ino EXT2FS_ATTR((unused)), 
+                     struct problem_context *pctx)
 {
        int     i;
        int     fixup = -1;
@@ -483,8 +484,9 @@ static int check_name(e2fsck_t ctx,
  * Check the directory filetype (if present)
  */
 static _INLINE_ int check_filetype(e2fsck_t ctx,
-                     struct ext2_dir_entry *dirent,
-                     ext2_ino_t dir_ino, struct problem_context *pctx)
+                                  struct ext2_dir_entry *dirent,
+                                  ext2_ino_t dir_ino EXT2FS_ATTR((unused)),
+                                  struct problem_context *pctx)
 {
        int     filetype = dirent->name_len >> 8;
        int     should_be = EXT2_FT_UNKNOWN;
@@ -591,7 +593,7 @@ static void parse_int_node(ext2_filsys fs,
 #endif
                blk = ext2fs_le32_to_cpu(ent[i].block) & 0x0ffffff;
                /* Check to make sure the block is valid */
-               if (blk > dx_dir->numblocks) {
+               if (blk > (blk_t) dx_dir->numblocks) {
                        cd->pctx.blk = blk;
                        if (fix_problem(cd->ctx, PR_2_HTREE_BADBLK,
                                        &cd->pctx))
@@ -644,7 +646,7 @@ clear_and_exit:
 static void salvage_directory(ext2_filsys fs,
                              struct ext2_dir_entry *dirent,
                              struct ext2_dir_entry *prev,
-                             int *offset)
+                             unsigned int *offset)
 {
        char    *cp = (char *) dirent;
        int left = fs->blocksize - *offset - dirent->rec_len;
@@ -708,7 +710,7 @@ static int check_dir_block(ext2_filsys fs,
 #endif /* ENABLE_HTREE */
        struct ext2_dir_entry   *dirent, *prev;
        ext2_dirhash_t          hash;
-       int                     offset = 0;
+       unsigned int            offset = 0;
        int                     dir_modified = 0;
        int                     dot_state;
        blk_t                   block_nr = db->blk;
@@ -1071,9 +1073,9 @@ abort_free_dict:
  */
 static int deallocate_inode_block(ext2_filsys fs,
                                  blk_t *block_nr,
-                                 e2_blkcnt_t blockcnt,
-                                 blk_t ref_block,
-                                 int ref_offset
+                                 e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)),
+                                 blk_t ref_block EXT2FS_ATTR((unused)),
+                                 int ref_offset EXT2FS_ATTR((unused)),
                                  void *priv_data)
 {
        e2fsck_t        ctx = (e2fsck_t) priv_data;
@@ -1287,7 +1289,8 @@ extern int e2fsck_process_bad_inode(e2fsck_t ctx, ext2_ino_t dir,
  */
 static int allocate_dir_block(e2fsck_t ctx,
                              struct ext2_db_entry *db,
-                             char *buf, struct problem_context *pctx)
+                             char *buf EXT2FS_ATTR((unused)), 
+                             struct problem_context *pctx)
 {
        ext2_filsys fs = ctx->fs;
        blk_t                   blk;
@@ -1366,11 +1369,11 @@ static int allocate_dir_block(e2fsck_t ctx,
 /*
  * This is a helper function for allocate_dir_block().
  */
-static int update_dir_block(ext2_filsys fs,
+static int update_dir_block(ext2_filsys fs EXT2FS_ATTR((unused)),
                            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 ext2_db_entry *db;
index bafcb4c..e2bdd54 100644 (file)
@@ -611,9 +611,9 @@ struct fix_dotdot_struct {
 };
 
 static int fix_dotdot_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 fix_dotdot_struct *fp = (struct fix_dotdot_struct *) priv_data;
@@ -691,8 +691,8 @@ struct expand_dir_struct {
 static int expand_dir_proc(ext2_filsys fs,
                           blk_t        *blocknr,
                           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 expand_dir_struct *es = (struct expand_dir_struct *) priv_data;
index 862b7e0..e708fa4 100644 (file)
@@ -114,8 +114,8 @@ static void check_block_bitmaps(e2fsck_t ctx)
        blk_t   i;
        int     *free_array;
        int     group = 0;
-       int     blocks = 0;
-       int     free_blocks = 0;
+       unsigned int    blocks = 0;
+       unsigned int    free_blocks = 0;
        int     group_free = 0;
        int     actual, bitmap;
        struct problem_context  pctx;
@@ -275,17 +275,17 @@ static void check_inode_bitmaps(e2fsck_t ctx)
 {
        ext2_filsys fs = ctx->fs;
        ext2_ino_t      i;
-       int     free_inodes = 0;
-       int     group_free = 0;
-       int     dirs_count = 0;
-       int     group = 0;
-       int     inodes = 0;
-       int     *free_array;
-       int     *dir_array;
-       int     actual, bitmap;
+       unsigned int    free_inodes = 0;
+       int             group_free = 0;
+       int             dirs_count = 0;
+       int             group = 0;
+       unsigned int    inodes = 0;
+       int             *free_array;
+       int             *dir_array;
+       int             actual, bitmap;
        errcode_t       retval;
        struct problem_context  pctx;
-       int     problem, save_problem, fixit, had_problem;
+       int             problem, save_problem, fixit, had_problem;
        
        clear_problem_context(&pctx);
        free_array = (int *) e2fsck_allocate_memory(ctx,
index a164bb5..9f0b561 100644 (file)
@@ -1440,7 +1440,7 @@ static struct latch_descr pr_latch_info[] = {
        { -1, 0, 0 },
 };
 
-static const struct e2fsck_problem *find_problem(int code)
+static const struct e2fsck_problem *find_problem(problem_t code)
 {
        int     i;
 
index c6b0b02..727e08c 100644 (file)
@@ -79,15 +79,15 @@ struct out_dir {
 static int fill_dir_block(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 fill_dir_struct  *fd = (struct fill_dir_struct *) priv_data;
        struct hash_entry       *new_array, *ent;
        struct ext2_dir_entry   *dirent;
        char                    *dir;
-       int                     offset, dir_offset;
+       unsigned int            offset, dir_offset;
        
        if (blockcnt < 0)
                return 0;
@@ -589,8 +589,8 @@ struct write_dir_struct {
 static int write_dir_block(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 write_dir_struct *wd = (struct write_dir_struct *) priv_data;
index b6c5e74..9a1ab4c 100644 (file)
@@ -60,7 +60,7 @@ struct process_block_struct {
        struct problem_context *pctx;
        int             truncating;
        int             truncate_offset;
-       blk_t           truncate_block;
+       e2_blkcnt_t     truncate_block;
        int             truncated_blocks;
        int             abort;
        errcode_t       errcode;
@@ -68,7 +68,9 @@ struct process_block_struct {
 
 static int release_inode_block(ext2_filsys fs,
                               blk_t    *block_nr,
-                              int blockcnt,
+                              e2_blkcnt_t blockcnt,
+                              blk_t    ref_blk EXT2FS_ATTR((unused)),
+                              int      ref_offset EXT2FS_ATTR((unused)),
                               void *priv_data)
 {
        struct process_block_struct *pb;
@@ -180,7 +182,7 @@ static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino,
        pb.pctx = pctx;
        if (inode->i_links_count) {
                pb.truncating = 1;
-               pb.truncate_block = (blk_t)
+               pb.truncate_block = (e2_blkcnt_t)
                        ((((long long)inode->i_size_high << 32) +
                          inode->i_size + fs->blocksize - 1) /
                         fs->blocksize);
@@ -191,7 +193,7 @@ static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino,
                pb.truncate_offset = 0;
        }
        pb.truncated_blocks = 0;
-       retval = ext2fs_block_iterate(fs, ino, BLOCK_FLAG_DEPTH_TRAVERSE, 
+       retval = ext2fs_block_iterate2(fs, ino, BLOCK_FLAG_DEPTH_TRAVERSE, 
                                      block_buf, release_inode_block, &pb);
        if (retval) {
                com_err("release_inode_blocks", retval,
@@ -384,7 +386,7 @@ void check_super_block(e2fsck_t ctx)
                }
        }
 
-       if (sb->s_log_block_size != sb->s_log_frag_size) {
+       if (sb->s_log_block_size != (__u32) sb->s_log_frag_size) {
                pctx.blk = EXT2_BLOCK_SIZE(sb);
                pctx.blk2 = EXT2_FRAG_SIZE(sb);
                fix_problem(ctx, PR_0_NO_FRAGMENTS, &pctx);
index 8e9a134..3e7609b 100644 (file)
@@ -110,7 +110,8 @@ static void swap_inode_blocks(e2fsck_t ctx, ext2_ino_t ino, char *block_buf,
 static void swap_inodes(e2fsck_t ctx)
 {
        ext2_filsys fs = ctx->fs;
-       int                     i, group;
+       dgrp_t                  group;
+       unsigned int            i;
        ext2_ino_t              ino = 1;
        char                    *buf, *block_buf;
        errcode_t               retval;
index 91511bf..4c2598f 100644 (file)
@@ -199,7 +199,7 @@ static void check_mount(e2fsck_t ctx)
        return;
 }
 
-static int is_on_batt()
+static int is_on_batt(void)
 {
        FILE    *f;
        char    tmp[80], tmp2[80];
@@ -254,12 +254,12 @@ static void check_if_skip(e2fsck_t ctx)
                             (unsigned) fs->super->s_max_mnt_count*2))
                        reason = 0;
        } else if (fs->super->s_checkinterval &&
-                now >= (fs->super->s_lastcheck +
-                            fs->super->s_checkinterval)) {
+                  ((now - fs->super->s_lastcheck) >= 
+                   fs->super->s_checkinterval)) {
                reason = _(" has gone %u days without being checked");
                reason_arg = (now - fs->super->s_lastcheck)/(3600*24);
-               if (batt && (now < (fs->super->s_lastcheck +
-                                   fs->super->s_checkinterval*2)))
+               if (batt && ((now - fs->super->s_lastcheck) < 
+                            fs->super->s_checkinterval*2))
                        reason = 0;
        }
        if (reason) {
@@ -279,13 +279,13 @@ static void check_if_skip(e2fsck_t ctx)
                if (next_check <= 0) 
                        next_check = 1;
        }
-       if (now >= (fs->super->s_lastcheck + fs->super->s_checkinterval))
+       if ((now - fs->super->s_lastcheck) >= fs->super->s_checkinterval)
                next_check = 1;
        if (next_check <= 5) {
                if (next_check == 1)
                        fputs(_(" (check after next mount)"), stdout);
                else
-                       printf(_(" (check in %d mounts)"), next_check);
+                       printf(_(" (check in %ld mounts)"), next_check);
        }
        fputc('\n', stdout);
        ext2fs_close(fs);
@@ -336,7 +336,7 @@ int e2fsck_simple_progress(e2fsck_t ctx, const char *label, float percent,
 {
        static const char spinner[] = "\\|/-";
        int     i;
-       int     tick;
+       unsigned int    tick;
        struct timeval  tv;
        int dpywidth;
 
@@ -437,7 +437,7 @@ static void reserve_stdio_fds(void)
 }
 
 #ifdef HAVE_SIGNAL_H
-static void signal_progress_on(int sig)
+static void signal_progress_on(int sig EXT2FS_ATTR((unused)))
 {
        e2fsck_t ctx = e2fsck_global_ctx;
 
@@ -448,7 +448,7 @@ static void signal_progress_on(int sig)
        ctx->progress_fd = 0;
 }
 
-static void signal_progress_off(int sig)
+static void signal_progress_off(int sig EXT2FS_ATTR((unused)))
 {
        e2fsck_t ctx = e2fsck_global_ctx;
 
@@ -459,7 +459,7 @@ static void signal_progress_off(int sig)
        ctx->progress = 0;
 }
 
-static void signal_cancel(int sig)
+static void signal_cancel(int sig EXT2FS_ATTR((unused)))
 {
        e2fsck_t ctx = e2fsck_global_ctx;
 
index 8bb538d..569fc58 100644 (file)
@@ -70,7 +70,8 @@ void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned int size,
        return ret;
 }
 
-char *string_copy(e2fsck_t ctx, const char *str, int len)
+char *string_copy(e2fsck_t ctx EXT2FS_ATTR((unused)), 
+                 const char *str, int len)
 {
        char    *ret;
        
index eebbf15..f6d3bb1 100644 (file)
@@ -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
index 1ab29c5..7d90b5e 100644 (file)
 
 #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).
index 505400c..5b74c31 100644 (file)
@@ -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) */
index b07cf79..0a8e3f3 100644 (file)
@@ -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)) {
index 377f594..586abc1 100644 (file)
@@ -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
index 3356006..7385123 100644 (file)
@@ -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;
index f601787..dd8e7c3 100644 (file)
@@ -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;
index e27c5a0..886eb5e 100644 (file)
@@ -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
 }
 
index 338b918..f64c0af 100644 (file)
@@ -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;
 
index 902c4b6..2a754c7 100644 (file)
@@ -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;
 
index 56be292..1256385 100644 (file)
@@ -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 +
index 9a6ac91..003c0a3 100644 (file)
@@ -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,
index 0cb07c7..ebfc72c 100644 (file)
@@ -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;
index 3c2c803..10a5149 100644 (file)
@@ -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;
index d0bd280..92f273e 100644 (file)
 #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;
index a8449c6..23f593f 100644 (file)
@@ -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;
index e08b335..5997792 100644 (file)
@@ -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);
index b72a9fb..596fbbe 100644 (file)
@@ -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) {
index d1cb750..74f20a7 100644 (file)
@@ -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)) {
index d80f6c0..50420b7 100644 (file)
@@ -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 {
index c8dc5af..30ad1ef 100644 (file)
@@ -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;
index af9fdd1..1745f33 100644 (file)
@@ -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;
index abf162e..427a08e 100644 (file)
@@ -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 */
index 7dd5737..bc7c5bb 100644 (file)
@@ -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;
index d0f3139..c717adc 100644 (file)
@@ -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;
        
index f671b92..40c34ee 100644 (file)
@@ -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);
 
index 2c5f397..ff3dd59 100644 (file)
@@ -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);
index 2c732e9..5b2f364 100644 (file)
@@ -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;
index 03825c4..5612b3d 100644 (file)
@@ -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;
index 011c480..269b576 100644 (file)
@@ -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;
index 25e84e1..dbe8a05 100644 (file)
@@ -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
index b1fc5ed..770f5f0 100644 (file)
 
 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]) {
index 784af44..05d0dc0 100644 (file)
@@ -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)
index 7f1805d..8013368 100644 (file)
@@ -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, "");
 }
index 90a268a..6cc050b 100644 (file)
 #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);
index 03e6cc1..74ab9ed 100644 (file)
@@ -1,3 +1,9 @@
+2003-12-07  Theodore Ts'o  <tytso@mit.edu>
+
+       * badblocks.c, blkid.c, chattr.c, dumpe2fs.c, e2image.c, fsck.c,
+               fsck.h, lsattr.c, mke2fs.c, nls-enable.h, tune2fs.c,
+               util.c: Fix gcc -Wall nitpicks.
+
 2003-09-13  Theodore Ts'o  <tytso@mit.edu>
  
         * tune2fs.c (parse_e2label_options, parse_tune2fs_options,
index aae4842..2c5e17e 100644 (file)
@@ -146,7 +146,7 @@ static void print_status(void)
        fflush (stderr);
 }
 
-static void alarm_intr(int alnum)
+static void alarm_intr(int alnum EXT2FS_ATTR((unused)))
 {
        signal (SIGALRM, alarm_intr);
        alarm(1);
@@ -159,7 +159,7 @@ static void alarm_intr(int alnum)
 
 static void *terminate_addr = NULL;
 
-static void terminate_intr(int signo)
+static void terminate_intr(int signo EXT2FS_ATTR((unused)))
 {
        if (terminate_addr)
                longjmp(terminate_addr,1);
@@ -216,15 +216,15 @@ static void set_o_direct(int dev, unsigned char *buffer, size_t size,
 static void pattern_fill(unsigned char *buffer, unsigned long pattern,
                         size_t n)
 {
-       int     i, nb;
+       unsigned int    i, nb;
        unsigned char   bpattern[sizeof(pattern)], *ptr;
        
-       if (pattern == ~0) {
+       if (pattern == (unsigned char) ~0) {
                for (ptr = buffer; ptr < buffer + n; ptr++) {
                        (*ptr) = random() % (1 << (8 * sizeof(char)));
                }
                if (s_flag | v_flag)
-                       fprintf(stderr, _("Testing with random pattern: "));
+                       fputs(_("Testing with random pattern: "), stderr);
        } else {
                bpattern[0] = 0;
                for (i = 0; i < sizeof(bpattern); i++) {
@@ -235,15 +235,17 @@ static void pattern_fill(unsigned char *buffer, unsigned long pattern,
                }
                nb = i ? (i-1) : 0;
                for (ptr = buffer, i = nb; ptr < buffer + n; ptr++) {
-                       *ptr = bpattern[i--];
-                       if (i < 0)
+                       *ptr = bpattern[i];
+                       if (i == 0)
                                i = nb;
+                       else
+                               i--;
                }
                if (s_flag | v_flag) {
-                       fprintf(stderr, _("Testing with pattern 0x"));
+                       fputs(_("Testing with pattern 0x"), stderr);
                        for (i = 0; i <= nb; i++)
                                fprintf(stderr, "%02x", buffer[i]);
-                       fprintf(stderr, ": ");
+                       fputs(": ", stderr);
                }
        }
 }
@@ -301,8 +303,7 @@ static long do_write (int dev, unsigned char * buffer, int try, int block_size,
        if (got < 0)
                got = 0;        
        if (got & 511)
-               fprintf (stderr,
-                        "Weird value (%ld) in do_write\n", got);
+               fprintf(stderr, "Weird value (%ld) in do_write\n", got);
        got /= block_size;
        return got;
 }
@@ -353,7 +354,7 @@ static unsigned int test_ro (int dev, unsigned long last_block,
                     last_block);
        }
        if (t_flag) {
-               fprintf(stderr, _("Checking for bad blocks in read-only mode\n"));
+               fputs(_("Checking for bad blocks in read-only mode\n"), stderr);
                pattern_fill(blkbuf + blocks_at_once * block_size,
                             t_patts[0], block_size);
        }
@@ -362,8 +363,7 @@ static unsigned int test_ro (int dev, unsigned long last_block,
        currently_testing = from_count;
        num_blocks = last_block;
        if (!t_flag && (s_flag || v_flag)) {
-               fprintf(stderr,
-                       _("Checking for bad blocks (read-only test): "));
+               fputs(_("Checking for bad blocks (read-only test): "), stderr);
                if (v_flag <= 1)
                        alarm_intr(SIGALRM);
        }
@@ -396,7 +396,7 @@ static unsigned int test_ro (int dev, unsigned long last_block,
                if (got == try) {
                        try = blocks_at_once;
                        /* recover page-aligned offset for O_DIRECT */
-                       if ( blocks_at_once >= (sys_page_size >> 9)
+                       if ( blocks_at_once >= (unsigned long) (sys_page_size >> 9)
                             && (currently_testing % (sys_page_size >> 9)!= 0))
                                try -= (sys_page_size >> 9)
                                        - (currently_testing 
@@ -443,8 +443,8 @@ static unsigned int test_rw (int dev, unsigned long last_block,
        flush_bufs();
 
        if (v_flag) {
-               fprintf(stderr,
-                       _("Checking for bad blocks in read-write mode\n"));
+               fputs(_("Checking for bad blocks in read-write mode\n"), 
+                     stderr);
                fprintf(stderr, _("From block %lu to %lu\n"),
                         from_count, last_block);
        }
@@ -476,7 +476,7 @@ static unsigned int test_rw (int dev, unsigned long last_block,
                        if (got == try) {
                                try = blocks_at_once;
                                /* recover page-aligned offset for O_DIRECT */
-                               if ( blocks_at_once >= (sys_page_size >> 9)
+                               if ( blocks_at_once >= (unsigned long) (sys_page_size >> 9)
                                     && (currently_testing % 
                                         (sys_page_size >> 9)!= 0))
                                        try -= (sys_page_size >> 9)
@@ -496,7 +496,7 @@ static unsigned int test_rw (int dev, unsigned long last_block,
                        fputs(done_string, stderr);
                flush_bufs();
                if (s_flag | v_flag)
-                       fprintf (stderr, _("Reading and comparing: "));
+                       fputs(_("Reading and comparing: "), stderr);
                num_blocks = last_block;
                currently_testing = from_count;
                if (s_flag && v_flag <= 1)
@@ -520,7 +520,7 @@ static unsigned int test_rw (int dev, unsigned long last_block,
                        }
                        currently_testing += got;
                        /* recover page-aligned offset for O_DIRECT */
-                       if ( blocks_at_once >= (sys_page_size >> 9)
+                       if ( blocks_at_once >= (unsigned long) (sys_page_size >> 9)
                             && (currently_testing % (sys_page_size >> 9)!= 0))
                                try = blocks_at_once - (sys_page_size >> 9)
                                        - (currently_testing 
@@ -563,9 +563,10 @@ static unsigned int test_nd (int dev, unsigned long last_block,
        static int num_saved;
        jmp_buf terminate_env;
        errcode_t errcode;
-       long buf_used;
-       unsigned int bb_count = 0;
+       unsigned long buf_used;
+       static unsigned int bb_count;
 
+       bb_count = 0;
        errcode = ext2fs_badblocks_list_iterate_begin(bb_list,&bb_iter);
        if (errcode) {
                com_err (program_name, errcode,
@@ -591,19 +592,18 @@ static unsigned int test_nd (int dev, unsigned long last_block,
 
        flush_bufs();
        if (v_flag) {
-           fprintf (stderr,
-                    _("Checking for bad blocks in non-destructive read-write mode\n"));
+           fputs(_("Checking for bad blocks in non-destructive read-write mode\n"), stderr);
            fprintf (stderr, _("From block %lu to %lu\n"), from_count, last_block);
        }
        if (s_flag || v_flag > 1) {
-               fprintf(stderr, _("Checking for bad blocks (non-destructive read-write test)\n"));
+               fputs(_("Checking for bad blocks (non-destructive read-write test)\n"), stderr);
        }
        if (setjmp(terminate_env)) {
                /*
                 * Abnormal termination by a signal is handled here.
                 */
                signal (SIGALRM, SIG_IGN);
-               fprintf(stderr, _("\nInterrupt caught, cleaning up\n"));
+               fputs(_("\nInterrupt caught, cleaning up\n"), stderr);
 
                save_ptr = save_base;
                for (i=0; i < num_saved; i++) {
@@ -787,11 +787,11 @@ static void check_mount(char *device_name)
 
        fprintf(stderr, _("%s is mounted; "), device_name);
        if (force) {
-               fprintf(stderr, _("badblocks forced anyway.  "
-                       "Hope /etc/mtab is incorrect.\n"));
+               fputs(_("badblocks forced anyway.  "
+                       "Hope /etc/mtab is incorrect.\n"), stderr);
                return;
        }
-       fprintf(stderr, _("it's not safe to run badblocks!\n"));
+       fputs(_("it's not safe to run badblocks!\n"), stderr);
        exit(1);
 }
 
@@ -925,7 +925,7 @@ int main (int argc, char ** argv)
                                                optarg);
                                        exit(1);
                                }
-                               if (pattern == ~0)
+                               if (pattern == (unsigned long) ~0)
                                        pattern = 0xffff;
                                t_patts[t_flag++] = pattern;
                        }
@@ -941,7 +941,7 @@ int main (int argc, char ** argv)
                          "in read-only mode"));
                        exit(1);
                }
-               if (t_patts && (t_patts[0] == ~0)) {
+               if (t_patts && (t_patts[0] == (unsigned long) ~0)) {
                        com_err(program_name, 0,
                        _("Random test_pattern is not allowed "
                          "in read-only mode"));
@@ -985,7 +985,7 @@ int main (int argc, char ** argv)
        } else from_count = 0;
        if (from_count >= last_block) {
            com_err (program_name, 0, _("bad blocks range: %lu-%lu"),
-                    from_count, last_block);
+                    (unsigned long) from_count, (unsigned long) last_block);
            exit (1);
        }
        if (w_flag)
index 2b71a56..9caebbd 100644 (file)
@@ -25,7 +25,7 @@ const char *progname = "blkid";
 
 static void print_version(FILE *out)
 {
-       fprintf(stderr, "%s %s (%s)\n", progname, BLKID_VERSION, BLKID_DATE);
+       fprintf(out, "%s %s (%s)\n", progname, BLKID_VERSION, BLKID_DATE);
 }
 
 static void usage(int error)
@@ -85,10 +85,10 @@ int main(int argc, char **argv)
        char *search_type = NULL, *search_value = NULL;
        char *read = NULL;
        char *write = NULL;
-       int numdev = 0, numtag = 0;
+       unsigned int numdev = 0, numtag = 0;
        int version = 0;
        int err = 4;
-       int i;
+       unsigned int i;
        char c;
 
        while ((c = getopt (argc, argv, "c:f:hps:t:w:v")) != EOF)
index 4ff1564..b4b1ca3 100644 (file)
 #include <sys/stat.h>
 #include "ext2fs/ext2_fs.h"
 
+#ifdef __GNUC__
+#define EXT2FS_ATTR(x) __attribute__(x)
+#else
+#define EXT2FS_ATTR(x)
+#endif
+
 #ifndef S_ISLNK                        /* So we can compile even with gcc-warn */
 # ifdef __S_IFLNK
 #  define S_ISLNK(mode)         __S_ISTYPE((mode), __S_IFLNK)
@@ -239,7 +245,7 @@ static void change_attributes (const char * name)
 }
 
 static int chattr_dir_proc (const char * dir_name, struct dirent * de,
-                           void * unused_private)
+                           void * private EXT2FS_ATTR((unused)))
 {
        if (strcmp (de->d_name, ".") && strcmp (de->d_name, "..")) {
                char *path;
@@ -278,15 +284,15 @@ int main (int argc, char ** argv)
        if (i >= argc)
                usage ();
        if (set && (add || rem)) {
-               fprintf (stderr, _("= is incompatible with - and +\n"));
+               fputs(_("= is incompatible with - and +\n"), stderr);
                exit (1);
        }
        if ((rf & af) != 0) {
-               fprintf (stderr, "Can't both set and unset same flag.\n");
+               fputs("Can't both set and unset same flag.\n", stderr);
                exit (1);
        }
        if (!(add || rem || set || set_version)) {
-               fprintf (stderr, _("Must use '-v', =, - or +\n"));
+               fputs(_("Must use '-v', =, - or +\n"), stderr);
                exit (1);
        }
        if (verbose)
index d04fe16..da8fdfa 100644 (file)
@@ -56,6 +56,11 @@ static void usage(void)
        exit (1);
 }
 
+static void print_number (unsigned long num)
+{
+       printf(num_format, num);
+}
+
 static void print_free (unsigned long group, char * bitmap,
                        unsigned long nbytes, unsigned long offset)
 {
@@ -69,12 +74,12 @@ static void print_free (unsigned long group, char * bitmap,
                {
                        if (p)
                                printf (", ");
-                       printf (num_format, i + offset);
+                       print_number(i + offset);
                        for (j = i; j < nbytes && !in_use (bitmap, j); j++)
                                ;
                        if (--j != i) {
                                fputc('-', stdout);
-                               printf(num_format, j + offset);
+                               print_number(j + offset);
                                i = j;
                        }
                        p = 1;
@@ -119,7 +124,7 @@ static void list_desc (ext2_filsys fs)
                if (has_super) {
                        printf (_("  %s superblock at "),
                                i == 0 ? _("Primary") : _("Backup"));
-                       printf(num_format, super_blk);
+                       print_number(super_blk);
                }
                if (old_desc_blk) {
                        printf(_(", Group descriptors at "));
@@ -128,18 +133,18 @@ static void list_desc (ext2_filsys fs)
                } else if (new_desc_blk) {
                        fputc(has_super ? ',' : ' ', stdout);
                        printf(_(" Group descriptor at "));
-                       printf(num_format, new_desc_blk);
+                       print_number(new_desc_blk);
                        has_super++;
                }
                if (has_super)
                        fputc('\n', stdout);
                fputs(_("  Block bitmap at "), stdout);
-               printf(num_format, fs->group_desc[i].bg_block_bitmap);
+               print_number(fs->group_desc[i].bg_block_bitmap);
                diff = fs->group_desc[i].bg_block_bitmap - group_blk;
                if (diff >= 0)
                        printf(" (+%ld)", diff);
                fputs(_(", Inode bitmap at "), stdout);
-               printf(num_format, fs->group_desc[i].bg_inode_bitmap);
+               print_number(fs->group_desc[i].bg_inode_bitmap);
                diff = fs->group_desc[i].bg_inode_bitmap - group_blk;
                if (diff >= 0)
                        printf(" (+%ld)", diff);
@@ -213,7 +218,7 @@ static void print_journal_information(ext2_filsys fs)
        errcode_t       retval;
        char            buf[1024];
        char            str[80];
-       int             i;
+       unsigned int    i;
        journal_superblock_t    *jsb;
 
        /* Get the journal superblock */
index 1cb2a1d..c6d9dcf 100644 (file)
@@ -58,7 +58,7 @@ static void write_header(int fd, struct ext2_image_hdr *hdr, int blocksize)
 
        header_buf = malloc(blocksize);
        if (!header_buf) {
-               fprintf(stderr, _("Couldn't allocate header buffer\n"));
+               fputs(_("Couldn't allocate header buffer\n"), stderr);
                exit(1);
        }
 
@@ -160,8 +160,9 @@ struct process_block_struct {
 static ino_t stashed_ino = 0;
 static struct ext2_inode *stashed_inode;
 
-static errcode_t meta_get_blocks(ext2_filsys fs, ext2_ino_t ino,
-                                 blk_t *blocks)
+static errcode_t meta_get_blocks(ext2_filsys fs EXT2FS_ATTR((unused)), 
+                                ext2_ino_t ino,
+                                blk_t *blocks)
 {
        int     i;
        
@@ -173,7 +174,8 @@ static errcode_t meta_get_blocks(ext2_filsys fs, ext2_ino_t ino,
        return 0;
 }
 
-static errcode_t meta_check_directory(ext2_filsys fs, ext2_ino_t ino)
+static errcode_t meta_check_directory(ext2_filsys fs EXT2FS_ATTR((unused)), 
+                                     ext2_ino_t ino)
 {
        if ((ino != stashed_ino) || !stashed_inode)
                return EXT2_ET_CALLBACK_NOTHANDLED;
@@ -183,7 +185,8 @@ static errcode_t meta_check_directory(ext2_filsys fs, ext2_ino_t ino)
        return 0;
 }
 
-static errcode_t meta_read_inode(ext2_filsys fs, ext2_ino_t ino,
+static errcode_t meta_read_inode(ext2_filsys fs EXT2FS_ATTR((unused)), 
+                                ext2_ino_t ino,
                                 struct ext2_inode *inode)
 {
        if ((ino != stashed_ino) || !stashed_inode)
@@ -206,17 +209,23 @@ static void use_inode_shortcuts(ext2_filsys fs, int bool)
        }
 }
 
-static int process_dir_block(ext2_filsys fs, blk_t *block_nr,
-                            e2_blkcnt_t blockcnt, blk_t ref_block,
-                            int ref_offset, void *priv_data)
+static int process_dir_block(ext2_filsys fs EXT2FS_ATTR((unused)), 
+                            blk_t *block_nr,
+                            e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)), 
+                            blk_t ref_block EXT2FS_ATTR((unused)),
+                            int ref_offset EXT2FS_ATTR((unused)), 
+                            void *priv_data EXT2FS_ATTR((unused)))
 {
        ext2fs_mark_block_bitmap(meta_block_map, *block_nr);
        return 0;
 }
 
-static int process_file_block(ext2_filsys fs, blk_t *block_nr,
-                            e2_blkcnt_t blockcnt, blk_t ref_block,
-                            int ref_offset, void *priv_data)
+static int process_file_block(ext2_filsys fs EXT2FS_ATTR((unused)), 
+                             blk_t *block_nr,
+                             e2_blkcnt_t blockcnt, 
+                             blk_t ref_block EXT2FS_ATTR((unused)),
+                             int ref_offset EXT2FS_ATTR((unused)), 
+                             void *priv_data EXT2FS_ATTR((unused)))
 {
        if (blockcnt < 0) {
                ext2fs_mark_block_bitmap(meta_block_map, *block_nr);
@@ -227,7 +236,7 @@ static int process_file_block(ext2_filsys fs, blk_t *block_nr,
 static void mark_table_blocks(ext2_filsys fs)
 {
        blk_t   block, b;
-       int     i,j;
+       unsigned int    i,j;
        
        block = fs->super->s_first_data_block;
        /*
@@ -249,7 +258,7 @@ static void mark_table_blocks(ext2_filsys fs)
                 */
                if (fs->group_desc[i].bg_inode_table) {
                        for (j = 0, b = fs->group_desc[i].bg_inode_table;
-                            j < fs->inode_blocks_per_group;
+                            j < (unsigned) fs->inode_blocks_per_group;
                             j++, b++)
                                ext2fs_mark_block_bitmap(meta_block_map, b);
                }
@@ -476,7 +485,7 @@ int main (int argc, char ** argv)
         if (retval) {
                com_err (program_name, retval, _("while trying to open %s"),
                         device_name);
-               printf(_("Couldn't find valid filesystem superblock.\n"));
+               fputs(_("Couldn't find valid filesystem superblock.\n"), stdout);
                exit(1);
        }
 
index 28bd7a2..bebf5ee 100644 (file)
@@ -353,10 +353,10 @@ static void load_fs_info(const char *filename)
        fclose(f);
        
        if (old_fstab) {
-               fprintf(stderr, _("\007\007\007"
+               fputs(_("\007\007\007"
                "WARNING: Your /etc/fstab does not contain the fsck passno\n"
                "       field.  I will kludge around things for you, but you\n"
-               "       should fix your /etc/fstab file as soon as you can.\n\n"));
+               "       should fix your /etc/fstab file as soon as you can.\n\n"), stderr);
                
                for (fs = filesys_info; fs; fs = fs->next) {
                        fs->passno = 1;
@@ -729,8 +729,8 @@ static void compile_fs_type(char *fs_type, struct fs_type_compile *cmp)
        cmp->list = malloc(num * sizeof(char *));
        cmp->type = malloc(num * sizeof(int));
        if (!cmp->list || !cmp->type) {
-               fprintf(stderr, _("Couldn't allocate memory for "
-                                 "filesystem types\n"));
+               fputs(_("Couldn't allocate memory for filesystem types\n"), 
+                     stderr);
                exit(EXIT_ERROR);
        }
        memset(cmp->list, 0, num * sizeof(char *));
@@ -766,7 +766,7 @@ static void compile_fs_type(char *fs_type, struct fs_type_compile *cmp)
                        }
                        if ((negate && !cmp->negate) ||
                            (!negate && cmp->negate)) {
-                               fprintf(stderr, _(fs_type_syntax_error));
+                               fputs(_(fs_type_syntax_error), stderr);
                                exit(EXIT_USAGE);
                        }
                }
@@ -925,7 +925,7 @@ static int check_all(NOARGS)
        int pass_done;
 
        if (verbose)
-               printf(_("Checking all file systems.\n"));
+               fputs(_("Checking all file systems.\n"), stdout);
 
        /*
         * Do an initial scan over the filesystem; mark filesystems
@@ -1031,13 +1031,12 @@ static int check_all(NOARGS)
 
 static void usage(NOARGS)
 {
-       fprintf(stderr,
-               _("Usage: fsck [-ACNPRTV] [-t fstype] [fs-options] [filesys ...]\n"));
+       fputs(_("Usage: fsck [-ACNPRTV] [-t fstype] [fs-options] [filesys ...]\n"), stderr);
        exit(EXIT_USAGE);
 }
 
 #ifdef HAVE_SIGNAL_H
-static void signal_cancel(int sig)
+static void signal_cancel(int sig FSCK_ATTR((unused)))
 {
        cancel_requested++;
 }
index 56afcf9..55cb525 100644 (file)
 #define const
 #endif
 
+#ifdef __GNUC__
+#define FSCK_ATTR(x) __attribute__(x)
+#else
+#define FSCK_ATTR(x)
+#endif
+
+
 #ifndef DEFAULT_FSTYPE
 #define DEFAULT_FSTYPE "ext2"
 #endif
index 513b41a..ff3859f 100644 (file)
@@ -45,6 +45,12 @@ extern char *optarg;
 #include "../version.h"
 #include "nls-enable.h"
 
+#ifdef __GNUC__
+#define EXT2FS_ATTR(x) __attribute__(x)
+#else
+#define EXT2FS_ATTR(x)
+#endif
+
 static const char * program_name = "lsattr";
 
 static int all;
@@ -114,7 +120,8 @@ static void lsattr_args (const char * name)
        }
 }
 
-static int lsattr_dir_proc (const char * dir_name, struct dirent * de, void * private)
+static int lsattr_dir_proc (const char * dir_name, struct dirent * de, 
+                           void * private EXT2FS_ATTR((unused)))
 {
        STRUCT_STAT     st;
        char *path;
index 96f7b71..e225d00 100644 (file)
@@ -189,7 +189,7 @@ static void set_fs_defaults(const char *fs_type,
 /*
  * Helper function for read_bb_file and test_disk
  */
-static void invalid_block(ext2_filsys fs, blk_t blk)
+static void invalid_block(ext2_filsys fs EXT2FS_ATTR((unused)), blk_t blk)
 {
        fprintf(stderr, _("Bad block %u out of range; ignored.\n"), blk);
        return;
@@ -250,8 +250,9 @@ static void test_disk(ext2_filsys fs, badblocks_list *bb_list)
 
 static void handle_bad_blocks(ext2_filsys fs, badblocks_list bb_list)
 {
-       int                     i, j;
-       int                     must_be_good;
+       dgrp_t                  i;
+       blk_t                   j;
+       unsigned                must_be_good;
        blk_t                   blk;
        badblocks_iterate       bb_iter;
        errcode_t               retval;
@@ -274,7 +275,7 @@ static void handle_bad_blocks(ext2_filsys fs, badblocks_list bb_list)
                        fprintf(stderr, _("Blocks %d through %d must be good "
                                "in order to build a filesystem.\n"),
                                fs->super->s_first_data_block, must_be_good);
-                       fprintf(stderr, _("Aborting....\n"));
+                       fputs(_("Aborting....\n"), stderr);
                        exit(1);
                }
        }
@@ -346,7 +347,7 @@ static void progress_init(struct progress_struct *progress,
        sprintf(progress->format, "%%%dd/%%%dld", i, i);
        memset(progress->backup, '\b', sizeof(progress->backup)-1);
        progress->backup[sizeof(progress->backup)-1] = 0;
-       if ((2*i)+1 < sizeof(progress->backup))
+       if ((2*i)+1 < (int) sizeof(progress->backup))
                progress->backup[(2*i)+1] = 0;
        progress->max = max;
 
@@ -439,7 +440,8 @@ static void write_inode_tables(ext2_filsys fs)
 {
        errcode_t       retval;
        blk_t           blk;
-       int             i, num;
+       dgrp_t          i;
+       int             num;
        struct progress_struct progress;
 
        if (quiet)
@@ -655,7 +657,8 @@ static void show_stats(ext2_filsys fs)
        struct ext2_super_block *s = fs->super;
        char                    buf[80];
        blk_t                   group_block;
-       int                     i, need, col_left;
+       dgrp_t                  i;
+       int                     need, col_left;
        
        if (param.s_blocks_count != s->s_blocks_count)
                fprintf(stderr, _("warning: %d blocks unused.\n\n"),
@@ -664,12 +667,12 @@ static void show_stats(ext2_filsys fs)
        memset(buf, 0, sizeof(buf));
        strncpy(buf, s->s_volume_name, sizeof(s->s_volume_name));
        printf(_("Filesystem label=%s\n"), buf);
-       printf(_("OS type: "));
+       fputs(_("OS type: "), stdout);
        switch (fs->super->s_creator_os) {
-           case EXT2_OS_LINUX: printf ("Linux"); break;
-           case EXT2_OS_HURD:  printf ("GNU/Hurd");   break;
-           case EXT2_OS_MASIX: printf ("Masix"); break;
-           default:            printf (_("(unknown os)"));
+           case EXT2_OS_LINUX: fputs("Linux", stdout); break;
+           case EXT2_OS_HURD:  fputs("GNU/Hurd", stdout);   break;
+           case EXT2_OS_MASIX: fputs ("Masix", stdout); break;
+           default:            fputs(_("(unknown os)"), stdout);
         }
        printf("\n");
        printf(_("Block size=%u (log=%u)\n"), fs->blocksize,
@@ -1104,7 +1107,7 @@ static void PRS(int argc, char *argv[])
                                journal_device);
                        exit(1);
                }
-               if ((blocksize < 0) && (jfs->blocksize < -blocksize)) {
+               if ((blocksize < 0) && (jfs->blocksize < (unsigned) (-blocksize))) {
                        com_err(program_name, 0,
                                _("Journal dev blocksize (%d) smaller than "
                                  "minimum blocksize %d\n"), jfs->blocksize,
@@ -1219,7 +1222,7 @@ static void PRS(int argc, char *argv[])
                exit(1);
        }
 
-       if (tmp = getenv("MKE2FS_DEVICE_SECTSIZE"))
+       if ((tmp = getenv("MKE2FS_DEVICE_SECTSIZE")) != NULL)
                sector_size = atoi(tmp);
        
        set_fs_defaults(fs_type, &param, blocksize, sector_size, &inode_ratio);
@@ -1227,7 +1230,7 @@ static void PRS(int argc, char *argv[])
        
        if (param.s_blocks_per_group) {
                if (param.s_blocks_per_group < 256 ||
-                   param.s_blocks_per_group > 8 * blocksize) {
+                   param.s_blocks_per_group > 8 * (unsigned) blocksize) {
                        com_err(program_name, 0,
                                _("blocks per group count out of range"));
                        exit(1);
@@ -1271,7 +1274,8 @@ int main (int argc, char *argv[])
        ext2_filsys     fs;
        badblocks_list  bb_list = 0;
        int             journal_blocks;
-       int             i, val;
+       unsigned int    i;
+       int             val;
        io_manager      io_ptr;
 
 #ifdef ENABLE_NLS
@@ -1391,7 +1395,7 @@ int main (int argc, char *argv[])
                fs->flags &= ~(EXT2_FLAG_IB_DIRTY|EXT2_FLAG_BB_DIRTY);
        } else {
                /* rsv must be a power of two (64kB is MD RAID sb alignment) */
-               int rsv = 65536 / fs->blocksize;
+               unsigned int rsv = 65536 / fs->blocksize;
                unsigned long blocks = fs->super->s_blocks_count;
                unsigned long start;
                blk_t ret_blk;
index e365fbd..d6a7db3 100644 (file)
@@ -1,4 +1,5 @@
 #ifdef ENABLE_NLS
+#warning Using NLS
 #include <libintl.h>
 #include <locale.h>
 #define _(a) (gettext (a))
index f95aed4..d8c8e2e 100644 (file)
@@ -154,7 +154,7 @@ static void remove_journal_device(ext2_filsys fs)
        jsb = (journal_superblock_t *) buf;
        if ((jsb->s_header.h_magic != (unsigned) ntohl(JFS_MAGIC_NUMBER)) ||
            (jsb->s_header.h_blocktype != (unsigned) ntohl(JFS_SUPERBLOCK_V2))) {
-               fprintf(stderr, _("Journal superblock not found!\n"));
+               fputs(_("Journal superblock not found!\n"), stderr);
                goto no_valid_journal;
        }
 
@@ -166,8 +166,8 @@ static void remove_journal_device(ext2_filsys fs)
                        break;
        }
        if (i >= nr_users) {
-               fprintf(stderr,
-                       _("Filesystem's UUID not found on journal device.\n"));
+               fputs(_("Filesystem's UUID not found on journal device.\n"), 
+                     stderr);
                commit_remove_journal = 1;
                goto no_valid_journal;
        }
@@ -187,19 +187,20 @@ static void remove_journal_device(ext2_filsys fs)
 
 no_valid_journal:
        if (commit_remove_journal == 0) {
-               fprintf(stderr, _("Journal NOT removed\n"));
+               fputs(_("Journal NOT removed\n"), stderr);
                exit(1);
        }
        fs->super->s_journal_dev = 0;
        uuid_clear(fs->super->s_journal_uuid);
        ext2fs_mark_super_dirty(fs);
-       printf(_("Journal removed\n"));
+       fputs(_("Journal removed\n"), stdout);
        free(journal_path);
 }
 
 /* Helper function for remove_journal_inode */
 static int release_blocks_proc(ext2_filsys fs, blk_t *blocknr,
-                              int blockcnt, void *private)
+                              int blockcnt EXT2FS_ATTR((unused)), 
+                              void *private EXT2FS_ATTR((unused)))
 {
        blk_t   block;
        int     group;
@@ -305,19 +306,17 @@ static void update_feature_set(ext2_filsys fs, char *features)
        if (old_journal && !journal) {
                if ((mount_flags & EXT2_MF_MOUNTED) &&
                    !(mount_flags & EXT2_MF_READONLY)) {
-                       fprintf(stderr,
-                               _("The has_journal flag may only be "
-                                 "cleared when the filesystem is\n"
-                                 "unmounted or mounted "
-                                 "read-only.\n"));
+                       fputs(_("The has_journal flag may only be "
+                               "cleared when the filesystem is\n"
+                               "unmounted or mounted "
+                               "read-only.\n"), stderr);
                        exit(1);
                }
                if (sb->s_feature_incompat &
                    EXT3_FEATURE_INCOMPAT_RECOVER) {
-                       fprintf(stderr,
-                               _("The needs_recovery flag is set.  "
-                                 "Please run e2fsck before clearing\n"
-                                 "the has_journal flag.\n"));
+                       fputs(_("The needs_recovery flag is set.  "
+                               "Please run e2fsck before clearing\n"
+                               "the has_journal flag.\n"), stderr);
                        exit(1);
                }
                if (sb->s_journal_inum) {
@@ -369,7 +368,7 @@ static void add_journal(ext2_filsys fs)
 
        if (fs->super->s_feature_compat &
            EXT3_FEATURE_COMPAT_HAS_JOURNAL) {
-               fprintf(stderr, _("The filesystem already has a journal.\n"));
+               fputs(_("The filesystem already has a journal.\n"), stderr);
                goto err;
        }
        if (journal_device) {
@@ -402,9 +401,9 @@ static void add_journal(ext2_filsys fs)
                                 journal_device);
                        goto err;
                }
-               printf(_("done\n"));
+               fputs(_("done\n"), stdout);
        } else if (journal_size) {
-               printf(_("Creating journal inode: "));
+               fputs(_("Creating journal inode: "), stdout);
                fflush(stdout);
                journal_blocks = figure_journal_size(journal_size, fs);
 
@@ -416,7 +415,7 @@ static void add_journal(ext2_filsys fs)
                                _("\n\twhile trying to create journal file"));
                        exit(1);
                } else
-                       printf(_("done\n"));
+                       fputs(_("done\n"), stdout);
                /*
                 * If the filesystem wasn't mounted, we need to force
                 * the block group descriptors out.
@@ -437,7 +436,7 @@ err:
 static void parse_e2label_options(int argc, char ** argv)
 {
        if ((argc < 2) || (argc > 3)) {
-               fprintf(stderr, _("Usage: e2label device [newlabel]\n"));
+               fputs(_("Usage: e2label device [newlabel]\n"), stderr);
                exit(1);
        }
        device_name = blkid_get_devname(NULL, argv[1], NULL);
@@ -814,7 +813,7 @@ int main (int argc, char ** argv)
        if (r_flag) {
                if (reserved_blocks >= sb->s_blocks_count) {
                        com_err (program_name, 0,
-                                _("reserved blocks count is too big (%ul)"),
+                                _("reserved blocks count is too big (%lu)"),
                                 reserved_blocks);
                        exit (1);
                }
@@ -826,8 +825,8 @@ int main (int argc, char ** argv)
        if (s_flag == 1) {
                if (sb->s_feature_ro_compat &
                    EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)
-                       fprintf(stderr, _("\nThe filesystem already"
-                               " has sparse superblocks.\n"));
+                       fputs(_("\nThe filesystem already has sparse "
+                               "superblocks.\n"), stderr);
                else {
                        sb->s_feature_ro_compat |=
                                EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
@@ -840,8 +839,8 @@ int main (int argc, char ** argv)
        if (s_flag == 0) {
                if (!(sb->s_feature_ro_compat &
                      EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER))
-                       fprintf(stderr, _("\nThe filesystem already"
-                               " has sparse superblocks disabled.\n"));
+                       fputs(_("\nThe filesystem already has sparse "
+                               "superblocks disabled.\n"), stderr);
                else {
                        sb->s_feature_ro_compat &=
                                ~EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
@@ -865,8 +864,8 @@ int main (int argc, char ** argv)
        }
        if (L_flag) {
                if (strlen(new_label) > sizeof(sb->s_volume_name))
-                       fprintf(stderr, _("Warning: label too "
-                               "long, truncating.\n"));
+                       fputs(_("Warning: label too long, truncating.\n"), 
+                             stderr);
                memset(sb->s_volume_name, 0, sizeof(sb->s_volume_name));
                strncpy(sb->s_volume_name, new_label,
                        sizeof(sb->s_volume_name));
index 76392ff..b5e6f94 100644 (file)
@@ -69,7 +69,7 @@ void proceed_question(void)
 
        fflush(stdout);
        fflush(stderr);
-       printf(_("Proceed anyway? (y,n) "));
+       fputs(_("Proceed anyway? (y,n) "), stdout);
        buf[0] = 0;
        fgets(buf, sizeof(buf), stdin);
        if (strchr(short_yes, buf[0]) == 0)
@@ -93,8 +93,8 @@ void check_plausibility(const char *device)
                fprintf(stderr, _("Could not stat %s --- %s\n"),
                        device, error_message(errno));
                if (errno == ENOENT)
-                       fprintf(stderr, _("\nThe device apparently does "
-                              "not exist; did you specify it correctly?\n"));
+                       fputs(_("\nThe device apparently does not exist; "
+                               "did you specify it correctly?\n"), stderr);
                exit(1);
        }
        if (!S_ISBLK(s.st_mode)) {
@@ -151,8 +151,8 @@ void check_mount(const char *device, int force, const char *type)
 
        fprintf(stderr, _("%s is mounted; "), device);
        if (force) {
-               fprintf(stderr, _("mke2fs forced anyway.  "
-                       "Hope /etc/mtab is incorrect.\n"));
+               fputs(_("mke2fs forced anyway.  Hope /etc/mtab is "
+                       "incorrect.\n"), stderr);
        } else {
                fprintf(stderr, _("will not make a %s here!\n"), type);
                exit(1);
@@ -168,8 +168,8 @@ void parse_journal_opts(const char *opts)
        len = strlen(opts);
        buf = malloc(len+1);
        if (!buf) {
-               fprintf(stderr, _("Couldn't allocate memory to parse "
-                       "journal options!\n"));
+               fputs(_("Couldn't allocate memory to parse journal "
+                       "options!\n"), stderr);
                exit(1);
        }
        strcpy(buf, opts);
@@ -210,7 +210,7 @@ void parse_journal_opts(const char *opts)
                        journal_usage++;
        }
        if (journal_usage) {
-               fprintf(stderr, _("\nBad journal options specified.\n\n"
+               fputs(_("\nBad journal options specified.\n\n"
                        "Journal options are separated by commas, "
                        "and may take an argument which\n"
                        "\tis set off by an equals ('=') sign.\n\n"
@@ -218,7 +218,7 @@ void parse_journal_opts(const char *opts)
                        "\tsize=<journal size in megabytes>\n"
                        "\tdevice=<journal device>\n\n"
                        "The journal size must be between "
-                       "1024 and 102400 filesystem blocks.\n\n" ));
+                       "1024 and 102400 filesystem blocks.\n\n"), stderr);
                exit(1);
        }
 }      
@@ -237,7 +237,7 @@ int figure_journal_size(int size, ext2_filsys fs)
        blk_t j_blocks;
 
        if (fs->super->s_blocks_count < 2048) {
-               fprintf(stderr, _("\nFilesystem too small for a journal\n"));
+               fputs(_("\nFilesystem too small for a journal\n"), stderr);
                return 0;
        }
        
@@ -252,8 +252,8 @@ int figure_journal_size(int size, ext2_filsys fs)
                        exit(1);
                }
                if (j_blocks > fs->super->s_free_blocks_count) {
-                       fprintf(stderr, _("\nJournal size too big "
-                                         "for filesystem.\n"));
+                       fputs(_("\nJournal size too big for filesystem.\n"),
+                             stderr);
                        exit(1);
                }
                return j_blocks;
index 85809cc..ce98603 100644 (file)
@@ -1,3 +1,7 @@
+2003-12-07  Theodore Ts'o  <tytso@mit.edu>
+
+       * main.c, resize2fs.c: Fix gcc -Wall nitpicks.
+
 2003-08-24  Theodore Ts'o  <tytso@mit.edu>
 
        * resize2fs.8.in: Adjust description line so that apropos
index 649105a..b32a7ea 100644 (file)
@@ -138,7 +138,7 @@ int main (int argc, char ** argv)
        io_manager      io_ptr;
        char            *tmp;
        struct stat     st_buf;
-       int             sys_page_size = 4096;
+       unsigned int    sys_page_size = 4096;
        long            sysval;
 
 #ifdef ENABLE_NLS
@@ -265,9 +265,9 @@ int main (int argc, char ** argv)
                exit(1);
        }
        if (units) {
-               if (units < fs->blocksize)
+               if ((unsigned) units < fs->blocksize)
                        new_size = (new_size * units) / fs->blocksize;
-               else if (units > fs->blocksize)
+               else if ((unsigned) units > fs->blocksize)
                        new_size = new_size * (units / fs->blocksize);
        }
        if (!new_size) {
index c7970d0..5aaf8f5 100644 (file)
@@ -176,9 +176,10 @@ static errcode_t adjust_superblock(ext2_resize_t rfs, blk_t new_size)
        errcode_t       retval;
        ext2_ino_t      real_end;
        blk_t           blk, group_block;
-       unsigned long   i, j;
+       unsigned long   i, j, old_desc_blocks;
        int             old_numblocks, numblocks, adjblocks;
-       int             has_super, meta_bg, meta_bg_size, old_desc_blocks;
+       unsigned int    meta_bg, meta_bg_size;
+       int             has_super;
        unsigned long   max_group;
        
        fs = rfs->new_fs;
@@ -446,8 +447,11 @@ static errcode_t mark_table_blocks(ext2_filsys fs,
                                   ext2fs_block_bitmap *ret_bmap)
 {
        blk_t                   block, b;
-       int                     i,j, has_super, meta_bg, meta_bg_size;
-       int                     old_desc_blocks;
+       unsigned int            j;
+       dgrp_t                  i;
+       unsigned long           meta_bg, meta_bg_size;
+       int                     has_super;
+       unsigned int            old_desc_blocks;
        ext2fs_block_bitmap     bmap;
        errcode_t               retval;
 
@@ -497,7 +501,7 @@ static errcode_t mark_table_blocks(ext2_filsys fs,
                 * Mark the blocks used for the inode table
                 */
                for (j = 0, b = fs->group_desc[i].bg_inode_table;
-                    j < fs->inode_blocks_per_group;
+                    j < (unsigned int) fs->inode_blocks_per_group;
                     j++, b++)
                        ext2fs_mark_block_bitmap(bmap, b);
                            
@@ -560,9 +564,11 @@ static void mark_fs_metablock(ext2_resize_t rfs,
  */
 static errcode_t blocks_to_move(ext2_resize_t rfs)
 {
-       int     i, j, max_groups, has_super, meta_bg, meta_bg_size;
-       blk_t   blk, group_blk;
-       unsigned long old_blocks, new_blocks;
+       int             j, has_super;
+       dgrp_t          i, max_groups;
+       blk_t           blk, group_blk;
+       unsigned long   old_blocks, new_blocks;
+       unsigned int    meta_bg, meta_bg_size;
        errcode_t       retval;
        ext2_filsys     fs, old_fs;
        ext2fs_block_bitmap     meta_bmap;
@@ -969,8 +975,9 @@ struct process_block_struct {
 };
 
 static int process_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, 
+                        blk_t ref_block EXT2FS_ATTR((unused)),
+                        int ref_offset EXT2FS_ATTR((unused)), void *priv_data)
 {
        struct process_block_struct *pb;
        errcode_t       retval;
@@ -1007,7 +1014,8 @@ static int process_block(ext2_filsys fs, blk_t    *block_nr,
 /*
  * Progress callback
  */
-static errcode_t progress_callback(ext2_filsys fs, ext2_inode_scan scan,
+static errcode_t progress_callback(ext2_filsys fs, 
+                                  ext2_inode_scan scan EXT2FS_ATTR((unused)),
                                   dgrp_t group, void * priv_data)
 {
        ext2_resize_t rfs = (ext2_resize_t) priv_data;
@@ -1192,9 +1200,12 @@ struct istruct {
        int             num;
 };
 
-static int check_and_change_inodes(ext2_ino_t dir, int entry,
+static int check_and_change_inodes(ext2_ino_t dir, 
+                                  int entry EXT2FS_ATTR((unused)),
                                   struct ext2_dir_entry *dirent, int offset,
-                                  int  blocksize, char *buf, void *priv_data)
+                                  int  blocksize EXT2FS_ATTR((unused)),
+                                  char *buf EXT2FS_ATTR((unused)), 
+                                  void *priv_data)
 {
        struct istruct *is = (struct istruct *) priv_data;
        struct ext2_inode       inode;
@@ -1299,7 +1310,8 @@ errout:
  */
 static errcode_t move_itables(ext2_resize_t rfs)
 {
-       int             i, n, num, max_groups, size, diff;
+       int             n, num, size, diff;
+       dgrp_t          i, max_groups;
        ext2_filsys     fs = rfs->new_fs;
        char            *cp;
        blk_t           old_blk, new_blk;
@@ -1421,8 +1433,8 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs)
 {
        blk_t           blk;
        ext2_ino_t      ino;
-       int             group = 0;
-       int             count = 0;
+       unsigned int    group = 0;
+       unsigned int    count = 0;
        int             total_free = 0;
        int             group_free = 0;
 
index 2a21183..1501bda 100644 (file)
@@ -1,3 +1,10 @@
+2003-12-07  Theodore Ts'o  <tytso@mit.edu>
+
+       * subst.c: Fix gcc -Wall nitpicks.
+
+       * gcc-wall-cleanup: Remove missing initalizer, zero-length format
+               string, and some more long long warnings.
+
 2003-07-25  Theodore Ts'o  <tytso@mit.edu>
 
        * Release of E2fsprogs 1.34
index 4d817b1..6148e46 100644 (file)
@@ -6,12 +6,17 @@
 /^kcc /d
 /^gcc /d
 /does not support `long long'/d
+/forbids long long integer constants/d
 /does not support the `ll' length modifier/d
+/does not support the `ll' printf length modifier/d
 /ANSI C forbids long long integer constants/d
 /traditional C rejects string concatenation/d
 /integer constant is unsigned in ANSI C, signed with -traditional/d
 /At top level:/d
 /In file included from/d
 /In function `.*':/d
+/zero-length format string/d
+/warning: missing initializer/d
+/warning: (near initialization for/d
 /^[    ]*from/d
 
index 7b7ba83..dff1848 100644 (file)
@@ -74,7 +74,7 @@ static struct subst_entry *fetch_subst_entry(char *name)
  * Given the starting and ending position of the replacement name,
  * check to see if it is valid, and pull it out if it is.
  */
-static char *get_subst_symbol(const char *begin, int len, char prefix)
+static char *get_subst_symbol(const char *begin, size_t len, char prefix)
 {
        static char replace_name[128];
        char *cp, *start;
@@ -121,7 +121,7 @@ static void substitute_line(char *line)
        char    *ptr, *name_ptr, *end_ptr;
        struct subst_entry *ent;
        char    *replace_name;
-       int     len;
+       size_t  len;
 
        /*
         * Expand all @FOO@ substitutions