1
0
mirror of http://git.haproxy.org/git/haproxy.git/ synced 2025-04-10 19:21:37 +00:00

BUILD: config: address build warning on raspbian+rpi4

Issue  reports that building on raspbian for rpi4 triggers this
warning:

  src/cfgparse.c: In function 'check_config_validity':
  src/cfgparse.c:3584:26: warning: argument 1 range [2147483648, 4294967295] exceeds maximum object size 2147483647 [-Walloc-size-larger-than=]
     newsrv->idle_conns = calloc((unsigned)global.nbthread, sizeof(*newsrv->idle_conns));
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It's surprising because the declared type is size_t and the argument is
unsigned (i.e. the same type on 32-bit) precisely to avoid cast issues,
but gcc seems to be too smart at this one and to issue a warning over
the valid range, implying that passing the originally required type would
also warn. Given that these are the only casts in calloc and other ones
don't complain, let's drop them.

All 3 were added by commit dc2f2753e ("MEDIUM: servers: Split the
connections into idle, safe, and available.")  that went into 2.2, so
this should be backported.
This commit is contained in:
Willy Tarreau 2020-07-17 14:18:36 +02:00
parent f706a794d8
commit ad37c7ab25

View File

@ -3558,7 +3558,7 @@ out_uri_auth_compat:
for (newsrv = curproxy->srv; newsrv; newsrv = newsrv->next) {
int i;
newsrv->available_conns = calloc((unsigned)global.nbthread, sizeof(*newsrv->available_conns));
newsrv->available_conns = calloc(global.nbthread, sizeof(*newsrv->available_conns));
if (!newsrv->available_conns) {
ha_alert("parsing [%s:%d] : failed to allocate idle connections for server '%s'.\n",
@ -3590,7 +3590,7 @@ out_uri_auth_compat:
}
}
newsrv->idle_conns = calloc((unsigned)global.nbthread, sizeof(*newsrv->idle_conns));
newsrv->idle_conns = calloc(global.nbthread, sizeof(*newsrv->idle_conns));
if (!newsrv->idle_conns) {
ha_alert("parsing [%s:%d] : failed to allocate idle connections for server '%s'.\n",
newsrv->conf.file, newsrv->conf.line, newsrv->id);
@ -3601,7 +3601,7 @@ out_uri_auth_compat:
for (i = 0; i < global.nbthread; i++)
MT_LIST_INIT(&newsrv->idle_conns[i]);
newsrv->safe_conns = calloc((unsigned)global.nbthread, sizeof(*newsrv->safe_conns));
newsrv->safe_conns = calloc(global.nbthread, sizeof(*newsrv->safe_conns));
if (!newsrv->safe_conns) {
ha_alert("parsing [%s:%d] : failed to allocate idle connections for server '%s'.\n",
newsrv->conf.file, newsrv->conf.line, newsrv->id);