* [patch 1/1] use offsetof for rb_entry
@ 2004-10-07 17:53 blaisorblade_spam
2004-10-07 21:27 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: blaisorblade_spam @ 2004-10-07 17:53 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, blaisorblade_spam
Use, in the rb_entry definition, the offsetof macro instead of reinventing the
wheel.
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>
---
linux-2.6.9-current-paolo/include/linux/rbtree.h | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)
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-07 16:11:27.590555976 +0200
+++ linux-2.6.9-current-paolo/include/linux/rbtree.h 2004-10-07 16:11:27.592555672 +0200
@@ -114,7 +114,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)))
+ ((type *)((char *)(ptr) - offsetof(type, member)))
extern void rb_insert_color(struct rb_node *, struct rb_root *);
extern void rb_erase(struct rb_node *, struct rb_root *);
_
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch 1/1] use offsetof for rb_entry
2004-10-07 17:53 [patch 1/1] use offsetof for rb_entry blaisorblade_spam
@ 2004-10-07 21:27 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2004-10-07 21:27 UTC (permalink / raw)
To: blaisorblade_spam; +Cc: akpm, linux-kernel
On Thu, Oct 07, 2004 at 07:53:42PM +0200, blaisorblade_spam@yahoo.it wrote:
>
> Use, in the rb_entry definition, the offsetof macro instead of reinventing the
> wheel.
Or just use container_of - which has the additional benefit of beeing typesafe.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-10-07 21:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-07 17:53 [patch 1/1] use offsetof for rb_entry blaisorblade_spam
2004-10-07 21:27 ` Christoph Hellwig
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.