]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUILD: backend: silence a build warning when threads are disabled
authorWilly Tarreau <w@1wt.eu>
Wed, 12 Mar 2025 17:16:14 +0000 (18:16 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 12 Mar 2025 17:16:14 +0000 (18:16 +0100)
commit78ef52dbd1d2432b7ff7b1ed6ebf3b1827cf31ce
treef0d3aff6f1d8acc38f9996a0506bd360c4f160d7
parentb61ed9babe879fd5603af4643c1d60c8ab48d096
BUILD: backend: silence a build warning when threads are disabled

Since commit 8de8ed4f48 ("MEDIUM: connections: Allow taking over
connections from other tgroups.") we got this partially absurd
build warning when disabling threads:

  src/backend.c: In function 'conn_backend_get':
  src/backend.c:1371:27: warning: array subscript [0, 0] is outside array bounds of 'struct tgroup_info[1]' [-Warray-bounds]

The reason is that gcc sees that curtgid is not equal to tgid which is
defined as 1 in this case, thus it figures that tgroup_info[curtgid-1]
will be anything but zero and that doesn't fit. It is ridiculous as it
is a perfect case of dead code elimination which should not warrant a
warning. Nevertheless we know we don't need to do this when threads are
disabled and in this case there will not be more than 1 thread group, so
we can happily use that preliminary test to help the compiler eliminate
the dead condition and avoid spitting this warning.

No backport is needed.
src/backend.c