Re: [PATCH] MINOR: mute warnings while compiling with clang

2013-05-27 Thread Willy Tarreau
Hi Joris,

On Mon, May 27, 2013 at 07:17:28PM +0200, joris dedieu wrote:
  So maybe we can find some expect unused attributes for the functions
  and macros, or maybe we can disable those stupid checks in the compiler's
  cflags.
 
 So what about a conditional directive in the Makefile ? Something like
 
 diff --git a/Makefile b/Makefile
 index 5e12af8..89ca6a4 100644
 --- a/Makefile
 +++ b/Makefile
 @@ -154,6 +154,10 @@ ADDLIB =
  DEFINE =
  SILENT_DEFINE =
 
 + Compilers stupid warnings
 +# Sometimes compilers emit warnings that don't need a fix. Mute them.
 +COMPILER_CRAPS.clang   = -Wno-unused-value
 +COMPILER_CRAPS = $(COMPILER_CRAPS.$(CC))
(...)

Could be one solution indeed. That way people who want to force it on
their other compiler when using cross-compilers would simply just have
to force COMPILER_CRAPS instead.

When I have some time for this, I'll add some automatic detection of
supported -W* flags to disable these things in a portable way.

  Anyway, I'm really tired at fighting with this compilers!
 
  So if you can find portable solutions which disable those annoying
  stupid warnings, I'm all ears open !
 
 I know one unfortunately , but it's called autoconf :(

And it will be even worse, because instead of just figuring what variable
in the makefile would need to be adapted, users will have to fight for
hours or days to work around the autoconf mess.

Best regards,
Willy




[PATCH] MINOR: mute warnings while compiling with clang

2013-05-23 Thread joris dedieu
Hello,

I noticed several warings while compiling haproxy with clang (from
FreeBSD 9.1 base system).

* 145 unused-value regarding mini-clist.h (LIST_ADD, LIST_ADDQ,
LIST_DEL) and standard.h (UBOUND

src/haproxy.c:1206:4: warning: expression result unused [-Wunused-value]
LIST_DEL(log-list);
^~~~
include/common/mini-clist.h:117:95: note: expanded from macro 'LIST_DEL'
...({ typeof(el) __ret = (el); (el)-n-p = (el)-p; (el)-p-n =
(el)-n; (__ret); })

   ^
The patch mute then by casting the return value to (void) as we can
expect further usage of those values.

* 14 empty-body regarding a gcc warning fix

src/haproxy.c:1532:73: warning: if statement has empty body [-Wempty-body]
if (write(pidfd, pidstr,
strlen(pidstr))  0) /* shut gcc warning */;

 ^
src/haproxy.c:1532:73: note: put the semicolon on a separate line to
silence this warning [-Wempty-body]

The patch just apply clang recommendation  put the semicolon on a
separate line to silence this warning  (adding a hack to another).


As they are quite long, patches are attached.

Best regards
Joris


clang-unused-value.patch
Description: Binary data


clang-empty-body.patch
Description: Binary data