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.
This commit is contained in:
Willy Tarreau 2020-03-14 11:03:20 +01:00
parent 15ed69fd3f
commit 2e8ab6b560
7 changed files with 10 additions and 28 deletions

View 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);

View 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));
}

View 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();
}

View 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)

View 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;

View 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.

View 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);