Btrfs: add leaf data casting helper
Signed-off-by: Chris Mason <chris.mason@oracle.com>
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 7f156d9..3767744 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -41,9 +41,7 @@
BUG();
BUG_ON(ret != 0);
l = &path.nodes[0]->leaf;
- item = (struct btrfs_extent_item *)(l->data +
- btrfs_item_offset(l->items +
- path.slots[0]));
+ item = btrfs_item_ptr(l, path.slots[0], struct btrfs_extent_item);
refs = btrfs_extent_refs(item);
btrfs_set_extent_refs(item, refs + 1);
@@ -69,9 +67,7 @@
if (ret != 0)
BUG();
l = &path.nodes[0]->leaf;
- item = (struct btrfs_extent_item *)(l->data +
- btrfs_item_offset(l->items +
- path.slots[0]));
+ item = btrfs_item_ptr(l, path.slots[0], struct btrfs_extent_item);
*refs = btrfs_extent_refs(item);
btrfs_release_path(root->extent_root, &path);
return 0;