Werner's Miscellanea
Sign in or create your account | Project List | Help
Werner's Miscellanea Git Source Tree
Root/
| 1 | This issue is under review: |
| 2 | https://www.rtems.org/bugzilla/show_bug.cgi?id=1963 |
| 3 | |
| 4 | There 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 | |
| 13 | RTEMS with this patch applied runs well (on Milkymist), but I don't |
| 14 | know if the code in question actually is executed. |
| 15 | |
| 16 | - Werner |
| 17 | |
| 18 | Index: 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 |
Branches:
master
