Changeset fd6d8620 in rtems-docs


Ignore:
Timestamp:
03/08/23 20:39:25 (7 months ago)
Author:
Kinsey Moore <kinsey.moore@…>
Branches:
master
Children:
cdb6208
Parents:
2f7ebf7
git-author:
Kinsey Moore <kinsey.moore@…> (03/08/23 20:39:25)
git-committer:
Joel Sherrill <joel@…> (03/09/23 15:16:12)
Message:

c-user/chains: Correct iteration example code

Casting the node returned by rtems_chain_head is incorrect. That node is
owned by the control structure and use of it post-cast could cause
memory corruption. Instead, use rtems_chain_first which returns the
node after the head node. This also corrects node->next to
rtems_chain_next(node) which makes better use of the API.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c-user/chains.rst

    r2f7ebf7 rfd6d8620  
    193193        rtems_chain_initialize_empty (out);
    194194
    195         node = rtems_chain_head (chain);
     195        node = rtems_chain_first (chain);
     196
    196197        while (!rtems_chain_is_tail (chain, node))
    197198        {
    198199            bar = (foo*) node;
    199             rtems_chain_node* next_node = node->next;
     200            rtems_chain_node* next_node = rtems_chain_next(node);
    200201            if (strcmp (match, bar->data) == 0)
    201202            {
Note: See TracChangeset for help on using the changeset viewer.