Commit 551107ca authored by Paolo \'Blaisorblade\' Giarrusso's avatar Paolo \'Blaisorblade\' Giarrusso Committed by Linus Torvalds

[PATCH] use container_of() for rb_entry()

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: default avatarPaolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 0bf6d4e7
...@@ -113,8 +113,7 @@ struct rb_root ...@@ -113,8 +113,7 @@ struct rb_root
}; };
#define RB_ROOT (struct rb_root) { NULL, } #define RB_ROOT (struct rb_root) { NULL, }
#define rb_entry(ptr, type, member) \ #define rb_entry(ptr, type, member) container_of(ptr, type, member)
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
extern void rb_insert_color(struct rb_node *, struct rb_root *); extern void rb_insert_color(struct rb_node *, struct rb_root *);
extern void rb_erase(struct rb_node *, struct rb_root *); extern void rb_erase(struct rb_node *, struct rb_root *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment