[PATCH 07/11] score: Make _Objects_Information_table const

Sebastian Huber sebastian.huber at embedded-brains.de
Tue May 3 12:49:43 UTC 2016


The _Objects_Information_table is statically initialized.  So, we can
make it read-only.
---
 cpukit/sapi/src/exinit.c                      |  3 ++-
 cpukit/score/include/rtems/score/objectimpl.h |  4 +--
 cpukit/score/src/threadget.c                  | 14 +----------
 testsuites/sptests/sp43/init.c                | 35 ---------------------------
 4 files changed, 5 insertions(+), 51 deletions(-)

diff --git a/cpukit/sapi/src/exinit.c b/cpukit/sapi/src/exinit.c
index 69db694..7988a5b 100644
--- a/cpukit/sapi/src/exinit.c
+++ b/cpukit/sapi/src/exinit.c
@@ -51,7 +51,8 @@ static Objects_Information *_RTEMS_Objects[ OBJECTS_RTEMS_CLASSES_LAST + 1 ];
 
 static Objects_Information *_POSIX_Objects[ OBJECTS_POSIX_CLASSES_LAST + 1 ];
 
-Objects_Information **_Objects_Information_table[ OBJECTS_APIS_LAST + 1 ] = {
+Objects_Information ** const
+_Objects_Information_table[ OBJECTS_APIS_LAST + 1 ] = {
   NULL,
   &_Internal_Objects[ 0 ],
   &_RTEMS_Objects[ 0 ],
diff --git a/cpukit/score/include/rtems/score/objectimpl.h b/cpukit/score/include/rtems/score/objectimpl.h
index 1129daf..fe08771 100644
--- a/cpukit/score/include/rtems/score/objectimpl.h
+++ b/cpukit/score/include/rtems/score/objectimpl.h
@@ -213,8 +213,8 @@ extern uint16_t _Objects_Maximum_nodes;
  *  class.  From the ID, we can go to one of these information blocks,
  *  and obtain a pointer to the appropriate object control block.
  */
-extern Objects_Information
-    **_Objects_Information_table[OBJECTS_APIS_LAST + 1];
+extern Objects_Information ** const
+_Objects_Information_table[ OBJECTS_APIS_LAST + 1 ];
 
 /**
  *  This function extends an object class information record.
diff --git a/cpukit/score/src/threadget.c b/cpukit/score/src/threadget.c
index 45ea55f..8731ab5 100644
--- a/cpukit/score/src/threadget.c
+++ b/cpukit/score/src/threadget.c
@@ -27,7 +27,6 @@ static Objects_Information *_Thread_Get_objects_information(
 {
   uint32_t             the_api;
   uint32_t             the_class;
-  Objects_Information **api_information;
 
   the_api = _Objects_Get_API( id );
   if ( !_Objects_Is_api_valid( the_api ) ) {
@@ -39,18 +38,7 @@ static Objects_Information *_Thread_Get_objects_information(
     return NULL;
   }
 
-  api_information = _Objects_Information_table[ the_api ];
-  /*
-   *  There is no way for this to happen if POSIX is enabled.  But there
-   *  is actually a test case in sp43 for this which trips it whether or
-   *  not POSIX is enabled.  So in the interest of safety, this is left
-   *  on in all configurations.
-   */
-  if ( !api_information ) {
-    return NULL;
-  }
-
-  return api_information[ the_class ];
+  return _Objects_Information_table[ the_api ][ the_class ];
 }
 
 Thread_Control *_Thread_Get(
diff --git a/testsuites/sptests/sp43/init.c b/testsuites/sptests/sp43/init.c
index 03fe5a5..a002535 100644
--- a/testsuites/sptests/sp43/init.c
+++ b/testsuites/sptests/sp43/init.c
@@ -448,23 +448,6 @@ rtems_task Init(
     );
     directive_failed( sc, "rtems_task_set_priority" );
 
-    /* destroy internal API pointer */
-    puts( "rtems_task_set_priority - clobber internal API info" );
-    tmp = _Objects_Information_table[ api ];
-    _Objects_Information_table[ api ] = NULL;
-
-    puts( "rtems_task_set_priority - use valid Idle thread id again" );
-    sc = rtems_task_set_priority(
-      rtems_build_id( class, api, 1, 1 ),
-      RTEMS_CURRENT_PRIORITY,
-      &old_priority
-    );
-    fatal_directive_status( sc, RTEMS_INVALID_ID, "rtems_task_set_priority" );
-
-    /* restore pointer */
-    puts( "rtems_task_set_priority - restore internal api info" );
-    _Objects_Information_table[ api ] = tmp;
-
     /* destroy internal API thread class pointer */
     puts( "rtems_task_set_priority - clobber internal thread class info" );
     tmp = _Objects_Information_table[ api ][ class ];
@@ -510,24 +493,6 @@ rtems_task Init(
   );
   fatal_directive_status( sc, RTEMS_INVALID_ID, "rtems_semaphore_obtain" );
 
-  /*
-   * Invalid POSIX API pointer on get name
-   */
-  {
-    void *tmp;
-    tmp = _Objects_Information_table[OBJECTS_POSIX_API];
-    _Objects_Information_table[OBJECTS_POSIX_API] = NULL;
-
-    puts( "rtems_object_get_classic_name - bad API pointer - INVALID_ID" );
-    sc = rtems_object_get_classic_name(
-      rtems_build_id( OBJECTS_POSIX_API, OBJECTS_POSIX_THREADS, 1, 1 ),
-      &tmpName
-    );
-    fatal_directive_status( sc, RTEMS_INVALID_ID, "object_get_classic_name" );
-
-    _Objects_Information_table[OBJECTS_POSIX_API] = tmp;
-  }
-
   TEST_END();
   rtems_test_exit( 0 );
 }
-- 
1.8.4.5



More information about the devel mailing list