Hi everyone, While going through testsuites/sptests/spchain/init.c, I noticed the following code:
----------------------------------------------- rtems_task Init( rtems_task_argument ignored ) { rtems_chain_control chain1; rtems_chain_node *p; test_node node1, node2; int id; TEST_BEGIN(); puts( "Init - Initialize chain empty" ); rtems_chain_initialize_empty( &chain1 ); rtems_chain_initialize_node( &node1.Node ); rtems_chain_initialize_node( &node2.Node ); /* verify that the chain append and insert work */ puts( "INIT - Verify rtems_chain_insert" ); node1.id = 1; node2.id = 2; rtems_chain_append( &chain1, &node1.Node ); rtems_chain_insert( &node1.Node, &node2.Node ); for ( p = rtems_chain_first(&chain1), id = 1 ; !rtems_chain_is_tail(&chain1, p) ; p = p->next , id++ ) { test_node *t = (test_node *)p; if ( id > 2 ) { puts( "INIT - TOO MANY NODES ON CHAIN" ); rtems_test_exit(0); } if ( t->id != id ) { puts( "INIT - ERROR ON CHAIN ID MISMATCH" ); rtems_test_exit(0); } } ----------------------------------------- Where test_node is defined as: typedef struct { rtems_chain_node Node; int id; } test_node; ---------------------------------- Now when we are inserting or appending our structure into the chain, we are only inserting the part of strucuture correspoing to rtems_chain_node, i.e.: rtems_chain_append( &chain1, &node1.Node ); rtems_chain_insert( &node1.Node, &node2.Node ); So, how do we ever get our node1.id ? How can we (or how do we ever) access our data from the structure when we are only adding some part of the structure into the node? I hope my doubt is not too vague. Thanks, Richi.
_______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel