aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2013-05-19 21:45:16 -0400
committerTheodore Ts'o <tytso@mit.edu>2013-05-19 21:45:16 -0400
commit581ecb6d8808a083add919f066f44cf7e70f9c4a (patch)
tree2963ccfdd5988bc2c8ff48160b1d8c4db714562f
parent29f6dfea52f7c3d6e90b9a03fb66fc09d4aa90ed (diff)
parent68477355a9f3b4ca46dfa6c34d05105dcc6682ad (diff)
downloade2fsprogs-581ecb6d8808a083add919f066f44cf7e70f9c4a.tar.gz
e2fsprogs-581ecb6d8808a083add919f066f44cf7e70f9c4a.tar.xz
e2fsprogs-581ecb6d8808a083add919f066f44cf7e70f9c4a.zip
Merge branch 'maint' into next
Conflicts: e2fsck/pass1b.c e2fsck/rehash.c lib/ext2fs/crc32c.c lib/ext2fs/gen_bitmap64.c misc/tune2fs.c
-rw-r--r--debian/e2fslibs.symbols1
-rw-r--r--e2fsck/journal.c2
-rw-r--r--e2fsck/message.c3
-rw-r--r--e2fsck/pass1.c15
-rw-r--r--e2fsck/pass1b.c35
-rw-r--r--e2fsck/pass2.c2
-rw-r--r--e2fsck/recovery.c16
-rw-r--r--e2fsck/rehash.c9
-rw-r--r--e2fsck/sigcatcher.c3
-rw-r--r--e2fsck/super.c2
-rw-r--r--lib/ext2fs/bitops.c2
-rw-r--r--lib/ext2fs/bitops.h19
-rw-r--r--lib/ext2fs/blkmap64_rb.c48
-rw-r--r--lib/ext2fs/block.c4
-rw-r--r--lib/ext2fs/gen_bitmap64.c2
-rw-r--r--lib/ext2fs/mmp.c3
-rw-r--r--lib/ext2fs/rbtree.c4
-rw-r--r--lib/ext2fs/rbtree.h4
-rw-r--r--lib/ext2fs/rw_bitmaps.c3
-rw-r--r--lib/ext2fs/symlink.c2
-rw-r--r--lib/quota/quotaio.h5
-rw-r--r--lib/quota/quotaio_tree.c5
-rw-r--r--misc/badblocks.c16
-rw-r--r--misc/e2image.c2
-rw-r--r--misc/filefrag.c6
-rw-r--r--misc/mke2fs.c45
-rw-r--r--misc/tune2fs.c28
27 files changed, 149 insertions, 137 deletions
diff --git a/debian/e2fslibs.symbols b/debian/e2fslibs.symbols
index 6464a1bd..eea35006 100644
--- a/debian/e2fslibs.symbols
+++ b/debian/e2fslibs.symbols
@@ -378,7 +378,6 @@ libext2fs.so.2 e2fslibs #MINVER#
ext2fs_open_file@Base 1.42
ext2fs_open_inode_scan@Base 1.37
ext2fs_parse_version_string@Base 1.37
- ext2fs_print_bmap_statistics@Base 1.42.1
ext2fs_process_dir_block@Base 1.37
ext2fs_punch@Base 1.42
ext2fs_r_blocks_count@Base 1.42
diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index fd6d6caa..2ca19b86 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -361,7 +361,7 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
BLOCK_FLAG_HOLE, 0,
process_journal_block, &pb);
if ((pb.last_block + 1) * ctx->fs->blocksize <
- EXT2_I_SIZE(&j_inode->i_ext2)) {
+ (int) EXT2_I_SIZE(&j_inode->i_ext2)) {
retval = EXT2_ET_JOURNAL_TOO_SMALL;
goto try_backup_journal;
}
diff --git a/e2fsck/message.c b/e2fsck/message.c
index b79b895d..b99473dd 100644
--- a/e2fsck/message.c
+++ b/e2fsck/message.c
@@ -361,8 +361,7 @@ static _INLINE_ void expand_dirent_expression(FILE *f, ext2_filsys fs, char ch,
struct problem_context *ctx)
{
struct ext2_dir_entry *dirent;
- unsigned int rec_len;
- int len;
+ unsigned int rec_len, len;
if (!ctx || !ctx->dirent)
goto no_dirent;
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 94df36d4..1b410be3 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -1955,12 +1955,12 @@ fix_problem_now:
}
/* The next extent should match this index's logical start */
if (extent.e_lblk != lblk) {
- struct ext2_extent_info info;
+ struct ext2_extent_info e_info;
- ext2fs_extent_get_info(ehandle, &info);
+ ext2fs_extent_get_info(ehandle, &e_info);
pctx->blk = lblk;
pctx->blk2 = extent.e_lblk;
- pctx->num = info.curr_level - 1;
+ pctx->num = e_info.curr_level - 1;
problem = PR_1_EXTENT_INDEX_START_INVALID;
if (fix_problem(ctx, problem, pctx))
ext2fs_extent_fix_parents(ehandle);
@@ -2000,7 +2000,8 @@ fix_problem_now:
}
pb->fragmented = 1;
}
- while (is_dir && ++pb->last_db_block < extent.e_lblk) {
+ while (is_dir && (++pb->last_db_block <
+ (e2_blkcnt_t) extent.e_lblk)) {
pctx->errcode = ext2fs_add_dir_block2(ctx->fs->dblist,
pb->ino, 0,
pb->last_db_block);
@@ -2022,7 +2023,7 @@ fix_problem_now:
(EXT2FS_B2C(ctx->fs, blk) ==
EXT2FS_B2C(ctx->fs, pb->previous_block)) &&
(blk & EXT2FS_CLUSTER_MASK(ctx->fs)) ==
- (blockcnt & EXT2FS_CLUSTER_MASK(ctx->fs)))) {
+ ((unsigned) blockcnt & EXT2FS_CLUSTER_MASK(ctx->fs)))) {
mark_block_used(ctx, blk);
pb->num_blocks++;
}
@@ -2472,7 +2473,7 @@ static int process_block(ext2_filsys fs,
(EXT2FS_B2C(ctx->fs, blk) ==
EXT2FS_B2C(ctx->fs, p->previous_block)) &&
(blk & EXT2FS_CLUSTER_MASK(ctx->fs)) ==
- (blockcnt & EXT2FS_CLUSTER_MASK(ctx->fs)))) {
+ ((unsigned) blockcnt & EXT2FS_CLUSTER_MASK(ctx->fs)))) {
mark_block_used(ctx, blk);
p->num_blocks++;
}
@@ -2803,7 +2804,7 @@ static void mark_table_blocks(e2fsck_t ctx)
ext2_filsys fs = ctx->fs;
blk64_t b;
dgrp_t i;
- int j;
+ unsigned int j;
struct problem_context pctx;
clear_problem_context(&pctx);
diff --git a/e2fsck/pass1b.c b/e2fsck/pass1b.c
index 05cbd10c..16a81b92 100644
--- a/e2fsck/pass1b.c
+++ b/e2fsck/pass1b.c
@@ -624,7 +624,6 @@ static void delete_file(e2fsck_t ctx, ext2_ino_t ino,
{
ext2_filsys fs = ctx->fs;
struct process_block_struct pb;
- struct ext2_inode inode;
struct problem_context pctx;
unsigned int count;
@@ -635,33 +634,35 @@ static void delete_file(e2fsck_t ctx, ext2_ino_t ino,
pctx.str = "delete_file";
pb.cur_cluster = ~0;
- e2fsck_read_inode(ctx, ino, &inode, "delete_file");
- if (ext2fs_inode_has_valid_blocks2(fs, &inode))
- pctx.errcode = ext2fs_block_iterate3(fs, ino, BLOCK_FLAG_READ_ONLY,
- block_buf, delete_file_block, &pb);
+ if (ext2fs_inode_has_valid_blocks2(fs, &dp->inode))
+ pctx.errcode = ext2fs_block_iterate3(fs, ino,
+ BLOCK_FLAG_READ_ONLY,
+ block_buf,
+ delete_file_block, &pb);
if (pctx.errcode)
fix_problem(ctx, PR_1B_BLOCK_ITERATE, &pctx);
if (ctx->inode_bad_map)
ext2fs_unmark_inode_bitmap2(ctx->inode_bad_map, ino);
- ext2fs_inode_alloc_stats2(fs, ino, -1, LINUX_S_ISDIR(inode.i_mode));
- quota_data_sub(ctx->qctx, &inode, ino, pb.dup_blocks * fs->blocksize);
- quota_data_inodes(ctx->qctx, &inode, ino, -1);
+ ext2fs_inode_alloc_stats2(fs, ino, -1, LINUX_S_ISDIR(dp->inode.i_mode));
+ quota_data_sub(ctx->qctx, &dp->inode, ino,
+ pb.dup_blocks * fs->blocksize);
+ quota_data_inodes(ctx->qctx, &dp->inode, ino, -1);
/* Inode may have changed by block_iterate, so reread it */
- e2fsck_read_inode(ctx, ino, &inode, "delete_file");
- e2fsck_clear_inode(ctx, ino, &inode, 0, "delete_file");
- if (ext2fs_file_acl_block(fs, &inode) &&
+ e2fsck_read_inode(ctx, ino, &dp->inode, "delete_file");
+ e2fsck_clear_inode(ctx, ino, &dp->inode, 0, "delete_file");
+ if (ext2fs_file_acl_block(fs, &dp->inode) &&
(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_EXT_ATTR)) {
count = 1;
pctx.errcode = ext2fs_adjust_ea_refcount3(fs,
- ext2fs_file_acl_block(fs, &inode),
+ ext2fs_file_acl_block(fs, &dp->inode),
block_buf, -1, &count, ino);
if (pctx.errcode == EXT2_ET_BAD_EA_BLOCK_NUM) {
pctx.errcode = 0;
count = 1;
}
if (pctx.errcode) {
- pctx.blk = ext2fs_file_acl_block(fs, &inode);
+ pctx.blk = ext2fs_file_acl_block(fs, &dp->inode);
fix_problem(ctx, PR_1B_ADJ_EA_REFCOUNT, &pctx);
}
/*
@@ -672,12 +673,12 @@ static void delete_file(e2fsck_t ctx, ext2_ino_t ino,
*/
if ((count == 0) ||
ext2fs_test_block_bitmap2(ctx->block_dup_map,
- ext2fs_file_acl_block(fs, &inode))) {
- blk64_t blk = ext2fs_file_acl_block(fs, &inode);
+ ext2fs_file_acl_block(fs, &dp->inode))) {
+ blk64_t blk = ext2fs_file_acl_block(fs, &dp->inode);
delete_file_block(fs, &blk,
BLOCK_COUNT_EXTATTR, 0, 0, &pb);
- ext2fs_file_acl_block_set(fs, &inode, blk);
- quota_data_sub(ctx->qctx, &inode, ino, fs->blocksize);
+ ext2fs_file_acl_block_set(fs, &dp->inode, blk);
+ quota_data_sub(ctx->qctx, &dp->inode, ino, fs->blocksize);
}
}
}
diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index e28af610..257589c4 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -687,7 +687,7 @@ static void salvage_directory(ext2_filsys fs,
*/
if ((left < 0) &&
((int) rec_len + left > 8) &&
- (name_len + 8 <= (int) rec_len + left) &&
+ ((int) name_len + 8 <= (int) rec_len + left) &&
dirent->inode <= fs->super->s_inodes_count &&
strnlen(dirent->name, name_len) == name_len) {
(void) ext2fs_set_rec_len(fs, (int) rec_len + left, dirent);
diff --git a/e2fsck/recovery.c b/e2fsck/recovery.c
index d9dc59d2..7712185a 100644
--- a/e2fsck/recovery.c
+++ b/e2fsck/recovery.c
@@ -857,12 +857,16 @@ static int scan_revoke_records(journal_t *journal, struct buffer_head *bh,
unsigned long long blocknr;
int err;
- if (record_len == 4)
- blocknr = ext2fs_be32_to_cpu(*((__be32 *)(bh->b_data +
- offset)));
- else
- blocknr = ext2fs_be64_to_cpu(*((__be64 *)(bh->b_data +
- offset)));
+ if (record_len == 4) {
+ __be32 b;
+ memcpy(&b, bh->b_data + offset, sizeof(__be32));
+ blocknr = ext2fs_be32_to_cpu(b);
+ } else {
+ __be64 b;
+ memcpy(&b, bh->b_data + offset, sizeof(__be64));
+ blocknr = ext2fs_be64_to_cpu(b);
+ }
+
offset += record_len;
err = journal_set_revoke(journal, blocknr, sequence);
if (err)
diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c
index 9cfb516f..df3afab8 100644
--- a/e2fsck/rehash.c
+++ b/e2fsck/rehash.c
@@ -78,7 +78,7 @@ struct fill_dir_struct {
e2fsck_t ctx;
struct hash_entry *harray;
int max_array, num_array;
- int dir_size;
+ unsigned int dir_size;
int compress;
ino_t parent;
ext2_ino_t dir;
@@ -145,7 +145,7 @@ static int fill_dir_block(ext2_filsys fs,
if (((dir_offset + rec_len) > fs->blocksize) ||
(rec_len < 8) ||
((rec_len % 4) != 0) ||
- (((dirent->name_len & 0xFF)+8) > rec_len)) {
+ (((dirent->name_len & 0xFF)+8U) > rec_len)) {
fd->err = EXT2_ET_DIR_CORRUPTED;
return BLOCK_ABORT;
}
@@ -428,10 +428,9 @@ static errcode_t copy_dir_entries(e2fsck_t ctx,
char *block_start;
struct hash_entry *ent;
struct ext2_dir_entry *dirent;
- unsigned int rec_len, prev_rec_len;
- int i, left;
+ unsigned int rec_len, prev_rec_len, left, slack, offset;
+ int i;
ext2_dirhash_t prev_hash;
- int offset, slack;
int csum_size = 0;
struct ext2_dir_entry_tail *t;
diff --git a/e2fsck/sigcatcher.c b/e2fsck/sigcatcher.c
index e3925f15..27740bf6 100644
--- a/e2fsck/sigcatcher.c
+++ b/e2fsck/sigcatcher.c
@@ -331,7 +331,8 @@ static const char *lookup_table_fallback(int num, struct str_table *table)
return buf;
}
-static void die_signal_handler(int signum, siginfo_t *siginfo, void *context)
+static void die_signal_handler(int signum, siginfo_t *siginfo,
+ void *context EXT2FS_ATTR((unused)))
{
void *stack_syms[32];
int frames;
diff --git a/e2fsck/super.c b/e2fsck/super.c
index 6f1ce3de..16a1c23d 100644
--- a/e2fsck/super.c
+++ b/e2fsck/super.c
@@ -465,11 +465,11 @@ void check_super_block(e2fsck_t ctx)
ext2_filsys fs = ctx->fs;
blk64_t first_block, last_block;
struct ext2_super_block *sb = fs->super;
+ unsigned int ipg_max;
problem_t problem;
blk64_t blocks_per_group = fs->super->s_blocks_per_group;
__u32 bpg_max, cpg_max;
int inodes_per_block;
- int ipg_max;
int inode_size;
int accept_time_fudge;
int broken_system_clock;
diff --git a/lib/ext2fs/bitops.c b/lib/ext2fs/bitops.c
index 7c3f215f..8e4c05c4 100644
--- a/lib/ext2fs/bitops.c
+++ b/lib/ext2fs/bitops.c
@@ -142,7 +142,7 @@ unsigned int ext2fs_bitcount(const void *addr, unsigned int nbytes)
res += popcount8(*cp++);
nbytes--;
}
- p = (__u32 *) cp;
+ p = (const __u32 *) cp;
while (nbytes > 4) {
res += popcount32(*p++);
diff --git a/lib/ext2fs/bitops.h b/lib/ext2fs/bitops.h
index 1559539f..edf82f2c 100644
--- a/lib/ext2fs/bitops.h
+++ b/lib/ext2fs/bitops.h
@@ -54,6 +54,14 @@ extern void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
int code, unsigned long arg);
#ifdef NO_INLINE_FUNCS
+extern void ext2fs_fast_set_bit(unsigned int nr,void * addr);
+extern void ext2fs_fast_clear_bit(unsigned int nr, void * addr);
+extern void ext2fs_fast_set_bit64(__u64 nr,void * addr);
+extern void ext2fs_fast_clear_bit64(__u64 nr, void * addr);
+extern __u16 ext2fs_swab16(__u16 val);
+extern __u32 ext2fs_swab32(__u32 val);
+extern __u64 ext2fs_swab64(__u64 val);
+
extern int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block);
extern int ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block);
@@ -650,14 +658,3 @@ extern int ext2fs_set_bit64(__u64 nr,void * addr);
extern int ext2fs_clear_bit64(__u64 nr, void * addr);
extern int ext2fs_test_bit64(__u64 nr, const void * addr);
extern unsigned int ext2fs_bitcount(const void *addr, unsigned int nbytes);
-
-#ifdef NO_INLINE_FUNCS
-extern void ext2fs_fast_set_bit(unsigned int nr,void * addr);
-extern void ext2fs_fast_clear_bit(unsigned int nr, void * addr);
-extern void ext2fs_fast_set_bit64(__u64 nr,void * addr);
-extern void ext2fs_fast_clear_bit64(__u64 nr, void * addr);
-extern __u16 ext2fs_swab16(__u16 val);
-extern __u32 ext2fs_swab32(__u32 val);
-extern __u64 ext2fs_swab64(__u64 val);
-#endif
-
diff --git a/lib/ext2fs/blkmap64_rb.c b/lib/ext2fs/blkmap64_rb.c
index 702187fa..9c1abc57 100644
--- a/lib/ext2fs/blkmap64_rb.c
+++ b/lib/ext2fs/blkmap64_rb.c
@@ -47,6 +47,17 @@ struct ext2fs_rb_private {
#endif
};
+inline static struct bmap_rb_extent *node_to_extent(struct rb_node *node)
+{
+ /*
+ * This depends on the fact the struct rb_node is at the
+ * beginning of the bmap_rb_extent structure. We use this
+ * instead of the ext2fs_rb_entry macro because it causes gcc
+ * -Wall to generate a huge amount of noise.
+ */
+ return (struct bmap_rb_extent *) node;
+}
+
static int rb_insert_extent(__u64 start, __u64 count,
struct ext2fs_rb_private *);
static void rb_get_new_extent(struct bmap_rb_extent **, __u64, __u64);
@@ -63,7 +74,7 @@ static void print_tree(struct rb_root *root)
node = ext2fs_rb_first(root);
for (node = ext2fs_rb_first(root); node != NULL;
node = ext2fs_rb_next(node)) {
- ext = ext2fs_rb_entry(node, struct bmap_rb_extent, node);
+ ext = node_to_extent(node);
printf("\t\t\t--> (%llu -> %llu)\n",
ext->start, ext->start + ext->count);
}
@@ -77,7 +88,7 @@ static void check_tree(struct rb_root *root, const char *msg)
for (node = ext2fs_rb_first(root); node;
node = ext2fs_rb_next(node)) {
- ext = ext2fs_rb_entry(node, struct bmap_rb_extent, node);
+ ext = node_to_extent(node);
if (ext->count <= 0) {
printf("Tree Error: count is crazy\n");
printf("extent: %llu -> %llu (%u)\n", ext->start,
@@ -198,7 +209,7 @@ static void rb_free_tree(struct rb_root *root)
for (node = ext2fs_rb_first(root); node; node = next) {
next = ext2fs_rb_next(node);
- ext = ext2fs_rb_entry(node, struct bmap_rb_extent, node);
+ ext = node_to_extent(node);
ext2fs_rb_erase(node, root);
ext2fs_free_mem(&ext);
}
@@ -234,7 +245,7 @@ static errcode_t rb_copy_bmap(ext2fs_generic_bitmap src,
src_node = ext2fs_rb_first(&src_bp->root);
while (src_node) {
- src_ext = ext2fs_rb_entry(src_node, struct bmap_rb_extent, node);
+ src_ext = node_to_extent(src_node);
retval = ext2fs_get_mem(sizeof (struct bmap_rb_extent),
&dest_ext);
if (retval)
@@ -267,7 +278,7 @@ static void rb_truncate(__u64 new_max, struct rb_root *root)
node = ext2fs_rb_last(root);
while (node) {
- ext = ext2fs_rb_entry(node, struct bmap_rb_extent, node);
+ ext = node_to_extent(node);
if ((ext->start + ext->count - 1) <= new_max)
break;
@@ -328,8 +339,7 @@ rb_test_bit(struct ext2fs_rb_private *bp, __u64 bit)
if (!next_ext) {
next = ext2fs_rb_next(&rcursor->node);
if (next)
- next_ext = ext2fs_rb_entry(next, struct bmap_rb_extent,
- node);
+ next_ext = node_to_extent(next);
bp->rcursor_next = next_ext;
}
if (next_ext) {
@@ -355,7 +365,7 @@ search_tree:
while (*n) {
parent = *n;
- ext = ext2fs_rb_entry(parent, struct bmap_rb_extent, node);
+ ext = node_to_extent(parent);
if (bit < ext->start)
n = &(*n)->rb_left;
else if (bit >= (ext->start + ext->count))
@@ -393,7 +403,7 @@ static int rb_insert_extent(__u64 start, __u64 count,
while (*n) {
parent = *n;
- ext = ext2fs_rb_entry(parent, struct bmap_rb_extent, node);
+ ext = node_to_extent(parent);
if (start < ext->start) {
n = &(*n)->rb_left;
@@ -427,7 +437,7 @@ got_extent:
node = ext2fs_rb_prev(new_node);
if (node) {
- ext = ext2fs_rb_entry(node, struct bmap_rb_extent, node);
+ ext = node_to_extent(node);
if ((ext->start + ext->count) == start) {
start = ext->start;
count += ext->count;
@@ -440,7 +450,7 @@ skip_insert:
/* See if we can merge extent to the right */
for (node = ext2fs_rb_next(new_node); node != NULL; node = next) {
next = ext2fs_rb_next(node);
- ext = ext2fs_rb_entry(node, struct bmap_rb_extent, node);
+ ext = node_to_extent(node);
if ((ext->start + ext->count) <= start)
continue;
@@ -485,7 +495,7 @@ static int rb_remove_extent(__u64 start, __u64 count,
while (*n) {
parent = *n;
- ext = ext2fs_rb_entry(parent, struct bmap_rb_extent, node);
+ ext = node_to_extent(parent);
if (start < ext->start) {
n = &(*n)->rb_left;
continue;
@@ -528,7 +538,7 @@ static int rb_remove_extent(__u64 start, __u64 count,
/* See if we should delete or truncate extent on the right */
for (; parent != NULL; parent = node) {
node = ext2fs_rb_next(parent);
- ext = ext2fs_rb_entry(parent, struct bmap_rb_extent, node);
+ ext = node_to_extent(parent);
if ((ext->start + ext->count) <= start)
continue;
@@ -635,7 +645,7 @@ static int rb_test_clear_bmap_extent(ext2fs_generic_bitmap bitmap,
*/
while (*n) {
parent = *n;
- ext = ext2fs_rb_entry(parent, struct bmap_rb_extent, node);
+ ext = node_to_extent(parent);
if (start < ext->start) {
n = &(*n)->rb_left;
} else if (start >= (ext->start + ext->count)) {
@@ -652,7 +662,7 @@ static int rb_test_clear_bmap_extent(ext2fs_generic_bitmap bitmap,
node = parent;
while (node) {
next = ext2fs_rb_next(node);
- ext = ext2fs_rb_entry(node, struct bmap_rb_extent, node);
+ ext = node_to_extent(node);
node = next;
if ((ext->start + ext->count) <= start)
@@ -730,7 +740,7 @@ static errcode_t rb_get_bmap_range(ext2fs_generic_bitmap bitmap,
while (*n) {
parent = *n;
- ext = ext2fs_rb_entry(parent, struct bmap_rb_extent, node);
+ ext = node_to_extent(parent);
if (start < ext->start) {
n = &(*n)->rb_left;
} else if (start >= (ext->start + ext->count)) {
@@ -743,7 +753,7 @@ static errcode_t rb_get_bmap_range(ext2fs_generic_bitmap bitmap,
for (; parent != NULL; parent = next) {
next = ext2fs_rb_next(parent);
- ext = ext2fs_rb_entry(parent, struct bmap_rb_extent, node);
+ ext = node_to_extent(parent);
pos = ext->start;
count = ext->count;
@@ -764,7 +774,7 @@ static errcode_t rb_get_bmap_range(ext2fs_generic_bitmap bitmap,
int nbytes = count >> 3;
int offset = (pos - start) >> 3;
- memset(out + offset, 0xFF, nbytes);
+ memset(((char *) out) + offset, 0xFF, nbytes);
pos += nbytes << 3;
count -= nbytes << 3;
continue;
@@ -810,7 +820,7 @@ static void rb_print_stats(ext2fs_generic_bitmap bitmap)
node = ext2fs_rb_first(&bp->root);
for (node = ext2fs_rb_first(&bp->root); node != NULL;
node = ext2fs_rb_next(node)) {
- ext = ext2fs_rb_entry(node, struct bmap_rb_extent, node);
+ ext = node_to_extent(node);
count++;
if (ext->count > max_size)
max_size = ext->count;
diff --git a/lib/ext2fs/block.c b/lib/ext2fs/block.c
index 68dcb03f..b8c68798 100644
--- a/lib/ext2fs/block.c
+++ b/lib/ext2fs/block.c
@@ -472,9 +472,9 @@ errcode_t ext2fs_block_iterate3(ext2_filsys fs,
extent.e_lblk, extent.e_pblk,
extent.e_len, blockcnt);
#endif
- if (extent.e_lblk + extent.e_len <= blockcnt)
+ if (extent.e_lblk + extent.e_len <= (blk64_t) blockcnt)
continue;
- if (extent.e_lblk > blockcnt)
+ if (extent.e_lblk > (blk64_t) blockcnt)
blockcnt = extent.e_lblk;
j = blockcnt - extent.e_lblk;
blk += j;
diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c
index 44ac4999..2880afa2 100644
--- a/lib/ext2fs/gen_bitmap64.c
+++ b/lib/ext2fs/gen_bitmap64.c
@@ -174,7 +174,7 @@ errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic,
}
#ifdef ENABLE_BMAP_STATS
-void ext2fs_print_bmap_statistics(ext2fs_generic_bitmap bitmap)
+static void ext2fs_print_bmap_statistics(ext2fs_generic_bitmap bitmap)
{
struct ext2_bmap_statistics *stats = &bitmap->stats;
#ifdef ENABLE_BMAP_STATS_OPS
diff --git a/lib/ext2fs/mmp.c b/lib/ext2fs/mmp.c
index d09178e6..00f3461b 100644
--- a/lib/ext2fs/mmp.c
+++ b/lib/ext2fs/mmp.c
@@ -63,7 +63,8 @@ errcode_t ext2fs_mmp_read(ext2_filsys fs, blk64_t mmp_blk, void *buf)
return retval;
}
- if (ext2fs_llseek(fs->mmp_fd, mmp_blk * fs->blocksize, SEEK_SET) !=
+ if ((blk64_t) ext2fs_llseek(fs->mmp_fd, mmp_blk * fs->blocksize,
+ SEEK_SET) !=
mmp_blk * fs->blocksize) {
retval = EXT2_ET_LLSEEK_FAILED;
goto out;
diff --git a/lib/ext2fs/rbtree.c b/lib/ext2fs/rbtree.c
index 7467e10e..94393030 100644
--- a/lib/ext2fs/rbtree.c
+++ b/lib/ext2fs/rbtree.c
@@ -375,7 +375,7 @@ struct rb_node *ext2fs_rb_last(const struct rb_root *root)
return n;
}
-struct rb_node *ext2fs_rb_next(const struct rb_node *node)
+struct rb_node *ext2fs_rb_next(struct rb_node *node)
{
struct rb_node *parent;
@@ -403,7 +403,7 @@ struct rb_node *ext2fs_rb_next(const struct rb_node *node)
return parent;
}
-struct rb_node *ext2fs_rb_prev(const struct rb_node *node)
+struct rb_node *ext2fs_rb_prev(struct rb_node *node)
{
struct rb_node *parent;
diff --git a/lib/ext2fs/rbtree.h b/lib/ext2fs/rbtree.h
index 16defb52..3b0b0784 100644
--- a/lib/ext2fs/rbtree.h
+++ b/lib/ext2fs/rbtree.h
@@ -158,8 +158,8 @@ extern void ext2fs_rb_augment_erase_end(struct rb_node *node,
rb_augment_f func, void *data);
/* Find logical next and previous nodes in a tree */
-extern struct rb_node *ext2fs_rb_next(const struct rb_node *);
-extern struct rb_node *ext2fs_rb_prev(const struct rb_node *);
+extern struct rb_node *ext2fs_rb_next(struct rb_node *);
+extern struct rb_node *ext2fs_rb_prev(struct rb_node *);
extern struct rb_node *ext2fs_rb_first(const struct rb_root *);
extern struct rb_node *ext2fs_rb_last(const struct rb_root *);
diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c
index a885c696..cc14aaf8 100644
--- a/lib/ext2fs/rw_bitmaps.c
+++ b/lib/ext2fs/rw_bitmaps.c
@@ -174,7 +174,8 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
- if ((block_nbytes > fs->blocksize) || (inode_nbytes > fs->blocksize))
+ if ((block_nbytes > (int) fs->blocksize) ||
+ (inode_nbytes > (int) fs->blocksize))
return EXT2_ET_CORRUPT_SUPERBLOCK;
fs->write_bitmaps = ext2fs_write_bitmaps;
diff --git a/lib/ext2fs/symlink.c b/lib/ext2fs/symlink.c
index da6e3a8a..e943412e 100644
--- a/lib/ext2fs/symlink.c
+++ b/lib/ext2fs/symlink.c
@@ -37,7 +37,7 @@ errcode_t ext2fs_symlink(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t ino,
ext2_ino_t scratch_ino;
blk64_t blk;
int fastlink;
- int target_len;
+ unsigned int target_len;
char *block_buf = 0;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
diff --git a/lib/quota/quotaio.h b/lib/quota/quotaio.h
index 5a7db7b1..1c062f10 100644
--- a/lib/quota/quotaio.h
+++ b/lib/quota/quotaio.h
@@ -132,11 +132,6 @@ struct quotafile_ops {
/* This might go into a special header file but that sounds a bit silly... */
extern struct quotafile_ops quotafile_ops_meta;
-static inline void mark_quotafile_info_dirty(struct quota_handle *h)
-{
- h->qh_io_flags |= IOFL_INFODIRTY;
-}
-
/* Open existing quotafile of given type (and verify its format) on given
* filesystem. */
errcode_t quota_file_open(struct quota_handle *h, ext2_filsys fs,
diff --git a/lib/quota/quotaio_tree.c b/lib/quota/quotaio_tree.c
index e7aea3bd..c1653a39 100644
--- a/lib/quota/quotaio_tree.c
+++ b/lib/quota/quotaio_tree.c
@@ -53,6 +53,11 @@ static int get_index(qid_t id, int depth)
return (id >> ((QT_TREEDEPTH - depth - 1) * 8)) & 0xff;
}
+static inline void mark_quotafile_info_dirty(struct quota_handle *h)
+{
+ h->qh_io_flags |= IOFL_INFODIRTY;
+}
+
/* Read given block */
static void read_blk(struct quota_handle *h, uint blk, dqbuf_t buf)
{
diff --git a/misc/badblocks.c b/misc/badblocks.c
index f37cf269..c9e47c7c 100644
--- a/misc/badblocks.c
+++ b/misc/badblocks.c
@@ -557,7 +557,7 @@ static unsigned int test_ro (int dev, blk_t last_block,
currently_testing += got;
if (got != try) {
try = 1;
- if (recover_block == ~0)
+ if (recover_block == ~0U)
recover_block = currently_testing - got +
blocks_at_once;
continue;
@@ -647,7 +647,7 @@ static unsigned int test_rw (int dev, blk_t last_block,
currently_testing += got;
if (got != try) {
try = 1;
- if (recover_block == ~0)
+ if (recover_block == ~0U)
recover_block = currently_testing -
got + blocks_at_once;
continue;
@@ -686,13 +686,13 @@ static unsigned int test_rw (int dev, blk_t last_block,
currently_testing += got;
if (got != try) {
try = 1;
- if (recover_block == ~0)
+ if (recover_block == ~0U)
recover_block = currently_testing -
got + blocks_at_once;
continue;
} else if (currently_testing == recover_block) {
try = blocks_at_once;
- recover_block = ~0;
+ recover_block = ~0U;
}
for (i=0; i < got; i++) {
if (memcmp(read_buffer + i * block_size,
@@ -739,8 +739,8 @@ static unsigned int test_nd (int dev, blk_t last_block,
errcode_t errcode;
unsigned long buf_used;
static unsigned int bb_count;
- int granularity = blocks_at_once;
- blk_t recover_block = ~0;
+ unsigned int granularity = blocks_at_once;
+ blk_t recover_block = ~0U;
bb_count = 0;
errcode = ext2fs_badblocks_list_iterate_begin(bb_list,&bb_iter);
@@ -839,7 +839,7 @@ static unsigned int test_nd (int dev, blk_t last_block,
got = do_read (dev, save_ptr, try, block_size,
currently_testing);
if (got == 0) {
- if (recover_block == ~0)
+ if (recover_block == ~0U)
recover_block = currently_testing +
blocks_at_once;
if (granularity != 1) {
@@ -874,7 +874,7 @@ static unsigned int test_nd (int dev, blk_t last_block,
currently_testing += got;
if (got != try) {
try = 1;
- if (recover_block == ~0)
+ if (recover_block == ~0U)
recover_block = currently_testing -
got + blocks_at_once;
continue;
diff --git a/misc/e2image.c b/misc/e2image.c
index 70bb9ac2..369c9468 100644
--- a/misc/e2image.c
+++ b/misc/e2image.c
@@ -453,7 +453,7 @@ static void scramble_dir_block(ext2_filsys fs, blk64_t blk, char *buf)
#endif
continue;
}
- if (dirent->name_len + 8 > rec_len) {
+ if (dirent->name_len + 8U > rec_len) {
printf("Corrupt directory block %lu: "
"bad name_len (%d)\n", (unsigned long) blk,
dirent->name_len);
diff --git a/misc/filefrag.c b/misc/filefrag.c
index ee03a07a..35b35441 100644
--- a/misc/filefrag.c
+++ b/misc/filefrag.c
@@ -52,8 +52,8 @@ int force_bmap; /* force use of FIBMAP instead of FIEMAP */
int force_extent; /* print output in extent format always */
int logical_width = 8;
int physical_width = 10;
-char *ext_fmt = "%4d: %*llu..%*llu: %*llu..%*llu: %6llu: %s\n";
-char *hex_fmt = "%4d: %*llx..%*llx: %*llx..%*llx: %6llx: %s\n";
+const char *ext_fmt = "%4d: %*llu..%*llu: %*llu..%*llu: %6llu: %s\n";
+const char *hex_fmt = "%4d: %*llx..%*llx: %*llx..%*llx: %6llx: %s\n";
#define FILEFRAG_FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR)
@@ -166,7 +166,7 @@ static void print_extent_info(struct fiemap_extent *fm_extent, int cur_ex,
if (fm_extent->fe_flags & FIEMAP_EXTENT_MERGED)
strcat(flags, "merged,");
- if (fm_extent->fe_logical + fm_extent->fe_length >= st->st_size)
+ if (fm_extent->fe_logical + fm_extent->fe_length >= (__u64) st->st_size)
strcat(flags, "eof,");
/* Remove trailing comma, if any */
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 7ff759dc..a59d24cc 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -1004,7 +1004,7 @@ static void print_str_list(char **list)
/*
* Return TRUE if the profile has the given subsection
*/
-static int profile_has_subsection(profile_t profile, const char *section,
+static int profile_has_subsection(profile_t prof, const char *section,
const char *subsection)
{
void *state;
@@ -1016,7 +1016,7 @@ static int profile_has_subsection(profile_t profile, const char *section,
names[1] = subsection;
names[2] = 0;
- if (profile_iterator_create(profile, names,
+ if (profile_iterator_create(prof, names,
PROFILE_ITER_LIST_SECTION |
PROFILE_ITER_RELATIONS_ONLY, &state))
return 0;
@@ -1032,7 +1032,7 @@ static int profile_has_subsection(profile_t profile, const char *section,
static char **parse_fs_type(const char *fs_type,
const char *usage_types,
- struct ext2_super_block *fs_param,
+ struct ext2_super_block *sb,
blk64_t fs_blocks_count,
char *progname)
{
@@ -1095,7 +1095,7 @@ static char **parse_fs_type(const char *fs_type,
}
}
- meg = (1024 * 1024) / EXT2_BLOCK_SIZE(fs_param);
+ meg = (1024 * 1024) / EXT2_BLOCK_SIZE(sb);
if (fs_blocks_count < 3 * meg)
size_type = "floppy";
else if (fs_blocks_count < 512 * meg)
@@ -1136,10 +1136,8 @@ static char **parse_fs_type(const char *fs_type,
}
if (t)
cp = t+1;
- else {
- cp = "";
+ else
break;
- }
}
free(parse_str);
free(profile_type);
@@ -1148,15 +1146,15 @@ static char **parse_fs_type(const char *fs_type,
return (list.list);
}
-static char *get_string_from_profile(char **fs_types, const char *opt,
+static char *get_string_from_profile(char **types, const char *opt,
const char *def_val)
{
char *ret = 0;
int i;
- for (i=0; fs_types[i]; i++);
+ for (i=0; types[i]; i++);
for (i-=1; i >=0 ; i--) {
- profile_get_string(profile, "fs_types", fs_types[i],
+ profile_get_string(profile, "fs_types", types[i],
opt, 0, &ret);
if (ret)
return ret;
@@ -1165,36 +1163,36 @@ static char *get_string_from_profile(char **fs_types, const char *opt,
return (ret);
}
-static int get_int_from_profile(char **fs_types, const char *opt, int def_val)
+static int get_int_from_profile(char **types, const char *opt, int def_val)
{
int ret;
char **cpp;
profile_get_integer(profile, "defaults", opt, 0, def_val, &ret);
- for (cpp = fs_types; *cpp; cpp++)
+ for (cpp = types; *cpp; cpp++)
profile_get_integer(profile, "fs_types", *cpp, opt, ret, &ret);
return ret;
}
-static double get_double_from_profile(char **fs_types, const char *opt,
+static double get_double_from_profile(char **types, const char *opt,
double def_val)
{
double ret;
char **cpp;
profile_get_double(profile, "defaults", opt, 0, def_val, &ret);
- for (cpp = fs_types; *cpp; cpp++)
+ for (cpp = types; *cpp; cpp++)
profile_get_double(profile, "fs_types", *cpp, opt, ret, &ret);
return ret;
}
-static int get_bool_from_profile(char **fs_types, const char *opt, int def_val)
+static int get_bool_from_profile(char **types, const char *opt, int def_val)
{
int ret;
char **cpp;
profile_get_boolean(profile, "defaults", opt, 0, def_val, &ret);
- for (cpp = fs_types; *cpp; cpp++)
+ for (cpp = types; *cpp; cpp++)
profile_get_boolean(profile, "fs_types", *cpp, opt, ret, &ret);
return ret;
}
@@ -2119,7 +2117,7 @@ profile_error:
fs_param.s_inodes_count = num_inodes ? num_inodes :
(ext2fs_blocks_count(&fs_param) * blocksize) / inode_ratio;
- if ((((long long)fs_param.s_inodes_count) *
+ if ((((unsigned long long)fs_param.s_inodes_count) *
(inode_size ? inode_size : EXT2_GOOD_OLD_INODE_SIZE)) >=
((ext2fs_blocks_count(&fs_param)) *
EXT2_BLOCK_SIZE(&fs_param))) {
@@ -2200,7 +2198,7 @@ static int mke2fs_setup_tdb(const char *name, io_manager *io_ptr)
{
errcode_t retval = ENOMEM;
char *tdb_dir = NULL, *tdb_file = NULL;
- char *device_name, *tmp_name;
+ char *dev_name, *tmp_name;
int free_tdb_dir = 0;
/*
@@ -2222,13 +2220,13 @@ static int mke2fs_setup_tdb(const char *name, io_manager *io_ptr)
tmp_name = strdup(name);
if (!tmp_name)
goto errout;
- device_name = basename(tmp_name);
- tdb_file = malloc(strlen(tdb_dir) + 8 + strlen(device_name) + 7 + 1);
+ dev_name = basename(tmp_name);
+ tdb_file = malloc(strlen(tdb_dir) + 8 + strlen(dev_name) + 7 + 1);
if (!tdb_file) {
free(tmp_name);
goto errout;
}
- sprintf(tdb_file, "%s/mke2fs-%s.e2undo", tdb_dir, device_name);
+ sprintf(tdb_file, "%s/mke2fs-%s.e2undo", tdb_dir, dev_name);
free(tmp_name);
if (!access(tdb_file, F_OK)) {
@@ -2312,10 +2310,11 @@ static int mke2fs_discard_device(ext2_filsys fs)
static void fix_cluster_bg_counts(ext2_filsys fs)
{
blk64_t cluster, num_clusters, tot_free;
- int grp_free, num_free, group, num;
+ unsigned num = 0;
+ int grp_free, num_free, group;
num_clusters = EXT2FS_B2C(fs, ext2fs_blocks_count(fs->super));
- tot_free = num_free = num = group = grp_free = 0;
+ tot_free = num_free = group = grp_free = 0;
for (cluster = EXT2FS_B2C(fs, fs->super->s_first_data_block);
cluster < num_clusters; cluster++) {
if (!ext2fs_test_block_bitmap2(fs->block_map,
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 332aafd4..4f8cedca 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -698,7 +698,7 @@ static void rewrite_inodes(ext2_filsys fs)
static void rewrite_metadata_checksums(ext2_filsys fs)
{
- int i;
+ dgrp_t i;
fs->flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS;
ext2fs_init_csum_seed(fs);
@@ -722,7 +722,7 @@ static void rewrite_metadata_checksums(ext2_filsys fs)
static void enable_uninit_bg(ext2_filsys fs)
{
struct ext2_group_desc *gd;
- int i;
+ dgrp_t i;
for (i = 0; i < fs->group_desc_count; i++) {
gd = ext2fs_group_desc(fs, fs->group_desc, i);
@@ -736,7 +736,7 @@ static void enable_uninit_bg(ext2_filsys fs)
static void disable_uninit_bg(ext2_filsys fs, __u32 csum_feature_flag)
{
struct ext2_group_desc *gd;
- int i;
+ dgrp_t i;
/* Load bitmaps to ensure that the uninit ones get written out */
fs->super->s_feature_ro_compat |= csum_feature_flag;
@@ -1127,7 +1127,7 @@ err:
return 1;
}
-void handle_quota_options(ext2_filsys fs)
+static void handle_quota_options(ext2_filsys fs)
{
quota_ctx_t qctx;
ext2_ino_t qf_ino;
@@ -1177,7 +1177,7 @@ void handle_quota_options(ext2_filsys fs)
return;
}
-void parse_quota_opts(const char *opts)
+static void parse_quota_opts(const char *opts)
{
char *buf, *token, *next, *p;
int len;
@@ -1579,12 +1579,12 @@ static int parse_extended_opts(ext2_filsys fs, const char *opts)
strcmp(token, "clear_mmp") == 0) {
clear_mmp = 1;
} else if (strcmp(token, "mmp_update_interval") == 0) {
- unsigned long interval;
+ unsigned long intv;
if (!arg) {
r_usage++;
continue;
}
- interval = strtoul(arg, &p, 0);
+ intv = strtoul(arg, &p, 0);
if (*p) {
fprintf(stderr,
_("Invalid mmp_update_interval: %s\n"),
@@ -1592,21 +1592,21 @@ static int parse_extended_opts(ext2_filsys fs, const char *opts)
r_usage++;
continue;
}
- if (interval == 0) {
- interval = EXT4_MMP_UPDATE_INTERVAL;
- } else if (interval > EXT4_MMP_MAX_UPDATE_INTERVAL) {
+ if (intv == 0) {
+ intv = EXT4_MMP_UPDATE_INTERVAL;
+ } else if (intv > EXT4_MMP_MAX_UPDATE_INTERVAL) {
fprintf(stderr,
_("mmp_update_interval too big: %lu\n"),
- interval);
+ intv);
r_usage++;
continue;
}
printf(P_("Setting multiple mount protection update "
"interval to %lu second\n",
"Setting multiple mount protection update "
- "interval to %lu seconds\n", interval),
- interval);
- fs->super->s_mmp_update_interval = interval;
+ "interval to %lu seconds\n", intv),
+ intv);
+ fs->super->s_mmp_update_interval = intv;
ext2fs_mark_super_dirty(fs);
} else if (!strcmp(token, "test_fs")) {
fs->super->s_flags |= EXT2_FLAGS_TEST_FILESYS;