+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
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;
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;
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;
}
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;
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;
}
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 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;
}
}
-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;
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;
}
/* 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);
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);
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;
{
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;
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;
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;
}
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;
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;
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();
}
}
- 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);
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;
}
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;
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;
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,
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;
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;
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;
};
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;
struct super_set_info {
const char *name;
void *ptr;
- int size;
+ unsigned int size;
errcode_t (*func)(struct super_set_info *info, char *arg);
};
#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;
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.
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;
}
-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;
#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>
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);
}
struct ea_refcount {
blk_t count;
blk_t size;
- int cursor;
+ blk_t cursor;
struct ea_refcount_el *list;
};
*/
static void refcount_collapse(ext2_refcount_t refcount)
{
- int i, j;
+ unsigned int i, j;
struct ea_refcount_el *list;
list = refcount->list;
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;
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;
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;
}
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;
}
* 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;
int e2fsck_pass1_check_symlink(ext2_filsys fs, struct ext2_inode *inode,
char *buf)
{
- int len;
+ unsigned int len;
int i;
blk_t blocks;
* 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;
/* 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;
} 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;
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;
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;
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++) {
{
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);
/*
* 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;
/*
* 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;
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;
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;
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;
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;
{
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++) {
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;
*/
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;
* 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;
#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))
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;
#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;
*/
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;
*/
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;
/*
* 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;
};
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;
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;
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;
{
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,
{ -1, 0, 0 },
};
-static const struct e2fsck_problem *find_problem(int code)
+static const struct e2fsck_problem *find_problem(problem_t code)
{
int i;
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;
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;
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;
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;
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);
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,
}
}
- 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);
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;
return;
}
-static int is_on_batt()
+static int is_on_batt(void)
{
FILE *f;
char tmp[80], tmp2[80];
(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) {
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);
{
static const char spinner[] = "\\|/-";
int i;
- int tick;
+ unsigned int tick;
struct timeval tv;
int dpywidth;
}
#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;
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;
ctx->progress = 0;
}
-static void signal_cancel(int sig)
+static void signal_cancel(int sig EXT2FS_ATTR((unused)))
{
e2fsck_t ctx = e2fsck_global_ctx;
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;
+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
#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).
}
}
-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;
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;
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];
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];
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;
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;
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;
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;
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) */
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)) {
+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
*
* 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;
#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 *)
#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;
{
#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
}
#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
}
#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;
*/
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;
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 +
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)
{
* 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;
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,
#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;
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;
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;
#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
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;
/* 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);
/* 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);
/* 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);
/*
* 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;
#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;
ext2_ino_t count;
ext2_ino_t size;
ext2_ino_t num_inodes;
- int cursor;
+ ext2_ino_t cursor;
struct ext2_icount_el *list;
};
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);
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);
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);
retval = errno;
goto errout;
}
- if (actual != fs->blocksize * d) {
+ if (actual != (ssize_t) (fs->blocksize * d)) {
retval = EXT2_ET_SHORT_WRITE;
goto 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;
retval = errno;
goto errout;
}
- if (actual != fs->blocksize * c) {
+ if (actual != (ssize_t) (fs->blocksize * c)) {
retval = EXT2_ET_SHORT_READ;
goto 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;
retval = errno;
goto errout;
}
- if (actual != fs->blocksize) {
+ if (actual != (ssize_t) fs->blocksize) {
retval = EXT2_ET_SHORT_WRITE;
goto errout;
}
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;
}
/*
* 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;
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) {
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;
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;
* 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)) {
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);
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;
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);
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 {
#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;
#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;
{
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;
retval = errno;
goto errout;
}
- if (ret_size != fs->blocksize)
+ if (ret_size != (int) fs->blocksize)
goto errout;
memset(buf, 0, fs->blocksize);
retval = errno;
goto errout;
}
- if (ret_size != fs->blocksize)
+ if (ret_size != (int) fs->blocksize)
goto errout;
}
close(fd);
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;
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)
(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 */
* 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;
#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;
}
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);
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;
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);
int count, void *buf)
{
errcode_t retval;
- size_t size;
+ ssize_t size;
ext2_loff_t location;
int actual = 0;
unsigned long block,
int count, const void *buf)
{
- size_t size;
+ ssize_t size;
ext2_loff_t location;
int actual = 0;
errcode_t retval;
}
/* 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;
* 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)
{
cleanup:
if (data) {
- free_cache(io, data);
+ free_cache(data);
ext2fs_free_mem(&data);
}
if (io)
if (close(data->dev) < 0)
retval = errno;
- free_cache(channel, data);
+ free_cache(data);
ext2fs_free_mem(&channel->private_data);
if (channel->name)
#endif
channel->block_size = blksize;
- free_cache(channel, data);
+ free_cache(data);
if ((retval = alloc_cache(channel, data)))
return retval;
}
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
* 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);
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);
{
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;
#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;
#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;
#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;
+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
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;
int waitb;
#endif
- DONT_USE(argc);
- DONT_USE(argv);
-
sigemptyset(&igmask);
sigaddset(&igmask, SIGINT);
sigprocmask(SIG_BLOCK, &igmask, &omask);
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]) {
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)();
}
}
-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);
}
-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);
}
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)
/*
* 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,
/*
* 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);
}
/*
* 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);
}
* 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, "");
}
#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 */
#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);
+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,
fflush (stderr);
}
-static void alarm_intr(int alnum)
+static void alarm_intr(int alnum EXT2FS_ATTR((unused)))
{
signal (SIGALRM, alarm_intr);
alarm(1);
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);
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++) {
}
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);
}
}
}
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;
}
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);
}
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);
}
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
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);
}
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)
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)
}
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
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,
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++) {
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);
}
optarg);
exit(1);
}
- if (pattern == ~0)
+ if (pattern == (unsigned long) ~0)
pattern = 0xffff;
t_patts[t_flag++] = pattern;
}
"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"));
} 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)
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)
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)
#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)
}
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;
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)
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)
{
{
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;
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 "));
} 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);
errcode_t retval;
char buf[1024];
char str[80];
- int i;
+ unsigned int i;
journal_superblock_t *jsb;
/* Get the journal superblock */
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);
}
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;
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;
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)
}
}
-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);
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;
/*
*/
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);
}
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);
}
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;
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 *));
}
if ((negate && !cmp->negate) ||
(!negate && cmp->negate)) {
- fprintf(stderr, _(fs_type_syntax_error));
+ fputs(_(fs_type_syntax_error), stderr);
exit(EXIT_USAGE);
}
}
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
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++;
}
#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
#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;
}
}
-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;
/*
* 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;
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;
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);
}
}
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;
{
errcode_t retval;
blk_t blk;
- int i, num;
+ dgrp_t i;
+ int num;
struct progress_struct progress;
if (quiet)
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"),
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,
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,
exit(1);
}
- if (tmp = getenv("MKE2FS_DEVICE_SECTSIZE"))
+ if ((tmp = getenv("MKE2FS_DEVICE_SECTSIZE")) != NULL)
sector_size = atoi(tmp);
set_fs_defaults(fs_type, ¶m, blocksize, sector_size, &inode_ratio);
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);
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
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;
#ifdef ENABLE_NLS
+#warning Using NLS
#include <libintl.h>
#include <locale.h>
#define _(a) (gettext (a))
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;
}
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;
}
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;
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) {
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) {
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);
_("\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.
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);
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);
}
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;
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;
}
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));
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)
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)) {
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);
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);
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"
"\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);
}
}
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;
}
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;
+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
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
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) {
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;
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;
* 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);
*/
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;
};
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;
/*
* 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;
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;
*/
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;
{
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;
+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
/^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
* 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;
char *ptr, *name_ptr, *end_ptr;
struct subst_entry *ent;
char *replace_name;
- int len;
+ size_t len;
/*
* Expand all @FOO@ substitutions