]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUILD: definitely silence some stupid GCC warnings
authorWilly Tarreau <w@1wt.eu>
Fri, 13 Dec 2013 14:14:55 +0000 (15:14 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 13 Dec 2013 14:21:36 +0000 (15:21 +0100)
commit89efaed6b67b30739c39f0ff6dd2089632d3fda6
tree4b060f6d08d4820cb938dd742a3bc2d2cf3f0276
parent2819e994174b5e4d6776013a1917a44acb1c6efd
BUILD: definitely silence some stupid GCC warnings

It's becoming increasingly difficult to ignore unwanted function returns in
debug code with gcc. Now even when you try to work around it, it suggests a
way to write your code differently. For example :

    src/frontend.c:187:65: warning: if statement has empty body [-Wempty-body]
                if (write(1, trash.str, trash.len) < 0) /* shut gcc warning */;
                                                                              ^
    src/frontend.c:187:65: note: put the semicolon on a separate line to silence this warning
    1 warning generated.

This is totally unacceptable, this code already had to be written this way
to shut it up in earlier versions. And now it comments the form ? What's the
purpose of the C language if you can't write anymore the code that does what
you want ?

Emeric proposed to just keep a global variable to drain such useless results
so that gcc stops complaining all the time it believes people who write code
are monkeys. The solution is acceptable because the useless assignment is done
only in debug code so it will not impact performance. This patch implements
this, until gcc becomes even "smarter" to detect that we tried to cheat.
include/common/standard.h
src/appsession.c
src/frontend.c
src/haproxy.c
src/proto_http.c
src/session.c