mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-05-04 12:41:00 +02:00
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.
This commit is contained in:
parent
7f58e9f1e0
commit
822d45678f
@ -3902,7 +3902,7 @@ const char *srv_update_addr_port(struct server *s, const char *addr, const char
|
||||
struct sockaddr_storage sa;
|
||||
int ret;
|
||||
char current_addr[INET6_ADDRSTRLEN];
|
||||
uint16_t current_port, new_port;
|
||||
uint16_t current_port, new_port = 0;
|
||||
struct buffer *msg;
|
||||
int ip_change = 0;
|
||||
int port_change = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user