Btrfs: Fix variables set but not read (bugs found by gcc 4.6)
authorAndi Kleen <andi@firstfloor.org>
Fri, 29 Oct 2010 19:14:31 +0000 (15:14 -0400)
committerChris Mason <chris.mason@oracle.com>
Fri, 29 Oct 2010 19:14:31 +0000 (15:14 -0400)
These are all the cases where a variable is set, but not
read which are really bugs.

- Couple of incorrect error handling fixed.
- One incorrect use of a allocation policy
- Some other things

Still needs more review.

Found by gcc 4.6's new warnings.

[akpm@linux-foundation.org: fix build.  Might have been bitrot]
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: Chris Mason <chris.mason@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/dir-item.c
fs/btrfs/extent_io.c
fs/btrfs/inode.c
fs/btrfs/relocation.c
fs/btrfs/tree-log.c

index e9103b3baa49f4309c94eca9e0d7b7069665359c..f0cad5ae5be75679c273583b6c6f535118acc093 100644 (file)
@@ -427,5 +427,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;
 }
index 4c639e156296cbcf260f52342e2fd38fc9f58f1c..7dc31c39ca590485f788b73ad42f3eea12a0bf8c 100644 (file)
@@ -2779,6 +2779,8 @@ int extent_prepare_write(struct extent_io_tree *tree,
                                         NULL, 1,
                                         end_bio_extent_preparewrite, 0,
                                         0, 0);
+                       if (ret && !err)
+                               err = ret;
                        iocount++;
                        block_start = block_start + iosize;
                } else {
index 9f08136b10c45d12e7a619564ab048e94f842111..0aa24717cd588787d3fa3afecbd2540b94a5727c 100644 (file)
@@ -1389,7 +1389,7 @@ int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
 
        if (map_length < length + size)
                return 1;
-       return 0;
+       return ret;
 }
 
 /*
@@ -2709,8 +2709,8 @@ static int check_path_shared(struct btrfs_root *root,
 {
        struct extent_buffer *eb;
        int level;
-       int ret;
        u64 refs = 1;
+       int uninitialized_var(ret);
 
        for (level = 0; level < BTRFS_MAX_LEVEL; level++) {
                if (!path->nodes[level])
@@ -2723,7 +2723,7 @@ static int check_path_shared(struct btrfs_root *root,
                if (refs > 1)
                        return 1;
        }
-       return 0;
+       return ret; /* XXX callers? */
 }
 
 /*
index fd0714475db75501b4f1d7a5c77feee81c8a4b44..045c9c2b2d7ef7399f00370e4137d9da0b370836 100644 (file)
@@ -3094,6 +3094,8 @@ static int add_tree_block(struct reloc_control *rc,
                BUG_ON(item_size != sizeof(struct btrfs_extent_item_v0));
                ret = get_ref_objectid_v0(rc, path, extent_key,
                                          &ref_owner, NULL);
+               if (ret < 0)
+                       return ret;
                BUG_ON(ref_owner >= BTRFS_MAX_LEVEL);
                level = (int)ref_owner;
                /* FIXME: get real generation */
@@ -4218,7 +4220,7 @@ int btrfs_reloc_clone_csums(struct inode *inode, u64 file_pos, u64 len)
                btrfs_add_ordered_sum(inode, ordered, sums);
        }
        btrfs_put_ordered_extent(ordered);
-       return 0;
+       return ret;
 }
 
 void btrfs_reloc_cow_block(struct btrfs_trans_handle *trans,
index fb102a9aee9cc1ee3213d04bc1bae6fec6644f2d..224fb5b3daade5803ef17ef80c0695f3d2bdd121 100644 (file)
@@ -2273,7 +2273,7 @@ fail:
        }
        btrfs_end_log_trans(root);
 
-       return 0;
+       return err;
 }
 
 /* see comments for btrfs_del_dir_entries_in_log */