[rtems commit] score: Fix _Objects_Shrink_information()

Sebastian Huber sebh at rtems.org
Mon Jan 7 16:03:54 UTC 2013


Module:    rtems
Branch:    4.10
Commit:    8949e5b1a11c03452cf43f21023fa275628bcd3f
Changeset: http://git.rtems.org/rtems/commit/?id=8949e5b1a11c03452cf43f21023fa275628bcd3f

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Jan  3 17:07:14 2013 +0100

score: Fix _Objects_Shrink_information()

The chain iteration was wrong.  The chain tail is not an object.

---

 cpukit/score/src/objectshrinkinformation.c |   36 ++++++++++++---------------
 1 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/cpukit/score/src/objectshrinkinformation.c b/cpukit/score/src/objectshrinkinformation.c
index 914fe2a..69b206e 100644
--- a/cpukit/score/src/objectshrinkinformation.c
+++ b/cpukit/score/src/objectshrinkinformation.c
@@ -47,12 +47,9 @@ void _Objects_Shrink_information(
   Objects_Information *information
 )
 {
-  Objects_Control  *the_object;
-  Objects_Control  *extract_me;
   uint32_t          block_count;
   uint32_t          block;
   uint32_t          index_base;
-  uint32_t          index;
 
   /*
    * Search the list to find block or chunk with all objects inactive.
@@ -65,25 +62,24 @@ void _Objects_Shrink_information(
   for ( block = 0; block < block_count; block++ ) {
     if ( information->inactive_per_block[ block ] ==
          information->allocation_size ) {
+      Chain_Node       *node = _Chain_First( &information->Inactive );
+      const Chain_Node *tail = _Chain_Tail( &information->Inactive );
+      uint32_t          index_end = index_base + information->allocation_size;
 
-      /*
-       *  Assume the Inactive chain is never empty at this point
-       */
-      the_object = (Objects_Control *) information->Inactive.first;
+      while ( node != tail ) {
+        Objects_Control *object = (Objects_Control *) node;
+        uint32_t         index = _Objects_Get_index( object->id );
+
+        /*
+         *  Get the next node before the node is extracted
+         */
+        node = _Chain_Next( node );
+
+        if ( index >= index_base && index < index_end ) {
+          _Chain_Extract( &object->Node );
+        }
+      }
 
-      do {
-         index = _Objects_Get_index( the_object->id );
-         /*
-          *  Get the next node before the node is extracted
-          */
-         extract_me = the_object;
-         the_object = (Objects_Control *) the_object->Node.next;
-         if ((index >= index_base) &&
-             (index < (index_base + information->allocation_size))) {
-           _Chain_Extract( &extract_me->Node );
-         }
-       }
-       while ( the_object );
       /*
        *  Free the memory and reset the structures in the object' information
        */




More information about the vc mailing list