mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2025-04-21 12:27:27 +03:00
m1/patches/rtems/: pending RTEMS patches (relative to latest CVS)
This commit is contained in:
32
m1/patches/rtems/rbtree-container-of.patch
Normal file
32
m1/patches/rtems/rbtree-container-of.patch
Normal file
@@ -0,0 +1,32 @@
|
||||
This issue is under consideration:
|
||||
http://www.rtems.org/pipermail/rtems-users/2011-November/009097.html
|
||||
|
||||
There seem to be two issues in the original code:
|
||||
|
||||
- the "node" argument of the macro is not protected, which could lead
|
||||
to very hard to find errors (this doesn't seem to cause any
|
||||
immediate problems just now, but it's a lousy risk to take)
|
||||
|
||||
- more seriously, "offsetof" counts in bytes while arithmentic on the
|
||||
"node" pointer counts in multiples of whatever size that object has
|
||||
|
||||
RTEMS with this patch applied runs well (on Milkymist), but I don't
|
||||
know if the code in question actually is executed.
|
||||
|
||||
- Werner
|
||||
|
||||
Index: rtems/cpukit/score/include/rtems/score/rbtree.h
|
||||
===================================================================
|
||||
--- rtems.orig/cpukit/score/include/rtems/score/rbtree.h 2011-11-12 08:52:50.000000000 -0300
|
||||
+++ rtems/cpukit/score/include/rtems/score/rbtree.h 2011-11-12 09:00:35.000000000 -0300
|
||||
@@ -90,7 +90,9 @@
|
||||
*
|
||||
*/
|
||||
#define _RBTree_Container_of(node,container_type, node_field_name) \
|
||||
- ((container_type*) (node - offsetof(container_type,node_field_name)))
|
||||
+ ((container_type*) ((void *) (node) - \
|
||||
+ offsetof(container_type,node_field_name)))
|
||||
+
|
||||
|
||||
/**
|
||||
* This type indicates the direction.
|
||||
Reference in New Issue
Block a user