[rtems commit] score/rbtree: C++ compatibility

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Mar 30 10:05:49 UTC 2012


On 03/30/2012 11:47 AM, Ralf Corsepius wrote:
> On 03/30/2012 11:39 AM, Sebastian Huber wrote:
>> Module: rtems
>> Branch: master
>> Commit: c6dbcd6910a13443f1daed2300afe07afee7ed26
>> Changeset:
>> http://git.rtems.org/rtems/commit/?id=c6dbcd6910a13443f1daed2300afe07afee7ed26
>>
>> Author: Sebastian Huber<sebastian.huber at embedded-brains.de>
>> Date: Fri Mar 30 11:21:32 2012 +0200
>>
>> score/rbtree: C++ compatibility
>>
>> ---
>>
>> cpukit/score/inline/rtems/score/rbtree.inl | 5 +++--
>> 1 files changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/cpukit/score/inline/rtems/score/rbtree.inl
>> b/cpukit/score/inline/rtems/score/rbtree.inl
>> index c74726a..422924a 100644
>> --- a/cpukit/score/inline/rtems/score/rbtree.inl
>> +++ b/cpukit/score/inline/rtems/score/rbtree.inl
>> @@ -38,7 +38,7 @@ RTEMS_INLINE_ROUTINE RBTree_Direction
>> _RBTree_Opposite_direction(
>> RBTree_Direction the_dir
>> )
>> {
>> - return (!the_dir);
>> + return (RBTree_Direction) !((int) the_dir);
>> }
>>
>> /** @brief Set off rbtree
>> @@ -368,7 +368,8 @@ RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Find_unprotected(
>> break;
>> }
>>
>> - RBTree_Direction dir = _RBTree_Is_greater( compare_result );
>> + RBTree_Direction dir =
>> + (RBTree_Direction) _RBTree_Is_greater( compare_result );
>> iter_node = iter_node->child[dir];
>> } /* while(iter_node) */
>>
>
> This patch does not seem right to me.

This patch changes nothing in C.  In C++ we have the feature that an enum is 
not an int.

>
> Without having checked details, my gut feeling is you might be spraying casts
> to work around an improperly declared or improperly used function.

We exploit only the fact that the RBTree_Direction enum values are 0 and 1.

-- 
Sebastian Huber, embedded brains GmbH

Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone   : +49 89 18 90 80 79-6
Fax     : +49 89 18 90 80 79-9
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the devel mailing list