Make btrfs-progs compile with -fstrict-aliasing (included in -O2) again.
authorJan Engelhardt <jengelh@computergmbh.de>
Fri, 14 Sep 2007 14:31:06 +0000 (10:31 -0400)
committerDavid Woodhouse <dwmw2@hera.kernel.org>
Fri, 14 Sep 2007 14:31:06 +0000 (10:31 -0400)
This is done by doing a two-step conversion (rather than a one-step).
First, the variable goes from type * to void *, and then to
implicitly to void **.
(Not sure if this is "good practice", but it shuts up the compiler,
so it seems the compiler takes into account that we are actually punning
it this way.)

bit-radix.c
btrfsck.c
extent-tree.c
radix-tree.c

index 32ccb3a..57f6f3c 100644 (file)
@@ -186,7 +186,7 @@ int find_first_radix_bit(struct radix_tree_root *radix, unsigned long *retbits,
        unsigned long slot;
 
        slot = start / BIT_RADIX_BITS_PER_ARRAY;
-       ret = radix_tree_gang_lookup(radix, (void **)gang, slot,
+       ret = radix_tree_gang_lookup(radix, (void *)gang, slot,
                                     ARRAY_SIZE(gang));
        found = start % BIT_RADIX_BITS_PER_ARRAY;
        for (i = 0; i < ret && nr > 0; i++) {
index 628dfc3..d8bfa53 100644 (file)
--- a/btrfsck.c
+++ b/btrfsck.c
@@ -420,7 +420,7 @@ int check_extent_refs(struct btrfs_root *root,
        int err = 0;
 
        while(1) {
-               ret = radix_tree_gang_lookup(extent_radix, (void **)rec, 0,
+               ret = radix_tree_gang_lookup(extent_radix, (void *)rec, 0,
                                             ARRAY_SIZE(rec));
                if (!ret)
                        break;
index 8b91df5..2c53192 100644 (file)
@@ -164,7 +164,7 @@ int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans,
        btrfs_init_path(&path);
 
        while(1) {
-               ret = radix_tree_gang_lookup_tag(radix, (void **)cache,
+               ret = radix_tree_gang_lookup_tag(radix, (void *)cache,
                                                 0, ARRAY_SIZE(cache),
                                                 BTRFS_BLOCK_GROUP_DIRTY);
                if (!ret)
@@ -195,7 +195,7 @@ static int update_block_group(struct btrfs_trans_handle *trans,
 
        while(total) {
                ret = radix_tree_gang_lookup(&info->block_group_radix,
-                                            (void **)&cache, blocknr, 1);
+                                            (void *)&cache, blocknr, 1);
                if (!ret)
                        return -1;
                radix_tree_tag_set(&info->block_group_radix,
@@ -229,7 +229,7 @@ int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans, struct
 
        while(1) {
                ret = radix_tree_gang_lookup(&root->fs_info->pinned_radix,
-                                            (void **)gang, 0,
+                                            (void *)gang, 0,
                                             ARRAY_SIZE(gang));
                if (!ret)
                        break;
@@ -362,7 +362,7 @@ static int del_pending_extents(struct btrfs_trans_handle *trans, struct
        while(1) {
                ret = radix_tree_gang_lookup_tag(
                                        &extent_root->fs_info->cache_radix,
-                                       (void **)gang, 0,
+                                       (void *)gang, 0,
                                        ARRAY_SIZE(gang),
                                        CTREE_EXTENT_PENDING_DEL);
                if (!ret)
@@ -738,7 +738,7 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
 
        while(1) {
                ret = radix_tree_gang_lookup(&info->block_group_radix,
-                                            (void **)cache, 0,
+                                            (void *)cache, 0,
                                             ARRAY_SIZE(cache));
                if (!ret)
                        break;
index abb754e..ed01810 100644 (file)
@@ -314,7 +314,7 @@ static inline void **__lookup_slot(struct radix_tree_root *root,
                return NULL;
 
        if (height == 0 && root->rnode)
-               return (void **)&root->rnode;
+               return (void *)&root->rnode;
 
        shift = (height-1) * RADIX_TREE_MAP_SHIFT;
        slot = &root->rnode;