On Thu, Jan 23, 2020 at 10:59:00PM +0500, ???? ??????? wrote:
> > Could you please try to use (size_t) instead of (unsigned int) ? If it's
> > enough to shut it up, I'm fine with doing that change. Otherwise we'll
> > probably get rid of that stupid warning.
> >
> 
>   CC      src/server.o
>   CC      src/cfgparse.o
> src/cfgparse.c: In function 'check_config_validity':
> src/cfgparse.c:3642:33: warning: argument 1 range [2147483648, 4294967295]
> exceeds maximum object size 2147483647 [-Walloc-size-larger-than=]
>      newsrv->idle_orphan_conns = calloc((size_t)global.nbthread,
> sizeof(*newsrv->idle_orphan_conns));
> 
>  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In file included from src/cfgparse.c:24:
> /usr/arm-linux-gnueabihf/include/stdlib.h:541:14: note: in a call to
> allocation function 'calloc' declared here
>  extern void *calloc (size_t __nmemb, size_t __size)
>               ^~~~~~
>   CC      src/checks.o
> ^CMakefile:846: recipe for target 'src/checks.o' failed
> make: *** [src/checks.o] Interrupt

Thanks for the test! So basically this clearly proves we respect the
calling convention but the compiler still complains. OK I'm seeing in
the mad that it's for functions "decorated" with the "alloc_size"
attribute. Thus in short they enforce constraints that cannot be
expressed with available types. This is becoming totally ridiculous.

We're getting a huge collection of stupid warnings to shut up. I
suspect that the sum of all the code written to shut them is larger
than what haproxy 1.0 used to be :-/

The man page says we can disable this crap using
-Walloc-size-larger-than=SIZE_MAX but on my compiler (8.2) it simply
fails to build. However when passing explicit values not even that
large, I don't get any such warning, so I'm starting to think that
it's a real bug of GCC 9.2, because quite frankly, aside calling
calloc() with a char or short in argument, there's almost no way out
of this absurdity.

For me, calling it with -Walloc-size-larger-than=-1 makes it stay
silent. is it also the case for you ? You can patch your Makefile this
way:

diff --git a/Makefile b/Makefile
index 8399f6ca35..4757bc77e6 100644
--- a/Makefile
+++ b/Makefile
@@ -199,6 +199,7 @@ SPEC_CFLAGS += $(call cc-opt,-Wshift-negative-value)
 SPEC_CFLAGS += $(call cc-opt,-Wshift-overflow=2)
 SPEC_CFLAGS += $(call cc-opt,-Wduplicated-cond)
 SPEC_CFLAGS += $(call cc-opt,-Wnull-dereference)
+SPEC_CFLAGS += $(call cc-opt,-Walloc-size-larger-than=-1)
 
 #### Memory usage tuning
 # If small memory footprint is required, you can reduce the buffer size. There

If it still fails, we'll have to ignore it and wait for this monstrosity
to be fixed by their authors :-/

Willy

Reply via email to