This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Re: rbtree.h compiler warning fix
- From: Gary Thomas <gary at mlbassoc dot com>
- To: Savin Zlobec <savin dot zlobec at email dot si>
- Cc: ecos-patches at sources dot redhat dot com
- Date: 18 Oct 2003 08:04:54 -0600
- Subject: Re: rbtree.h compiler warning fix
- Organization: MLB Associates
- References: <20031018135239.A86458BAF2@www.email.si>
On Sat, 2003-10-18 at 07:52, Savin Zlobec wrote:
> The attached patch fixes a 'pointer of type `void *' used in subtraction'
> compiler warning in compat/linux/current/include/linux/rbtree.h.
>
> I've also noticed, that the bug in rbtree.c described and fixed in
>
> http://sources.redhat.com/ml/ecos-discuss/2003-07/msg00266.html
>
> was not commited to CVS. It there any reason not to commit it?
>
> I use the rbtree code in my block cache library, wich works without
> problems with the mentioned patch applied (without it doesn't work at all).
>
These both seem reasonable to me - sorry the older one was missed.
I've committed the attached change.
--
Gary Thomas <gary@mlbassoc.com>
MLB Associates
Index: compat/linux/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/compat/linux/current/ChangeLog,v
retrieving revision 1.3
diff -u -5 -p -r1.3 ChangeLog
--- compat/linux/current/ChangeLog 27 Jul 2003 13:58:42 -0000 1.3
+++ compat/linux/current/ChangeLog 18 Oct 2003 14:03:11 -0000
@@ -1,5 +1,15 @@
+2003-10-18 Gary Thomas <gary@mlbassoc.com>
+
+ * src/rbtree.c (rb_erase): Fix bug in red-black tree which caused
+ node corruption - merge from external sources, found by Scott Wilkerson.
+
+2003-10-18 Savin Zlobec <savin@elatec.si>
+
+ * include/linux/rbtree.h:
+ Fixed 'pointer of type `void *' used in subtraction' compiler warrning.
+
2003-07-27 Andrew Lunn <andrew.lunn@ascom.ch>
* include/linux/init.h:
* include/linux/vmalloc.h: New dummy files so that jffs2 will
compile.
Index: compat/linux/current/include/linux/rbtree.h
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/compat/linux/current/include/linux/rbtree.h,v
retrieving revision 1.1
diff -u -5 -p -r1.1 rbtree.h
--- compat/linux/current/include/linux/rbtree.h 22 Jan 2003 01:10:41 -0000 1.1
+++ compat/linux/current/include/linux/rbtree.h 18 Oct 2003 14:00:03 -0000
@@ -13,11 +13,11 @@ struct rb_root {
struct rb_node *rb_node; /* root of the tree */
};
#define NULL ((void *)0)
#define RB_ROOT ((struct rb_root){NULL})
#define rb_entry(p, container, field) \
- ((container *) ((void *)p - ((void *)&(((container *)0)->field))))
+ ((container *) ((char *)p - ((char *)&(((container *)0)->field))))
#define RB_BLACK 0
#define RB_RED 1
Index: compat/linux/current/src/rbtree.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/compat/linux/current/src/rbtree.c,v
retrieving revision 1.1
diff -u -5 -p -r1.1 rbtree.c
--- compat/linux/current/src/rbtree.c 22 Jan 2003 01:10:42 -0000 1.1
+++ compat/linux/current/src/rbtree.c 18 Oct 2003 14:01:28 -0000
@@ -292,11 +292,11 @@ void rb_erase(struct rb_node *elm, struc
RB_AUGMENT(parent);
} else
RB_HEAD(head) = child;
if (RB_PARENT(elm) == old)
parent = elm;
- (elm) = (old);
+ *(elm) = *(old);
if (RB_PARENT(old)) {
if (RB_LEFT(RB_PARENT(old)) == old)
RB_LEFT(RB_PARENT(old)) = elm;
else
RB_RIGHT(RB_PARENT(old)) = elm;