From ac497071589e30cd266a6043a57d2627434f5f76 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 29 May 2014 01:04:35 +0200 Subject: [PATCH] BUILD: stats: workaround stupid and bogus -Werror=format-security behaviour As reported by Vincent Bernat and Ryan O'Hara, building haproxy with the option above causes this : src/dumpstats.c: In function 'stats_dump_sv_stats': src/dumpstats.c:3059:4: error: format not a string literal and no format arguments [-Werror=format-security] cc1: some warnings being treated as errors make: *** [src/dumpstats.o] Error 1 With that option, gcc wants an argument after a string format even when that string format is a const but not a litteral. It can be anything invalid, for example an integer when a string is expected, it just wants something. So feed it with something :-( --- src/dumpstats.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dumpstats.c b/src/dumpstats.c index fcfad4a0c..7c2170149 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -3056,7 +3056,8 @@ static int stats_dump_sv_stats(struct stream_interface *si, struct proxy *px, in } else if ((ref->agent.state & CHK_ST_ENABLED) && (ref->state == SRV_ST_STOPPED)) { chunk_appendf(&trash, "%s ", human_time(now.tv_sec - ref->last_change, 1)); - chunk_appendf(&trash, srv_hlt_st[1]); /* DOWN (agent) */ + /* DOWN (agent) */ + chunk_appendf(&trash, srv_hlt_st[1], "GCC: your -Werror=format-security is bogus, annoying, and hides real bugs, I don't thank you, really!"); } else if (ref->check.state & CHK_ST_ENABLED) { chunk_appendf(&trash, "%s ", human_time(now.tv_sec - ref->last_change, 1));