Skip to contentSkip to conversation

btrfs: Simplify btrfs_item_ptr macro

PATCH In review Miao Xie 1 participant 1 message Mar 25, 2010 Btrfs file system

lore
Share & tools
lore

Miao Xie

author
#0 lore raw

PATCH 4/18 btrfs: Simplify btrfs_item_ptr macro

From: Zhao Lei <[email protected]>

btrfs_item_ptr is just a type_cast wrapper of btrfs_item_ptr_offset().

We can use btrfs_item_ptr_offset() in btrfs_item_ptr() to avoid code duplication.

---
 fs/btrfs/ctree.h |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
fs/btrfs/ctree.h +2 -4
index 1111584..72228b2 100644
@@ -1947,13 +1947,11 @@ static inline u32 btrfs_level_size(struct btrfs_root *root, int level)
 }
 
 /* helper function to cast into the data area of the leaf. */
-#define btrfs_item_ptr(leaf, slot, type) \
-	((type *)(btrfs_leaf_data(leaf) + \
-	btrfs_item_offset_nr(leaf, slot)))
-
 #define btrfs_item_ptr_offset(leaf, slot) \
 	((unsigned long)(btrfs_leaf_data(leaf) + \
 	btrfs_item_offset_nr(leaf, slot)))
+#define btrfs_item_ptr(leaf, slot, type) \
+	((type *)btrfs_item_ptr_offset(leaf, slot))
 
 static inline struct dentry *fdentry(struct file *file)
 {
Signature · 1 line
1.6.5.2