Fix unused-but-set errors in gcc-4.6

gcc-4.6 (as shipped in Fedora) turns on -Wunused-but-set-variable by
default, which breaks the build when combined with -Wall, e.g.:

debug-tree.c: In function ‘print_extent_leaf’:
debug-tree.c:45:13: error: variable ‘last_len’ set but not used [-Werror=unused-but-set-variable]
debug-tree.c:44:13: error: variable ‘last’ set but not used [-Werror=unused-but-set-variable]
debug-tree.c:41:21: error: variable ‘item’ set but not used [-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors

This patch fixes the errors by removing the unused variables.

Signed-off-by: Chris Ball <cjb@laptop.org>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
master
Chris Ball 2011-03-07 10:05:21 -05:00 committed by Chris Mason
parent 29e6fc2aa6
commit fcdc0929c6
12 changed files with 6 additions and 126 deletions

View File

@ -41,7 +41,6 @@ struct extent_buffer *debug_read_block(struct btrfs_root *root, u64 bytenr,
u32 blocksize, int copy)
{
int ret;
int dev_nr;
struct extent_buffer *eb;
u64 length;
struct btrfs_multi_bio *multi = NULL;
@ -53,7 +52,6 @@ struct extent_buffer *debug_read_block(struct btrfs_root *root, u64 bytenr,
if (!eb)
return NULL;
dev_nr = 0;
length = blocksize;
while (1) {
ret = btrfs_map_block(&root->fs_info->mapping_tree, READ,

View File

@ -1037,7 +1037,7 @@ static int process_one_leaf(struct btrfs_root *root, struct extent_buffer *eb,
break;
};
}
return 0;
return ret;
}
static void reada_walk_down(struct btrfs_root *root,
@ -1917,7 +1917,6 @@ static int check_owner_ref(struct btrfs_root *root,
struct btrfs_root *ref_root;
struct btrfs_key key;
struct btrfs_path path;
int ret;
int level;
int found = 0;
@ -1950,7 +1949,7 @@ static int check_owner_ref(struct btrfs_root *root,
btrfs_init_path(&path);
path.lowest_level = level + 1;
ret = btrfs_search_slot(NULL, ref_root, &key, &path, 0, 0);
btrfs_search_slot(NULL, ref_root, &key, &path, 0, 0);
if (buf->start == btrfs_node_blockptr(path.nodes[level + 1],
path.slots[level + 1]))
@ -2539,16 +2538,6 @@ static int run_next_block(struct btrfs_root *root,
continue;
}
if (key.type == BTRFS_BLOCK_GROUP_ITEM_KEY) {
struct btrfs_block_group_item *bi;
bi = btrfs_item_ptr(buf, i,
struct btrfs_block_group_item);
#if 0
fprintf(stderr,"block group %Lu %Lu used %Lu ",
btrfs_disk_key_objectid(disk_key),
btrfs_disk_key_offset(disk_key),
btrfs_block_group_used(bi));
fprintf(stderr, "flags %x\n", bi->flags);
#endif
continue;
}
if (key.type == BTRFS_EXTENT_REF_V0_KEY) {

16
ctree.c
View File

@ -262,7 +262,6 @@ int __btrfs_cow_block(struct btrfs_trans_handle *trans,
struct extent_buffer **cow_ret,
u64 search_start, u64 empty_size)
{
u64 generation;
struct extent_buffer *cow;
struct btrfs_disk_key disk_key;
int level;
@ -272,7 +271,6 @@ int __btrfs_cow_block(struct btrfs_trans_handle *trans,
WARN_ON(root->ref_cows && trans->transid != root->last_trans);
level = btrfs_header_level(buf);
generation = btrfs_header_generation(buf);
if (level == 0)
btrfs_item_key(buf, &disk_key, 0);
@ -795,7 +793,6 @@ static int balance_level(struct btrfs_trans_handle *trans,
int wret;
int pslot;
int orig_slot = path->slots[level];
int err_on_enospc = 0;
u64 orig_ptr;
if (level == 0)
@ -845,9 +842,6 @@ static int balance_level(struct btrfs_trans_handle *trans,
BTRFS_NODEPTRS_PER_BLOCK(root) / 4)
return 0;
if (btrfs_header_nritems(mid) < 2)
err_on_enospc = 1;
left = read_node_slot(root, parent, pslot - 1);
if (left) {
wret = btrfs_cow_block(trans, root, left,
@ -873,8 +867,6 @@ static int balance_level(struct btrfs_trans_handle *trans,
wret = push_node_left(trans, root, left, mid, 1);
if (wret < 0)
ret = wret;
if (btrfs_header_nritems(mid) < 2)
err_on_enospc = 1;
}
/*
@ -996,14 +988,12 @@ static int noinline push_nodes_for_insert(struct btrfs_trans_handle *trans,
int wret;
int pslot;
int orig_slot = path->slots[level];
u64 orig_ptr;
if (level == 0)
return 1;
mid = path->nodes[level];
WARN_ON(btrfs_header_generation(mid) != trans->transid);
orig_ptr = btrfs_node_blockptr(mid, orig_slot);
if (level < BTRFS_MAX_LEVEL - 1)
parent = path->nodes[level + 1];
@ -2370,7 +2360,6 @@ int btrfs_truncate_item(struct btrfs_trans_handle *trans,
{
int ret = 0;
int slot;
int slot_orig;
struct extent_buffer *leaf;
struct btrfs_item *item;
u32 nritems;
@ -2380,7 +2369,6 @@ int btrfs_truncate_item(struct btrfs_trans_handle *trans,
unsigned int size_diff;
int i;
slot_orig = path->slots[0];
leaf = path->nodes[0];
slot = path->slots[0];
@ -2468,7 +2456,6 @@ int btrfs_extend_item(struct btrfs_trans_handle *trans,
{
int ret = 0;
int slot;
int slot_orig;
struct extent_buffer *leaf;
struct btrfs_item *item;
u32 nritems;
@ -2477,7 +2464,6 @@ int btrfs_extend_item(struct btrfs_trans_handle *trans,
unsigned int old_size;
int i;
slot_orig = path->slots[0];
leaf = path->nodes[0];
nritems = btrfs_header_nritems(leaf);
@ -2541,7 +2527,6 @@ int btrfs_insert_empty_items(struct btrfs_trans_handle *trans,
struct btrfs_item *item;
int ret = 0;
int slot;
int slot_orig;
int i;
u32 nritems;
u32 total_size = 0;
@ -2565,7 +2550,6 @@ int btrfs_insert_empty_items(struct btrfs_trans_handle *trans,
if (ret < 0)
goto out;
slot_orig = path->slots[0];
leaf = path->nodes[0];
nritems = btrfs_header_nritems(leaf);

View File

@ -35,44 +35,6 @@ static int print_usage(void)
exit(1);
}
static void print_extent_leaf(struct btrfs_root *root, struct extent_buffer *l)
{
int i;
struct btrfs_item *item;
// struct btrfs_extent_ref *ref;
struct btrfs_key key;
static u64 last = 0;
static u64 last_len = 0;
u32 nr = btrfs_header_nritems(l);
u32 type;
for (i = 0 ; i < nr ; i++) {
item = btrfs_item_nr(l, i);
btrfs_item_key_to_cpu(l, &key, i);
type = btrfs_key_type(&key);
switch (type) {
case BTRFS_EXTENT_ITEM_KEY:
last_len = key.offset;
last = key.objectid;
break;
#if 0
case BTRFS_EXTENT_REF_KEY:
ref = btrfs_item_ptr(l, i, struct btrfs_extent_ref);
printf("%llu %llu extent back ref root %llu gen %llu "
"owner %llu num_refs %lu\n",
(unsigned long long)last,
(unsigned long long)last_len,
(unsigned long long)btrfs_ref_root(l, ref),
(unsigned long long)btrfs_ref_generation(l, ref),
(unsigned long long)btrfs_ref_objectid(l, ref),
(unsigned long)btrfs_ref_num_refs(l, ref));
break;
#endif
};
fflush(stdout);
}
}
static void print_extents(struct btrfs_root *root, struct extent_buffer *eb)
{
int i;
@ -81,10 +43,7 @@ static void print_extents(struct btrfs_root *root, struct extent_buffer *eb)
if (!eb)
return;
if (btrfs_is_leaf(eb)) {
print_extent_leaf(root, eb);
return;
}
size = btrfs_level_size(root, btrfs_header_level(eb) - 1);
nr = btrfs_header_nritems(eb);
for (i = 0; i < nr; i++) {

View File

@ -332,5 +332,5 @@ int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans,
ret = btrfs_truncate_item(trans, root, path,
item_len - sub_item_len, 1);
}
return 0;
return ret;
}

View File

@ -123,7 +123,6 @@ int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize,
u64 parent_transid)
{
int ret;
int dev_nr;
struct extent_buffer *eb;
u64 length;
struct btrfs_multi_bio *multi = NULL;
@ -135,7 +134,6 @@ int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize,
return 0;
}
dev_nr = 0;
length = blocksize;
ret = btrfs_map_block(&root->fs_info->mapping_tree, READ,
bytenr, &length, &multi, 0);
@ -177,7 +175,6 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
u32 blocksize, u64 parent_transid)
{
int ret;
int dev_nr;
struct extent_buffer *eb;
u64 length;
struct btrfs_multi_bio *multi = NULL;
@ -192,7 +189,6 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
if (btrfs_buffer_uptodate(eb, parent_transid))
return eb;
dev_nr = 0;
length = blocksize;
while (1) {
ret = btrfs_map_block(&root->fs_info->mapping_tree, READ,

View File

@ -96,13 +96,11 @@ int insert_existing_cache_extent(struct cache_tree *tree,
struct cache_extent *pe)
{
struct rb_node *found;
struct cache_extent *entry;
found = tree_insert(&tree->root, pe->start, pe->size, &pe->rb_node);
if (found) {
entry = rb_entry(found, struct cache_extent, rb_node);
if (found)
return -EEXIST;
}
return 0;
}

View File

@ -1549,7 +1549,6 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
int i;
int level;
int ret = 0;
int faili = 0;
int (*process_func)(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
u64, u64, u64, u64, u64, u64);
@ -1592,7 +1591,6 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
parent, ref_root, key.objectid,
key.offset);
if (ret) {
faili = i;
WARN_ON(1);
goto fail;
}
@ -1602,7 +1600,6 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
ret = process_func(trans, root, bytenr, num_bytes,
parent, ref_root, level - 1, 0);
if (ret) {
faili = i;
WARN_ON(1);
goto fail;
}
@ -1611,33 +1608,6 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
return 0;
fail:
WARN_ON(1);
#if 0
for (i =0; i < faili; i++) {
if (level == 0) {
u64 disk_bytenr;
btrfs_item_key_to_cpu(buf, &key, i);
if (btrfs_key_type(&key) != BTRFS_EXTENT_DATA_KEY)
continue;
fi = btrfs_item_ptr(buf, i,
struct btrfs_file_extent_item);
if (btrfs_file_extent_type(buf, fi) ==
BTRFS_FILE_EXTENT_INLINE)
continue;
disk_bytenr = btrfs_file_extent_disk_bytenr(buf, fi);
if (disk_bytenr == 0)
continue;
err = btrfs_free_extent(trans, root, disk_bytenr,
btrfs_file_extent_disk_num_bytes(buf,
fi), 0);
BUG_ON(err);
} else {
bytenr = btrfs_node_blockptr(buf, i);
err = btrfs_free_extent(trans, root, bytenr,
btrfs_level_size(root, level - 1), 0);
BUG_ON(err);
}
}
#endif
return ret;
}

View File

@ -296,7 +296,6 @@ int set_extent_bits(struct extent_io_tree *tree, u64 start,
struct extent_state *prealloc = NULL;
struct cache_extent *node;
int err = 0;
int set;
u64 last_start;
u64 last_end;
again:
@ -327,7 +326,6 @@ again:
* Just lock what we found and keep going
*/
if (state->start == start && state->end <= end) {
set = state->state & bits;
state->state |= bits;
merge_state(tree, state);
if (last_end == (u64)-1)
@ -352,7 +350,6 @@ again:
* desired bit on it.
*/
if (state->start < start) {
set = state->state & bits;
err = split_state(tree, state, prealloc, start);
BUG_ON(err == -EEXIST);
prealloc = NULL;
@ -398,7 +395,6 @@ again:
* We need to split the extent, and set the bit
* on the first half
*/
set = state->state & bits;
err = split_state(tree, state, prealloc, end + 1);
BUG_ON(err == -EEXIST);

3
mkfs.c
View File

@ -1149,7 +1149,6 @@ int main(int ac, char **av)
int zero_end = 1;
int option_index = 0;
int fd;
int first_fd;
int ret;
int i;
int mixed = 0;
@ -1250,7 +1249,6 @@ int main(int ac, char **av)
fprintf(stderr, "unable to open %s\n", file);
exit(1);
}
first_fd = fd;
first_file = file;
ret = btrfs_prepare_device(fd, file, zero_end, &dev_block_count, &mixed);
if (block_count == 0)
@ -1264,7 +1262,6 @@ int main(int ac, char **av)
}
file = output;
first_fd = fd;
first_file = file;
block_count = size_sourcedir(source_dir, sectorsize,
&num_of_meta_chunks, &size_of_data);

View File

@ -444,7 +444,6 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
struct btrfs_dir_item *di;
struct btrfs_inode_item *ii;
struct btrfs_file_extent_item *fi;
struct btrfs_csum_item *ci;
struct btrfs_block_group_item *bi;
struct btrfs_extent_data_ref *dref;
struct btrfs_shared_data_ref *sref;
@ -556,11 +555,9 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
#endif
break;
case BTRFS_CSUM_ITEM_KEY:
ci = btrfs_item_ptr(l, i, struct btrfs_csum_item);
printf("\t\tcsum item\n");
break;
case BTRFS_EXTENT_CSUM_KEY:
ci = btrfs_item_ptr(l, i, struct btrfs_csum_item);
printf("\t\textent csum item\n");
break;
case BTRFS_EXTENT_DATA_KEY:

View File

@ -643,7 +643,6 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
struct list_head *cur;
struct map_lookup *map;
int min_stripe_size = 1 * 1024 * 1024;
u64 physical;
u64 calc_size = 8 * 1024 * 1024;
u64 min_free;
u64 max_chunk_size = 4 * calc_size;
@ -811,7 +810,6 @@ again:
btrfs_set_stack_stripe_devid(stripe, device->devid);
btrfs_set_stack_stripe_offset(stripe, dev_offset);
memcpy(stripe->dev_uuid, device->uuid, BTRFS_UUID_SIZE);
physical = dev_offset;
index++;
}
BUG_ON(!list_empty(&private_devs));
@ -971,14 +969,12 @@ int btrfs_num_copies(struct btrfs_mapping_tree *map_tree, u64 logical, u64 len)
struct cache_extent *ce;
struct map_lookup *map;
int ret;
u64 offset;
ce = find_first_cache_extent(&map_tree->cache_tree, logical);
BUG_ON(!ce);
BUG_ON(ce->start > logical || ce->start + ce->size < logical);
map = container_of(ce, struct map_lookup, ce);
offset = logical - ce->start;
if (map->type & (BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID1))
ret = map->num_stripes;
else if (map->type & BTRFS_BLOCK_GROUP_RAID10)