]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: thread: silence a build warning when threads are disabled
authorWilly Tarreau <w@1wt.eu>
Wed, 22 Mar 2023 09:28:50 +0000 (10:28 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 22 Mar 2023 09:40:06 +0000 (10:40 +0100)
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.

src/thread.c

index 14ade8b4e72b399e5575c4252301a458a94dcfea..7a4307ee5a1d1ba1217c4c3f45b8581a3fa6b214 100644 (file)
@@ -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;