[patch 1/1] use container_of for rb_entry
From: blaisorblade_spam
Date: Fri Oct 08 2004 - 06:20:03 EST
Use, in the rb_entry definition, the container_of macro instead of reinventing
the wheel; compared to using offset_of() as I did in the prev. version, it has
type safety checking.
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade_spam@xxxxxxxx>
---
linux-2.6.9-current-paolo/include/linux/rbtree.h | 3 +--
1 files changed, 1 insertion(+), 2 deletions(-)
diff -puN include/linux/rbtree.h~use-offsetof-rb_entry include/linux/rbtree.h
--- linux-2.6.9-current/include/linux/rbtree.h~use-offsetof-rb_entry 2004-10-08 11:57:18.523435712 +0200
+++ linux-2.6.9-current-paolo/include/linux/rbtree.h 2004-10-08 13:12:27.602951432 +0200
@@ -113,8 +113,7 @@ struct rb_root
};
#define RB_ROOT (struct rb_root) { NULL, }
-#define rb_entry(ptr, type, member) \
- ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
+#define rb_entry(ptr, type, member) container_of(ptr, type, member)
extern void rb_insert_color(struct rb_node *, struct rb_root *);
extern void rb_erase(struct rb_node *, struct rb_root *);
_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/