<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi everyone,<br><div><br></div><div>While going through testsuites/sptests/spchain/init.c, I noticed the following code: </div><div><br></div><div>-----------------------------------------------</div><div><div>rtems_task Init(</div><div>  rtems_task_argument ignored</div><div>)</div><div>{</div><div>  rtems_chain_control  chain1;</div><div>  rtems_chain_node    *p;</div><div>  test_node            node1, node2;</div><div>  int                  id;</div><div><br></div><div>  TEST_BEGIN();</div><div><br></div><div>  puts( "Init - Initialize chain empty" );</div><div>  rtems_chain_initialize_empty( &chain1 );</div><div>  rtems_chain_initialize_node( &node1.Node );</div><div>  rtems_chain_initialize_node( &node2.Node );</div><div><br></div><div>  /* verify that the chain append and insert work */</div><div>  puts( "INIT - Verify rtems_chain_insert" );</div><div>  <a href="http://node1.id">node1.id</a> = 1;</div><div>  <a href="http://node2.id">node2.id</a> = 2;</div><div>  rtems_chain_append( &chain1, &node1.Node );</div><div>  rtems_chain_insert( &node1.Node, &node2.Node );</div><div><br></div><div>  for ( p = rtems_chain_first(&chain1), id = 1 ;</div><div>        !rtems_chain_is_tail(&chain1, p) ;</div><div>        p = p->next , id++ ) {</div><div>     test_node *t = (test_node *)p;</div><div>     if ( id > 2 ) {</div><div>       puts( "INIT - TOO MANY NODES ON CHAIN" );</div><div>       rtems_test_exit(0);</div><div>     }</div><div>     if ( t->id != id ) {</div><div>       puts( "INIT - ERROR ON CHAIN ID MISMATCH" );</div><div>       rtems_test_exit(0);</div><div>     }</div><div>  }</div><div><br></div><div>-----------------------------------------</div><div>Where test_node is defined as:</div></div><div><br></div><div><div>typedef struct {</div><div>  rtems_chain_node Node;</div><div>  int              id;</div><div>} test_node;</div></div><div><br></div><div>----------------------------------</div><div><br></div><div><br></div><div>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.:</div><div><div>  rtems_chain_append( &chain1, &node1.Node );</div><div>  rtems_chain_insert( &node1.Node, &node2.Node );</div></div><div><br></div><div>So, how do we ever get our <a href="http://node1.id">node1.id</a> ? 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?</div><div><br></div><div>I hope my doubt is not too vague.</div><div><br></div><div>Thanks,</div><div>Richi.</div><div> </div><div><br></div></div></div></div></div></div>