]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUILD: config: address build warning on raspbian+rpi4
authorWilly Tarreau <w@1wt.eu>
Fri, 17 Jul 2020 12:18:36 +0000 (14:18 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 17 Jul 2020 12:18:36 +0000 (14:18 +0200)
commitad37c7ab257826182c3fb0155d4360833c6ed0f1
treeb1c4dbf5de91ae57739c82419968685a554c3f11
parentf706a794d8b8d854cba4414adb6f9a1297c6fd02
BUILD: config: address build warning on raspbian+rpi4

Issue #747 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 [21474836484294967295] 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.
src/cfgparse.c