BUILD: server: fix build regression on old compilers (<= gcc-4.4)
authorAurelien DARRAGON <adarragon@haproxy.com>
Mon, 25 Mar 2024 12:38:36 +0000 (13:38 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 25 Mar 2024 15:23:37 +0000 (16:23 +0100)
commit3de1acfb2350d758df7b4c3bfb81fa6113013ddd
tree4082679a73d51784b485ad88ad3271c8e4e47b15
parent56c4b29ff1e7df05201fa736aa3f35307443f73b
BUILD: server: fix build regression on old compilers (<= gcc-4.4)

Willy reported that since 3ac79b504 ("MEDIUM: server:
make server_set_inetaddr() updater serializable"), haproxy fails to
compile on some older compilers such as gcc-4.4 with this kind of error:

  src/server.c: In function 'snr_resolution_cb':
  src/server.c:4471: error: unknown field 'dns_resolver' specified in initializer
  compilation terminated due to -Wfatal-errors.
  make: *** [Makefile:1006: src/server.o] Error 1

This is due to referencing a member inside anonymous union from a compound
literal assignment. Apparently such use of anonymous union wasn't properly
supported back then on older compilers. To fix the issue, we give "u" name
to the parent union use this name to explicitly refer to the union where
relevant in the code (only a few changes fortunately).

The fix itself was verified to restore build compatibility with gcc 4.4
(and even 4.2).

As 3ac79b504 is used as a prerequisite for 64c9c8ef3 ("BUG/MINOR:
server/dns: use server_set_inetaddr() to unset srv addr from DNS"), please
consider backporting this patch too if 64c9c8ef3 happens to be backported
in 2.9.
include/haproxy/server-t.h
src/server.c