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.
This commit is contained in:
Joel Sherrill
2025-10-02 09:14:46 -05:00
parent 96c2793709
commit 30752f5df4

View File

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