]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUILD: server: shut a bogus gcc warning on certain ubuntu
authorWilly Tarreau <w@1wt.eu>
Thu, 30 Nov 2023 16:48:03 +0000 (17:48 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 30 Nov 2023 16:48:03 +0000 (17:48 +0100)
commit822d45678f20480e9b6431685932601b77f4157f
tree4951e260d923389a68981291046fcbe12d49f2f1
parent7f58e9f1e01e746cd432ea107b3b9af1c6955cbd
BUILD: server: shut a bogus gcc warning on certain ubuntu

On ubuntu 20.04 and 22.04 with gcc 9.4 and 11.4 respectively, we get
the following warning:

  src/server.c: In function 'srv_update_addr_port':
  src/server.c:4027:3: warning: 'new_port' may be used uninitialized in this function [-Wmaybe-uninitialized]
   4027 |   _srv_event_hdl_prepare_inetaddr(&cb_data.addr, &s->addr, s->svc_port,
        |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   4028 |                                   ((ip_change) ? &sa : &s->addr),
        |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   4029 |                                   ((port_change) ? new_port : s->svc_port),
        |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   4030 |                                   1);
        |                                   ~~

It's clearly wrong, port_change only changes from 0 to anything else
*after* assigning new_port. Let's just preset new_port to zero instead
of trying to play smart with the compiler.
src/server.c