]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: task: silence a build warning with threads disabled
authorWilly Tarreau <w@1wt.eu>
Thu, 25 Jun 2026 08:48:44 +0000 (10:48 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 25 Jun 2026 08:54:07 +0000 (10:54 +0200)
The compiler doesn't know that a random value based on global.nbthread
is necessarily smaller than MAX_THREADS, and when picking a random
thread number while single-threaded it complains that new_tid 1 is
out of bounds for the array. In fact all this is dead code in this
case.

Let's tell it about it to silence the warning.

src/task.c

index cde958e83b8db736ac3251b70c0ecfa14125eb1c..8eabb463391475bea6bba22ef772b52af926d615 100644 (file)
@@ -395,6 +395,8 @@ void wake_expired_tasks()
 
                                        if (new_tid == tid)
                                                continue;
+
+                                       ASSUME(new_tid < MAX_THREADS);
                                        if (ha_thread_ctx[new_tid].rq_total * 2 < th_ctx->rq_total) {
                                                int cur_state;
                                                do {