mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-11 10:03:40 +00:00
validation: Address -Wclobbered warnings
Use functions with const parameters and const local variables to silence -Wclobbered warnings. Updates #5364.
This commit is contained in:
committed by
Gedare Bloom
parent
c49cfbf9a9
commit
e66a33fd7a
@@ -675,6 +675,15 @@ static void ResumeThreadDispatch(
|
|||||||
longjmp( ctx->thread_dispatch_context, 1 );
|
longjmp( ctx->thread_dispatch_context, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void DeleteAndJumpBack( Context * const ctx )
|
||||||
|
{
|
||||||
|
if ( setjmp( ctx->thread_dispatch_context ) == 0 ) {
|
||||||
|
ctx->status = rtems_task_delete( ctx->id );
|
||||||
|
} else {
|
||||||
|
_Thread_Dispatch_unnest( _Per_CPU_Get() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void Delete( void *arg )
|
static void Delete( void *arg )
|
||||||
{
|
{
|
||||||
Context *ctx;
|
Context *ctx;
|
||||||
@@ -716,12 +725,7 @@ static void Delete( void *arg )
|
|||||||
log = T_scheduler_record_10( &ctx->scheduler_log );
|
log = T_scheduler_record_10( &ctx->scheduler_log );
|
||||||
T_null( log );
|
T_null( log );
|
||||||
|
|
||||||
if ( setjmp( ctx->thread_dispatch_context ) == 0 ) {
|
DeleteAndJumpBack( ctx );
|
||||||
ctx->status = rtems_task_delete( ctx->id );
|
|
||||||
} else {
|
|
||||||
_Thread_Dispatch_unnest( _Per_CPU_Get() );
|
|
||||||
}
|
|
||||||
|
|
||||||
CaptureWorkerState( ctx );
|
CaptureWorkerState( ctx );
|
||||||
|
|
||||||
if ( ctx->dispatch_disabled ) {
|
if ( ctx->dispatch_disabled ) {
|
||||||
@@ -763,6 +767,18 @@ static void BlockDone( Context *ctx )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void BlockAndJumpBack(
|
||||||
|
Context * const ctx,
|
||||||
|
Per_CPU_Control * const cpu_self
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if ( setjmp( ctx->thread_dispatch_context ) == 0 ) {
|
||||||
|
Block( ctx );
|
||||||
|
} else {
|
||||||
|
_Thread_Dispatch_unnest( cpu_self );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void Signal( rtems_signal_set signals )
|
static void Signal( rtems_signal_set signals )
|
||||||
{
|
{
|
||||||
Context *ctx;
|
Context *ctx;
|
||||||
@@ -780,12 +796,7 @@ static void Signal( rtems_signal_set signals )
|
|||||||
SetFatalHandler( ResumeThreadDispatch, ctx );
|
SetFatalHandler( ResumeThreadDispatch, ctx );
|
||||||
cpu_self = _Thread_Dispatch_disable();
|
cpu_self = _Thread_Dispatch_disable();
|
||||||
|
|
||||||
if ( setjmp( ctx->thread_dispatch_context ) == 0 ) {
|
BlockAndJumpBack( ctx, cpu_self );
|
||||||
Block( ctx );
|
|
||||||
} else {
|
|
||||||
_Thread_Dispatch_unnest( cpu_self );
|
|
||||||
}
|
|
||||||
|
|
||||||
CallWithinISR( Delete, ctx );
|
CallWithinISR( Delete, ctx );
|
||||||
|
|
||||||
_Thread_Dispatch_direct( cpu_self );
|
_Thread_Dispatch_direct( cpu_self );
|
||||||
|
|||||||
@@ -744,8 +744,8 @@ static void ResumeThreadDispatch(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void TriggerNestedRequestViaSelfRestart(
|
static void TriggerNestedRequestViaSelfRestart(
|
||||||
Context *ctx,
|
Context * const ctx,
|
||||||
Per_CPU_Control *cpu_self
|
Per_CPU_Control * const cpu_self
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
WrapThreadQueueExtract( &ctx->wrap_tq_ctx, ctx->worker_tcb );
|
WrapThreadQueueExtract( &ctx->wrap_tq_ctx, ctx->worker_tcb );
|
||||||
@@ -761,6 +761,18 @@ static void TriggerNestedRequestViaSelfRestart(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void BlockAndJumpBack(
|
||||||
|
Context * const ctx,
|
||||||
|
Per_CPU_Control * const cpu_self
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if ( setjmp( ctx->thread_dispatch_context ) == 0 ) {
|
||||||
|
Block( ctx );
|
||||||
|
} else {
|
||||||
|
_Thread_Dispatch_unnest( cpu_self );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void Signal( rtems_signal_set signals )
|
static void Signal( rtems_signal_set signals )
|
||||||
{
|
{
|
||||||
Context *ctx;
|
Context *ctx;
|
||||||
@@ -777,15 +789,9 @@ static void Signal( rtems_signal_set signals )
|
|||||||
if ( ctx->interrupt || ctx->nested_request ) {
|
if ( ctx->interrupt || ctx->nested_request ) {
|
||||||
if ( ctx->blocked ) {
|
if ( ctx->blocked ) {
|
||||||
SetFatalHandler( ResumeThreadDispatch, ctx );
|
SetFatalHandler( ResumeThreadDispatch, ctx );
|
||||||
(void) _Thread_Dispatch_disable();
|
cpu_self = _Thread_Dispatch_disable();
|
||||||
|
BlockAndJumpBack( ctx, cpu_self );
|
||||||
|
|
||||||
if ( setjmp( ctx->thread_dispatch_context ) == 0 ) {
|
|
||||||
Block( ctx );
|
|
||||||
} else {
|
|
||||||
_Thread_Dispatch_unnest( _Per_CPU_Get() );
|
|
||||||
}
|
|
||||||
|
|
||||||
cpu_self = _Per_CPU_Get();
|
|
||||||
if ( ctx->interrupt ) {
|
if ( ctx->interrupt ) {
|
||||||
CallWithinISR( Restart, ctx );
|
CallWithinISR( Restart, ctx );
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -210,10 +210,9 @@ static void ScoreSmpValFatal_Action_0( ScoreSmpValFatal_Context *ctx )
|
|||||||
*/
|
*/
|
||||||
static void ScoreSmpValFatal_Action_1( ScoreSmpValFatal_Context *ctx )
|
static void ScoreSmpValFatal_Action_1( ScoreSmpValFatal_Context *ctx )
|
||||||
{
|
{
|
||||||
Per_CPU_Control *cpu;
|
Per_CPU_Control * const cpu = _Per_CPU_Get_by_index( 0 );
|
||||||
|
|
||||||
SetFatalHandler( FatalRecordAndJump, ctx );
|
SetFatalHandler( FatalRecordAndJump, ctx );
|
||||||
cpu = _Per_CPU_Get_by_index( 0 );
|
|
||||||
_Per_CPU_Submit_job( cpu, &job );
|
_Per_CPU_Submit_job( cpu, &job );
|
||||||
|
|
||||||
if ( setjmp( fatal_before ) == 0 ) {
|
if ( setjmp( fatal_before ) == 0 ) {
|
||||||
@@ -240,16 +239,14 @@ static void ScoreSmpValFatal_Action_1( ScoreSmpValFatal_Context *ctx )
|
|||||||
*/
|
*/
|
||||||
static void ScoreSmpValFatal_Action_2( ScoreSmpValFatal_Context *ctx )
|
static void ScoreSmpValFatal_Action_2( ScoreSmpValFatal_Context *ctx )
|
||||||
{
|
{
|
||||||
Per_CPU_Control *cpu;
|
|
||||||
|
|
||||||
SetFatalHandler( FatalRecordAndJump, ctx );
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This element is outside the array. This is not an issue since
|
* This element is outside the array. This is not an issue since
|
||||||
* _SMP_Start_multitasking_on_secondary_processor() does not access the
|
* _SMP_Start_multitasking_on_secondary_processor() does not access the
|
||||||
* structure.
|
* structure.
|
||||||
*/
|
*/
|
||||||
cpu = _Per_CPU_Get_by_index( 3 );
|
Per_CPU_Control * const cpu = _Per_CPU_Get_by_index( 3 );
|
||||||
|
|
||||||
|
SetFatalHandler( FatalRecordAndJump, ctx );
|
||||||
|
|
||||||
if ( setjmp( fatal_before ) == 0 ) {
|
if ( setjmp( fatal_before ) == 0 ) {
|
||||||
_SMP_Start_multitasking_on_secondary_processor( cpu );
|
_SMP_Start_multitasking_on_secondary_processor( cpu );
|
||||||
@@ -275,10 +272,9 @@ static void ScoreSmpValFatal_Action_2( ScoreSmpValFatal_Context *ctx )
|
|||||||
*/
|
*/
|
||||||
static void ScoreSmpValFatal_Action_3( ScoreSmpValFatal_Context *ctx )
|
static void ScoreSmpValFatal_Action_3( ScoreSmpValFatal_Context *ctx )
|
||||||
{
|
{
|
||||||
Per_CPU_Control *cpu;
|
Per_CPU_Control * const cpu = _Per_CPU_Get_by_index( 2 );
|
||||||
|
|
||||||
SetFatalHandler( FatalRecordAndJump, ctx );
|
SetFatalHandler( FatalRecordAndJump, ctx );
|
||||||
cpu = _Per_CPU_Get_by_index( 2 );
|
|
||||||
|
|
||||||
if ( setjmp( fatal_before ) == 0 ) {
|
if ( setjmp( fatal_before ) == 0 ) {
|
||||||
_SMP_Start_multitasking_on_secondary_processor( cpu );
|
_SMP_Start_multitasking_on_secondary_processor( cpu );
|
||||||
|
|||||||
@@ -285,20 +285,22 @@ static void ThreadQueueDeadlock(
|
|||||||
longjmp( ctx->before_enqueue, 1 );
|
longjmp( ctx->before_enqueue, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static void EnqueueFatal( TQContext * const ctx, TQWorkerKind const worker )
|
||||||
* This warning flags when the caller of setjmp() is assuming a local
|
{
|
||||||
* variable survives the longjmp() back. In this specific case, this
|
SetFatalHandler( ThreadQueueDeadlock, ctx );
|
||||||
* assumption is OK because it never returns from the thread body and
|
|
||||||
* the variable "events" is preserved.
|
if ( setjmp( ctx->before_enqueue ) == 0 ) {
|
||||||
*/
|
ctx->status[ worker ] = STATUS_MINUS_ONE;
|
||||||
#pragma GCC diagnostic push
|
Enqueue( ctx, worker, ctx->wait );
|
||||||
#pragma GCC diagnostic ignored "-Wclobbered"
|
} else {
|
||||||
|
ctx->status[ worker ] = STATUS_DEADLOCK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void Worker( rtems_task_argument arg, TQWorkerKind worker )
|
static void Worker( rtems_task_argument arg, TQWorkerKind worker )
|
||||||
{
|
{
|
||||||
TQContext *ctx;
|
TQContext *ctx;
|
||||||
|
|
||||||
|
|
||||||
ctx = (TQContext *) arg;
|
ctx = (TQContext *) arg;
|
||||||
|
|
||||||
while ( true ) {
|
while ( true ) {
|
||||||
@@ -332,14 +334,7 @@ static void Worker( rtems_task_argument arg, TQWorkerKind worker )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( ( events & TQ_EVENT_ENQUEUE_FATAL ) != 0 ) {
|
if ( ( events & TQ_EVENT_ENQUEUE_FATAL ) != 0 ) {
|
||||||
SetFatalHandler( ThreadQueueDeadlock, ctx );
|
EnqueueFatal( ctx, worker );
|
||||||
|
|
||||||
if ( setjmp( ctx->before_enqueue ) == 0 ) {
|
|
||||||
ctx->status[ worker ] = STATUS_MINUS_ONE;
|
|
||||||
Enqueue( ctx, worker, ctx->wait );
|
|
||||||
} else {
|
|
||||||
ctx->status[ worker ] = STATUS_DEADLOCK;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ( events & TQ_EVENT_TIMEOUT ) != 0 ) {
|
if ( ( events & TQ_EVENT_TIMEOUT ) != 0 ) {
|
||||||
@@ -455,8 +450,6 @@ static void Worker( rtems_task_argument arg, TQWorkerKind worker )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
static void BlockerA( rtems_task_argument arg )
|
static void BlockerA( rtems_task_argument arg )
|
||||||
{
|
{
|
||||||
Worker( arg, TQ_BLOCKER_A );
|
Worker( arg, TQ_BLOCKER_A );
|
||||||
@@ -644,20 +637,15 @@ Status_Control TQEnqueue( TQContext *ctx, TQWait wait )
|
|||||||
return ( *ctx->enqueue )( ctx, wait );
|
return ( *ctx->enqueue )( ctx, wait );
|
||||||
}
|
}
|
||||||
|
|
||||||
Status_Control TQEnqueueFatal( TQContext *ctx )
|
Status_Control TQEnqueueFatal( TQContext * const ctx )
|
||||||
{
|
{
|
||||||
Status_Control status;
|
|
||||||
|
|
||||||
SetFatalHandler( ThreadQueueDeadlock, ctx );
|
SetFatalHandler( ThreadQueueDeadlock, ctx );
|
||||||
status = STATUS_MINUS_ONE;
|
|
||||||
|
|
||||||
if ( setjmp( ctx->before_enqueue ) == 0 ) {
|
if ( setjmp( ctx->before_enqueue ) == 0 ) {
|
||||||
status = TQEnqueue( ctx, ctx->wait );
|
return TQEnqueue( ctx, ctx->wait );
|
||||||
} else {
|
|
||||||
status = STATUS_DEADLOCK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return STATUS_DEADLOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TQEnqueueDone( TQContext *ctx )
|
void TQEnqueueDone( TQContext *ctx )
|
||||||
|
|||||||
Reference in New Issue
Block a user