From: Willy Tarreau Date: Sun, 26 May 2019 09:50:08 +0000 (+0200) Subject: BUILD: connections: shut up gcc about impossible out-of-bounds warning X-Git-Tag: v2.0-dev5~66 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08e2b41e8183bede36f4fca1b8f849f18e4be13e;p=thirdparty%2Fhaproxy.git BUILD: connections: shut up gcc about impossible out-of-bounds warning Since commit 88698d9 ("MEDIUM: connections: Add a way to control the number of idling connections.") when building without threads, gcc complains that the operations made on the idle_orphan_conns[] list is out of bounds, which is always false since 1) can only equal zero, and 2) given it's equal to we never even enter the loop. But as usual it thinks it knows better, so let's mask the origin of this value to shut it up. Another solution consists in making unsigned and adding an explicit range check. --- diff --git a/src/backend.c b/src/backend.c index 467ef57a9b..4dff185ec5 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1354,6 +1354,13 @@ int connect_server(struct stream *s) for (i = 0; i < global.nbthread; i++) { if (i == tid) continue; + + // just silence stupid gcc which reports an absurd + // out-of-bounds warning for which is always + // exactly zero without threads, but it seems to + // see it possibly larger. + ALREADY_CHECKED(i); + tokill_conn = LIST_POP_LOCKED(&srv->idle_orphan_conns[i], struct connection *, list); if (tokill_conn) {