]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: use DISGUISE() everywhere we deliberately want to ignore a result
authorWilly Tarreau <w@1wt.eu>
Sat, 14 Mar 2020 10:03:20 +0000 (11:03 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 14 Mar 2020 10:04:49 +0000 (11:04 +0100)
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.

include/common/standard.h
include/proto/fd.h
src/debug.c
src/frontend.c
src/haproxy.c
src/http_ana.c
src/stream.c

index 40627b2f4c27a4d9e5e2f7eb5cedf99588900c7d..cf8f1f0469935fe328e00147de071270f2752be4 100644 (file)
@@ -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);
 
index 8dadae8f9f6f436b1418013e0de1afbf600d7a7c..bcf71d39b8e5a9a1c131296100963219218ce3bf 100644 (file)
@@ -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));
 }
 
 
index a3b208a33412f25ae6a23e671534f511bd63ce9d..c11ab544de9f138a72af415b1f45f7f20fa94078 100644 (file)
@@ -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();
 }
index 23b9c3c31cf7a55be56123aebf68777859913ac4..099d839c338ac04362dd0ae0d53f706b89a2c20a 100644 (file)
@@ -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)
index df3b9a6c75c946f693644df09a227058ebad4dcf..714a49073c176fab1664a936afe4fe6da42c8839 100644 (file)
@@ -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;
index 88f7937b194846d7f8396f2c3209794c9efdd683..f5a5d0de5aa36725049409b104b7e258790f08eb 100644 (file)
@@ -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 <s> unless there is one already.
index 7b63f1d31319f4a185e2defbb7f50fef6cea990e..c059a7a2252baab7a497ae3e6f33d65e6a541abc 100644 (file)
@@ -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);