From 30752f5df48074894c82b9b0d470716ba74af8d5 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 2 Oct 2025 09:14:46 -0500 Subject: [PATCH] testsuites/validation/tx-thread-queue.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 notpossible to reset events after the return. But analysis determined that the longjmp() should always returns to the same stack frame. Thus local variables should be preserved. The warning was disabled. This case was not addressed by adding the "returns_twice" attribute to setjmp() in setjmp.h. Updates #5364. --- testsuites/validation/tx-thread-queue.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/testsuites/validation/tx-thread-queue.c b/testsuites/validation/tx-thread-queue.c index 9d930c52dc..23e9878b90 100644 --- a/testsuites/validation/tx-thread-queue.c +++ b/testsuites/validation/tx-thread-queue.c @@ -285,10 +285,20 @@ static void ThreadQueueDeadlock( longjmp( ctx->before_enqueue, 1 ); } +/* + * This warning flags when the caller of setjmp() is assuming a local + * variable survives the longjmp() back. In this specific case, this + * assumption is OK because it never returns from the thread body and + * the variable "events" is preserved. + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wclobbered" + static void Worker( rtems_task_argument arg, TQWorkerKind worker ) { TQContext *ctx; + ctx = (TQContext *) arg; while ( true ) { @@ -445,6 +455,8 @@ static void Worker( rtems_task_argument arg, TQWorkerKind worker ) } } +#pragma GCC diagnostic pop + static void BlockerA( rtems_task_argument arg ) { Worker( arg, TQ_BLOCKER_A );