From 96c27937090ce01b741f624bd02c555f8e4acaa9 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 2 Oct 2025 09:11:37 -0500 Subject: [PATCH] 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. --- testsuites/validation/tc-task-restart.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/testsuites/validation/tc-task-restart.c b/testsuites/validation/tc-task-restart.c index 3a06ae6d99..69de846871 100644 --- a/testsuites/validation/tc-task-restart.c +++ b/testsuites/validation/tc-task-restart.c @@ -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 );