]> git.kaiwu.me - haproxy.git/commitdiff
BUILD: protocol: silence -Warray-bounds in single-group builds
authorOlivier Houchard <ohouchard@haproxy.com>
Fri, 14 Aug 2026 16:59:44 +0000 (18:59 +0200)
committerOlivier Houchard <cognet@ci0.org>
Fri, 14 Aug 2026 16:57:43 +0000 (18:57 +0200)
When MAX_TGROUPS is 1 (e.g. built without threads), gcc warns that the
ha_tgroup_ctx[] accesses in protocol_grab_foreign_receivers() may be out
of bounds, as it cannot know that nbtgroups < 2 makes them unreachable.

src/protocol.c

index a4a0332d59d1e707a0fffb0f8d1cb0a912bbcff8..eb44f9802fe6387ccffd7eba1d6186340b4f51c0 100644 (file)
@@ -197,7 +197,7 @@ int protocol_getsocks_foreign_fds(struct receiver ***orxs, int **ofds)
        *orxs = NULL;
        *ofds = NULL;
 
-       if (!(global.tune.options & GTUNE_NO_TG_FD_SHARING) || global.nbtgroups < 2)
+       if (MAX_TGROUPS < 2 || !(global.tune.options & GTUNE_NO_TG_FD_SHARING) || global.nbtgroups < 2)
                return 0;
 
        /* first pass: count the candidates */