source: rtems/cpukit/score/src/objectidtoname.c @ c86da31c

4.115
Last change on this file since c86da31c was 6fd4d06f, checked in by Joel Sherrill <joel.sherrill@…>, on 09/28/09 at 23:00:20

2009-09-28 Joel Sherrill <joel.sherrill@…>

  • score/src/objectidtoname.c: Remove error which cannot be reached since API that calls this checks the error first.
  • score/src/objectsetname.c: Adjust handling of length.
  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 *  Obtain Object Name Given ID
3 *
4 *
5 *  COPYRIGHT (c) 1989-2003.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in 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/object.h>
21#include <rtems/score/thread.h>
22
23/*
24 *  _Objects_Id_to_name
25 *
26 *  DESCRIPTION:
27 *
28 *  This routine returns the name associated with the given ID.
29 *
30 *  INPUT:
31 *
32 *  id   - id of object to lookup name
33 *  name - pointer to location in which to store name
34 *
35 */
36Objects_Name_or_id_lookup_errors _Objects_Id_to_name (
37  Objects_Id      id,
38  Objects_Name   *name
39)
40{
41  uint32_t             the_api;
42  uint32_t             the_class;
43  Objects_Id           tmpId;
44  Objects_Information *information;
45  Objects_Control     *the_object = (Objects_Control *) 0;
46  Objects_Locations    ignored_location;
47
48  /*
49   *  Caller is trusted for name != NULL.
50   */
51
52  tmpId = (id == OBJECTS_ID_OF_SELF) ? _Thread_Executing->Object.id : id;
53
54  the_api = _Objects_Get_API( tmpId );
55  if ( !_Objects_Is_api_valid( the_api ) )
56    return OBJECTS_INVALID_ID;
57
58  if ( !_Objects_Information_table[ the_api ] )
59    return OBJECTS_INVALID_ID;
60
61  the_class = _Objects_Get_class( tmpId );
62
63  information = _Objects_Information_table[ the_api ][ the_class ];
64  if ( !information )
65    return OBJECTS_INVALID_ID;
66
67  #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
68    if ( information->is_string )
69      return OBJECTS_INVALID_ID;
70  #endif
71
72  the_object = _Objects_Get( information, tmpId, &ignored_location );
73  if ( !the_object )
74    return OBJECTS_INVALID_ID;
75
76  *name = the_object->name;
77  _Thread_Enable_dispatch();
78  return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL;
79}
Note: See TracBrowser for help on using the repository browser.