Hi Joris,

On Thu, May 23, 2013 at 01:53:19PM +0200, joris dedieu wrote:
> 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.

Thanks for doing this. But I'm really worried about the way code is
progressively turning to because of those stupid compiler warnings.
We're reaching a point where we uglify the code so much that it
becomes confusing and error-prone. Soon it will be harder to code in
C than in asm!

I think we'd rather work on silencing the compilers than altering
the code. Having C code produce warning when a function returns an
unused result is contrary to the initial principles of the C and
contrary to the underlying implementation.

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.

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 !

Willy


Reply via email to