Avoid INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL

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

Update #4181.
This commit is contained in:
Sebastian Huber
2020-11-19 15:30:17 +01:00
parent ef8c4ebce7
commit bc175a1cab
10 changed files with 23 additions and 90 deletions

View File

@@ -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,

View File

@@ -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,

View File

@@ -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 ) );

View File

@@ -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

View File

@@ -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: []

View File

@@ -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

View File

@@ -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])

View File

@@ -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"

View File

@@ -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.

View File

@@ -1,3 +0,0 @@
*** TEST FATAL 2 ***
Fatal error (Classic API Init task start failure) hit
*** END OF TEST FATAL 2 ***