From: Willy Tarreau Date: Wed, 22 Mar 2023 09:28:50 +0000 (+0100) Subject: BUILD: thread: silence a build warning when threads are disabled X-Git-Tag: v2.8-dev6~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1b536a11e705490fddd188fddf6336ddeea36f58;p=thirdparty%2Fhaproxy.git BUILD: thread: silence a build warning when threads are disabled When threads are disabled, the compiler complains that we might be accessing tg->abs[] out of bounds since the array is of size 1. It cannot know that the condition to do this is never met, and given that it's not in a fast path, we can make it more obvious. --- diff --git a/src/thread.c b/src/thread.c index 14ade8b4e7..7a4307ee5a 100644 --- a/src/thread.c +++ b/src/thread.c @@ -1261,7 +1261,9 @@ int thread_resolve_group_mask(struct thread_set *ts, int defgrp, char **err) uint base = ha_tgroup_info[g].base % LONGBITS; mask = ts->abs[block] >> base; - if (base && ha_tgroup_info[g].count > (LONGBITS - base)) + if (base && + (block + 1) < sizeof(ts->abs) / sizeof(ts->abs[0]) && + ha_tgroup_info[g].count > (LONGBITS - base)) mask |= ts->abs[block + 1] << (LONGBITS - base); mask &= nbits(ha_tgroup_info[g].count); mask &= ha_tgroup_info[g].threads_enabled;