source: rtems/cpukit/score/src/objectgetnext.c @ da42259

4.104.115
Last change on this file since da42259 was 61541f4, checked in by Joel Sherrill <joel.sherrill@…>, on 05/08/09 at 02:13:24

2009-05-07 Joel Sherrill <joel.sherrill@…>

  • score/src/objectgetnext.c: Add checks for NULL pointers.
  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 *  Object Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/score/address.h>
21#include <rtems/score/chain.h>
22#include <rtems/score/object.h>
23#if defined(RTEMS_MULTIPROCESSING)
24#include <rtems/score/objectmp.h>
25#endif
26#include <rtems/score/thread.h>
27#include <rtems/score/wkspace.h>
28#include <rtems/score/sysstate.h>
29#include <rtems/score/isr.h>
30
31/*PAGE
32 *
33 * _Objects_Get_next
34 *
35 * Like _Objects_Get, but considers the 'id' as a "hint" and
36 * finds next valid one after that point.
37 * Mostly used for monitor and debug traversal of an object.
38 *
39 * Input parameters:
40 *   information - pointer to entry in table for this class
41 *   id          - object id to search for
42 *   location    - address of where to store the location
43 *   next_id     - address to store next id to try
44 *
45 * Output parameters:
46 *   returns     - address of object if local
47 *   location    - one of the following:
48 *                  OBJECTS_ERROR  - invalid object ID
49 *                  OBJECTS_REMOTE - remote object
50 *                  OBJECTS_LOCAL  - local object
51 *   next_id     - will contain a reasonable "next" id to continue traversal
52 *
53 * NOTE:
54 *      assumes can add '1' to an id to get to next index.
55 */
56
57Objects_Control *
58_Objects_Get_next(
59    Objects_Information *information,
60    Objects_Id           id,
61    Objects_Locations   *location_p,
62    Objects_Id          *next_id_p
63)
64{
65    Objects_Control *object;
66    Objects_Id       next_id;
67
68    if ( !information )
69      return NULL;
70
71    if ( !location_p )
72      return NULL;
73
74    if ( !next_id_p )
75      return NULL;
76
77    if (_Objects_Get_index(id) == OBJECTS_ID_INITIAL_INDEX)
78        next_id = information->minimum_id;
79    else
80        next_id = id;
81
82    do {
83        /* walked off end of list? */
84        if (_Objects_Get_index(next_id) > information->maximum)
85        {
86            *location_p = OBJECTS_ERROR;
87            goto final;
88        }
89
90        /* try to grab one */
91        object = _Objects_Get(information, next_id, location_p);
92
93        next_id++;
94
95    } while (*location_p != OBJECTS_LOCAL);
96
97    *next_id_p = next_id;
98    return object;
99
100final:
101    *next_id_p = OBJECTS_ID_FINAL;
102    return 0;
103}
Note: See TracBrowser for help on using the repository browser.