Root/m1/patches/rtems/rbtree-container-of.patch

Source at commit f6fd776f528905e346c7f1caec97945535c7ca43 created 8 years 4 months ago.
By Werner Almesberger, m1/patches/rtems/: Milkymist-specific patches are in upstream (update by Xiangfu)
1This issue is under review:
2https://www.rtems.org/bugzilla/show_bug.cgi?id=1963
3
4There seem to be two issues in the original code:
5
6- the "node" argument of the macro is not protected, which could lead
7  to very hard to find errors (this doesn't seem to cause any
8  immediate problems just now, but it's a lousy risk to take)
9
10- more seriously, "offsetof" counts in bytes while arithmentic on the
11  "node" pointer counts in multiples of whatever size that object has
12
13RTEMS with this patch applied runs well (on Milkymist), but I don't
14know if the code in question actually is executed.
15
16- Werner
17
18Index: rtems/cpukit/score/include/rtems/score/rbtree.h
19===================================================================
20--- rtems.orig/cpukit/score/include/rtems/score/rbtree.h 2011-11-12 08:52:50.000000000 -0300
21+++ rtems/cpukit/score/include/rtems/score/rbtree.h 2011-11-12 09:00:35.000000000 -0300
22@@ -90,7 +90,9 @@
23  *
24  */
25 #define _RBTree_Container_of(node,container_type, node_field_name) \
26- ((container_type*) (node - offsetof(container_type,node_field_name)))
27+ ((container_type*) ((void *) (node) - \
28+ offsetof(container_type,node_field_name)))
29+
30 
31 /**
32  * This type indicates the direction.
33

Archive Download this file

Branches:
master



interactive