From: Willy Tarreau Date: Sat, 14 Mar 2020 10:03:20 +0000 (+0100) Subject: MINOR: use DISGUISE() everywhere we deliberately want to ignore a result X-Git-Tag: v2.2-dev5~59 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2e8ab6b5600c7b312d13178f1285b766eaae5fcb;p=thirdparty%2Fhaproxy.git MINOR: use DISGUISE() everywhere we deliberately want to ignore a result It's more generic and versatile than the previous shut_your_big_mouth_gcc() that was used to silence annoying warnings as it's not limited to ignoring syscalls returns only. This allows us to get rid of the aforementioned function and the shut_your_big_mouth_gcc_int variable, that started to look ugly in multi-threaded environments. --- diff --git a/include/common/standard.h b/include/common/standard.h index 40627b2f4c..cf8f1f0469 100644 --- a/include/common/standard.h +++ b/include/common/standard.h @@ -1339,19 +1339,6 @@ void debug_hexdump(FILE *out, const char *pfx, const char *buf, unsigned int bas __attribute__((format(printf, 1, 2))) void calltrace(char *fmt, ...); -/* used from everywhere just to drain results we don't want to read and which - * recent versions of gcc increasingly and annoyingly complain about. - */ -extern int shut_your_big_mouth_gcc_int; - -/* used from everywhere just to drain results we don't want to read and which - * recent versions of gcc increasingly and annoyingly complain about. - */ -static inline void shut_your_big_mouth_gcc(int r) -{ - shut_your_big_mouth_gcc_int = r; -} - /* same as strstr() but case-insensitive */ const char *strnistr(const char *str1, int len_str1, const char *str2, int len_str2); diff --git a/include/proto/fd.h b/include/proto/fd.h index 8dadae8f9f..bcf71d39b8 100644 --- a/include/proto/fd.h +++ b/include/proto/fd.h @@ -436,7 +436,7 @@ static inline void wake_thread(int tid) { char c = 'c'; - shut_your_big_mouth_gcc(write(poller_wr_pipe[tid], &c, 1)); + DISGUISE(write(poller_wr_pipe[tid], &c, 1)); } diff --git a/src/debug.c b/src/debug.c index a3b208a334..c11ab544de 100644 --- a/src/debug.c +++ b/src/debug.c @@ -263,7 +263,7 @@ void ha_panic() chunk_reset(&trash); chunk_appendf(&trash, "Thread %u is about to kill the process.\n", tid + 1); ha_thread_dump_all_to_trash(); - shut_your_big_mouth_gcc(write(2, trash.area, trash.data)); + DISGUISE(write(2, trash.area, trash.data)); for (;;) abort(); } diff --git a/src/frontend.c b/src/frontend.c index 23b9c3c31c..099d839c33 100644 --- a/src/frontend.c +++ b/src/frontend.c @@ -134,7 +134,7 @@ int frontend_accept(struct stream *s) break; } - shut_your_big_mouth_gcc(write(1, trash.area, trash.data)); + DISGUISE(write(1, trash.area, trash.data)); } if (fe->mode == PR_MODE_HTTP) diff --git a/src/haproxy.c b/src/haproxy.c index df3b9a6c75..714a49073c 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -225,11 +225,6 @@ const struct linger nolinger = { .l_onoff = 1, .l_linger = 0 }; char hostname[MAX_HOSTNAME_LEN]; char localpeer[MAX_HOSTNAME_LEN]; -/* used from everywhere just to drain results we don't want to read and which - * recent versions of gcc increasingly and annoyingly complain about. - */ -int shut_your_big_mouth_gcc_int = 0; - static char **next_argv = NULL; struct list proc_list = LIST_HEAD_INIT(proc_list); @@ -3323,7 +3318,7 @@ int main(int argc, char **argv) char pidstr[100]; snprintf(pidstr, sizeof(pidstr), "%d\n", (int)getpid()); if (pidfd >= 0) - shut_your_big_mouth_gcc(write(pidfd, pidstr, strlen(pidstr))); + DISGUISE(write(pidfd, pidstr, strlen(pidstr))); } /* the father launches the required number of processes */ @@ -3344,7 +3339,7 @@ int main(int argc, char **argv) if (pidfd >= 0 && !(global.mode & MODE_MWORKER)) { char pidstr[100]; snprintf(pidstr, sizeof(pidstr), "%d\n", ret); - shut_your_big_mouth_gcc(write(pidfd, pidstr, strlen(pidstr))); + DISGUISE(write(pidfd, pidstr, strlen(pidstr))); } if (global.mode & MODE_MWORKER) { struct mworker_proc *child; diff --git a/src/http_ana.c b/src/http_ana.c index 88f7937b19..f5a5d0de5a 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -4973,7 +4973,7 @@ static void http_debug_stline(const char *dir, struct stream *s, const struct ht chunk_memcat(&trash, HTX_SL_P3_PTR(sl), max); trash.area[trash.data++] = '\n'; - shut_your_big_mouth_gcc(write(1, trash.area, trash.data)); + DISGUISE(write(1, trash.area, trash.data)); } /* @@ -5000,7 +5000,7 @@ static void http_debug_hdr(const char *dir, struct stream *s, const struct ist n chunk_memcat(&trash, v.ptr, max); trash.area[trash.data++] = '\n'; - shut_your_big_mouth_gcc(write(1, trash.area, trash.data)); + DISGUISE(write(1, trash.area, trash.data)); } /* Allocate a new HTTP transaction for stream unless there is one already. diff --git a/src/stream.c b/src/stream.c index 7b63f1d313..c059a7a225 100644 --- a/src/stream.c +++ b/src/stream.c @@ -2300,7 +2300,7 @@ struct task *process_stream(struct task *t, void *context, unsigned short state) s->uniq_id, s->be->id, objt_cs(si_f->end) ? (unsigned short)objt_cs(si_f->end)->conn->handle.fd : -1, objt_cs(si_b->end) ? (unsigned short)objt_cs(si_b->end)->conn->handle.fd : -1); - shut_your_big_mouth_gcc(write(1, trash.area, trash.data)); + DISGUISE(write(1, trash.area, trash.data)); } if (si_f->state == SI_ST_CLO && @@ -2309,7 +2309,7 @@ struct task *process_stream(struct task *t, void *context, unsigned short state) s->uniq_id, s->be->id, objt_cs(si_f->end) ? (unsigned short)objt_cs(si_f->end)->conn->handle.fd : -1, objt_cs(si_b->end) ? (unsigned short)objt_cs(si_b->end)->conn->handle.fd : -1); - shut_your_big_mouth_gcc(write(1, trash.area, trash.data)); + DISGUISE(write(1, trash.area, trash.data)); } } @@ -2376,7 +2376,7 @@ struct task *process_stream(struct task *t, void *context, unsigned short state) s->uniq_id, s->be->id, objt_cs(si_f->end) ? (unsigned short)objt_cs(si_f->end)->conn->handle.fd : -1, objt_cs(si_b->end) ? (unsigned short)objt_cs(si_b->end)->conn->handle.fd : -1); - shut_your_big_mouth_gcc(write(1, trash.area, trash.data)); + DISGUISE(write(1, trash.area, trash.data)); } s->logs.t_close = tv_ms_elapsed(&s->logs.tv_accept, &now);