[PATCH v3 2/5] Avoid INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Nov 25 07:12:20 UTC 2020


Replace a runtime check with a compile time assertion.  This makes the
INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL obsolete.

Update #4181.
---
 cpukit/include/rtems/confdefs/inittask.h    | 21 ++++++++++++++++
 cpukit/include/rtems/score/interr.h         |  2 +-
 cpukit/rtems/src/taskinitusers.c            |  8 +-----
 spec/build/testsuites/sptests/grp.yml       |  2 --
 spec/build/testsuites/sptests/spfatal02.yml | 19 --------------
 testsuites/sptests/Makefile.am              |  9 -------
 testsuites/sptests/configure.ac             |  1 -
 testsuites/sptests/spfatal02/init.c         | 28 ---------------------
 testsuites/sptests/spfatal02/spfatal02.doc  | 20 ---------------
 testsuites/sptests/spfatal02/spfatal02.scn  |  3 ---
 10 files changed, 23 insertions(+), 90 deletions(-)
 delete mode 100644 spec/build/testsuites/sptests/spfatal02.yml
 delete mode 100644 testsuites/sptests/spfatal02/init.c
 delete mode 100644 testsuites/sptests/spfatal02/spfatal02.doc
 delete mode 100644 testsuites/sptests/spfatal02/spfatal02.scn

diff --git a/cpukit/include/rtems/confdefs/inittask.h b/cpukit/include/rtems/confdefs/inittask.h
index a91b9a5917..08eddc0334 100644
--- a/cpukit/include/rtems/confdefs/inittask.h
+++ b/cpukit/include/rtems/confdefs/inittask.h
@@ -100,6 +100,27 @@ extern "C" {
   #define CONFIGURE_INIT_TASK_ARGUMENTS 0
 #endif
 
+/*
+ * Ignore the following warnings from g++ and clang in the static assertion
+ * below:
+ *
+ * warning: the address of 'void Init()' will never be NULL [-Waddress]
+ *
+ * warning: comparison of function 'Init' not equal to a null pointer is always
+ * true [-Wtautological-pointer-compare]
+ */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Waddress"
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic ignored "-Wtautological-pointer-compare"
+
+RTEMS_STATIC_ASSERT(
+  CONFIGURE_INIT_TASK_ENTRY_POINT != NULL,
+  CONFIGURE_INIT_TASK_ENTRY_POINT_MUST_NOT_BE_NULL
+);
+
+#pragma GCC diagnostic pop
+
 const rtems_initialization_tasks_table _RTEMS_tasks_User_task_table = {
   CONFIGURE_INIT_TASK_NAME,
   CONFIGURE_INIT_TASK_STACK_SIZE,
diff --git a/cpukit/include/rtems/score/interr.h b/cpukit/include/rtems/score/interr.h
index 4b06199ae9..b1f1061c82 100644
--- a/cpukit/include/rtems/score/interr.h
+++ b/cpukit/include/rtems/score/interr.h
@@ -189,7 +189,7 @@ typedef enum {
   INTERNAL_ERROR_NO_MEMORY_FOR_HEAP = 23,
   INTERNAL_ERROR_CPU_ISR_INSTALL_VECTOR = 24,
   INTERNAL_ERROR_RESOURCE_IN_USE = 25,
-  INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL = 26,
+  /* INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL = 26, */
   /* INTERNAL_ERROR_POSIX_INIT_THREAD_ENTRY_IS_NULL = 27, */
   INTERNAL_ERROR_THREAD_QUEUE_DEADLOCK = 28,
   INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_STICKY_FROM_BAD_STATE = 29,
diff --git a/cpukit/rtems/src/taskinitusers.c b/cpukit/rtems/src/taskinitusers.c
index 0b23d8bc86..f21c061670 100644
--- a/cpukit/rtems/src/taskinitusers.c
+++ b/cpukit/rtems/src/taskinitusers.c
@@ -29,7 +29,6 @@ void _RTEMS_tasks_Initialize_user_task( void )
   rtems_id                                id;
   rtems_status_code                       return_value;
   const rtems_initialization_tasks_table *user_task;
-  rtems_task_entry                        entry_point;
 
   user_task = &_RTEMS_tasks_User_task_table;
   return_value = rtems_task_create(
@@ -44,14 +43,9 @@ void _RTEMS_tasks_Initialize_user_task( void )
     _Internal_error( INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED );
   }
 
-  entry_point = user_task->entry_point;
-  if ( entry_point == NULL ) {
-    _Internal_error( INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL );
-  }
-
   return_value = rtems_task_start(
     id,
-    entry_point,
+    user_task->entry_point,
     user_task->argument
   );
   _Assert( rtems_is_status_successful( return_value ) );
diff --git a/spec/build/testsuites/sptests/grp.yml b/spec/build/testsuites/sptests/grp.yml
index 1c865777a7..b1bf85942d 100644
--- a/spec/build/testsuites/sptests/grp.yml
+++ b/spec/build/testsuites/sptests/grp.yml
@@ -218,8 +218,6 @@ links:
   uid: spextensions01
 - role: build-dependency
   uid: spfatal01
-- role: build-dependency
-  uid: spfatal02
 - role: build-dependency
   uid: spfatal03
 - role: build-dependency
diff --git a/spec/build/testsuites/sptests/spfatal02.yml b/spec/build/testsuites/sptests/spfatal02.yml
deleted file mode 100644
index 19e329a027..0000000000
--- a/spec/build/testsuites/sptests/spfatal02.yml
+++ /dev/null
@@ -1,19 +0,0 @@
-SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
-build-type: test-program
-cflags: []
-copyrights:
-- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
-cppflags: []
-cxxflags: []
-enabled-by: true
-features: c cprogram
-includes: []
-ldflags: []
-links: []
-source:
-- testsuites/sptests/spfatal02/init.c
-stlib: []
-target: testsuites/sptests/spfatal02.exe
-type: build
-use-after: []
-use-before: []
diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index 14788f7fb1..8813d43513 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -904,15 +904,6 @@ spfatal01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_spfatal01) \
 	$(support_includes)
 endif
 
-if TEST_spfatal02
-sp_tests += spfatal02
-sp_screens += spfatal02/spfatal02.scn
-sp_docs += spfatal02/spfatal02.doc
-spfatal02_SOURCES = spfatal02/init.c
-spfatal02_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_spfatal02) \
-	$(support_includes)
-endif
-
 if TEST_spfatal03
 sp_tests += spfatal03
 sp_screens += spfatal03/spfatal03.scn
diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
index 099ff0412b..4ca55e6a36 100644
--- a/testsuites/sptests/configure.ac
+++ b/testsuites/sptests/configure.ac
@@ -137,7 +137,6 @@ RTEMS_TEST_CHECK([speventsystem01])
 RTEMS_TEST_CHECK([speventtransient01])
 RTEMS_TEST_CHECK([spextensions01])
 RTEMS_TEST_CHECK([spfatal01])
-RTEMS_TEST_CHECK([spfatal02])
 RTEMS_TEST_CHECK([spfatal03])
 RTEMS_TEST_CHECK([spfatal04])
 RTEMS_TEST_CHECK([spfatal05])
diff --git a/testsuites/sptests/spfatal02/init.c b/testsuites/sptests/spfatal02/init.c
deleted file mode 100644
index 2700b4dd50..0000000000
--- a/testsuites/sptests/spfatal02/init.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "../spfatal_support/spfatal.h"
-
-/*
- * Classic API Init task create failure
- */
-
-#define CONFIGURE_INIT_TASK_ENTRY_POINT NULL
-
-#define FATAL_ERROR_TEST_NAME            "2"
-#define FATAL_ERROR_DESCRIPTION          "Classic API Init task start failure"
-#define FATAL_ERROR_EXPECTED_SOURCE      INTERNAL_ERROR_CORE
-#define FATAL_ERROR_EXPECTED_ERROR \
-  INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL
-
-static void force_error(void)
-{
-/*
- *  Case 2: Null entry
- */
-
-  /* we will not run this far */
-}
-
-#include "../spfatal_support/spfatalimpl.h"
diff --git a/testsuites/sptests/spfatal02/spfatal02.doc b/testsuites/sptests/spfatal02/spfatal02.doc
deleted file mode 100644
index 1e62051b52..0000000000
--- a/testsuites/sptests/spfatal02/spfatal02.doc
+++ /dev/null
@@ -1,20 +0,0 @@
-#  COPYRIGHT (c) 1989-2009.
-#  On-Line Applications Research Corporation (OAR).
-#
-#  The license and distribution terms for this file may be
-#  found in the file LICENSE in this distribution or at
-#  http://www.rtems.org/license/LICENSE.
-#
-
-This file describes the directives and concepts tested by this test set.
-
-test set name:  spfatal02
-
-directives:
-
-  rtems_task_start for a user initialization task
-
-concepts:
-
-+ Ensure that when rtems_task_start returns an error when creating a Classic
-  API user initialization task is properly treated as a fatal error.
diff --git a/testsuites/sptests/spfatal02/spfatal02.scn b/testsuites/sptests/spfatal02/spfatal02.scn
deleted file mode 100644
index a6e6d93501..0000000000
--- a/testsuites/sptests/spfatal02/spfatal02.scn
+++ /dev/null
@@ -1,3 +0,0 @@
-*** TEST FATAL 2 ***
-Fatal error (Classic API Init task start failure) hit
-*** END OF TEST FATAL 2 ***
-- 
2.26.2



More information about the devel mailing list