testsuites/validation/tc-task-restart.c: Address -Wclobbered warning

Code should not rely on the contents of local variables set before
setjmp() after the longjmp() returns. In this case, it was possible
to set cpu_self after the return from setjmp().

This case was not addressed by adding the "returns_twice" attribute
to setjmp() in setjmp.h.

Updates #5364.
This commit is contained in:
Joel Sherrill
2025-10-02 09:11:37 -05:00
parent f34f2e0bf9
commit 96c2793709

View File

@@ -779,7 +779,12 @@ static void Signal( rtems_signal_set signals )
SetFatalHandler( ResumeThreadDispatch, ctx );
cpu_self = _Thread_Dispatch_disable();
if ( setjmp( ctx->thread_dispatch_context ) == 0 ) {
int jumped = setjmp( ctx->thread_dispatch_context );
/* cpu_self can be clobbered by setjmp/longjmp, so reload it */
cpu_self = _Per_CPU_Get();
if ( jumped == 0 ) {
Block( ctx );
} else {
_Thread_Dispatch_unnest( cpu_self );