Fix gcc -Wall nitpicks
diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog
index b97949c..4b92c1b 100644
--- a/e2fsck/ChangeLog
+++ b/e2fsck/ChangeLog
@@ -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.
diff --git a/e2fsck/badblocks.c b/e2fsck/badblocks.c
index 572af20..09ef3ab 100644
--- a/e2fsck/badblocks.c
+++ b/e2fsck/badblocks.c
@@ -17,7 +17,7 @@
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 @@
}
-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;
diff --git a/e2fsck/dict.c b/e2fsck/dict.c
index 350ce75..bccab8b 100644
--- a/e2fsck/dict.c
+++ b/e2fsck/dict.c
@@ -20,6 +20,12 @@
#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 @@
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);
}
diff --git a/e2fsck/ea_refcount.c b/e2fsck/ea_refcount.c
index de13316..6420c72 100644
--- a/e2fsck/ea_refcount.c
+++ b/e2fsck/ea_refcount.c
@@ -28,7 +28,7 @@
struct ea_refcount {
blk_t count;
blk_t size;
- int cursor;
+ blk_t cursor;
struct ea_refcount_el *list;
};
@@ -83,7 +83,7 @@
*/
static void refcount_collapse(ext2_refcount_t refcount)
{
- int i, j;
+ unsigned int i, j;
struct ea_refcount_el *list;
list = refcount->list;
diff --git a/e2fsck/ehandler.c b/e2fsck/ehandler.c
index d4060c4..16d6d4f 100644
--- a/e2fsck/ehandler.c
+++ b/e2fsck/ehandler.c
@@ -23,8 +23,8 @@
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 @@
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;
diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index 615bd3e..c645f3b 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -101,8 +101,8 @@
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 @@
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;
}
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 58edd0a..2062807 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -113,7 +113,7 @@
* 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_symlink(ext2_filsys fs, struct ext2_inode *inode,
char *buf)
{
- int len;
+ unsigned int len;
int i;
blk_t blocks;
@@ -757,7 +757,8 @@
* 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 @@
/* 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 @@
} 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 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 @@
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 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 @@
{
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);
diff --git a/e2fsck/pass1b.c b/e2fsck/pass1b.c
index 39e9030..f368d84 100644
--- a/e2fsck/pass1b.c
+++ b/e2fsck/pass1b.c
@@ -159,7 +159,8 @@
/*
* 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 @@
/*
* 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 @@
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 @@
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 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 @@
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 @@
{
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++) {
diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index 6f2ac93..dee2c19 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -96,7 +96,7 @@
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_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 @@
* 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 @@
#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 @@
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 @@
#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 @@
*/
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 @@
*/
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 @@
/*
* 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;
diff --git a/e2fsck/pass3.c b/e2fsck/pass3.c
index bafcb4c..e2bdd54 100644
--- a/e2fsck/pass3.c
+++ b/e2fsck/pass3.c
@@ -611,9 +611,9 @@
};
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 @@
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;
diff --git a/e2fsck/pass5.c b/e2fsck/pass5.c
index 862b7e0..e708fa4 100644
--- a/e2fsck/pass5.c
+++ b/e2fsck/pass5.c
@@ -114,8 +114,8 @@
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 @@
{
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,
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index a164bb5..9f0b561 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -1440,7 +1440,7 @@
{ -1, 0, 0 },
};
-static const struct e2fsck_problem *find_problem(int code)
+static const struct e2fsck_problem *find_problem(problem_t code)
{
int i;
diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c
index c6b0b02..727e08c 100644
--- a/e2fsck/rehash.c
+++ b/e2fsck/rehash.c
@@ -79,15 +79,15 @@
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 @@
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;
diff --git a/e2fsck/super.c b/e2fsck/super.c
index b6c5e74..9a1ab4c 100644
--- a/e2fsck/super.c
+++ b/e2fsck/super.c
@@ -60,7 +60,7 @@
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 @@
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 @@
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 @@
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 @@
}
}
- 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);
diff --git a/e2fsck/swapfs.c b/e2fsck/swapfs.c
index 8e9a134..3e7609b 100644
--- a/e2fsck/swapfs.c
+++ b/e2fsck/swapfs.c
@@ -110,7 +110,8 @@
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;
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index 91511bf..4c2598f 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -199,7 +199,7 @@
return;
}
-static int is_on_batt()
+static int is_on_batt(void)
{
FILE *f;
char tmp[80], tmp2[80];
@@ -254,12 +254,12 @@
(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 @@
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 @@
{
static const char spinner[] = "\\|/-";
int i;
- int tick;
+ unsigned int tick;
struct timeval tv;
int dpywidth;
@@ -437,7 +437,7 @@
}
#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 @@
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 @@
ctx->progress = 0;
}
-static void signal_cancel(int sig)
+static void signal_cancel(int sig EXT2FS_ATTR((unused)))
{
e2fsck_t ctx = e2fsck_global_ctx;
diff --git a/e2fsck/util.c b/e2fsck/util.c
index 8bb538d..569fc58 100644
--- a/e2fsck/util.c
+++ b/e2fsck/util.c
@@ -70,7 +70,8 @@
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;