From 5a7d6ebf2c38ab004fb85a7465470c1be8d1c47e Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 26 Nov 2020 22:25:10 +0100 Subject: [PATCH] MINOR: fd/threads: silence a build warning with threads disabled Building with gcc-9.3.0 without threads may result in this warning: In file included from include/haproxy/api-t.h:36, from include/haproxy/api.h:33, from src/fd.c:90: src/fd.c: In function 'updt_fd_polling': include/haproxy/fd.h:507:11: warning: array subscript 63 is above array bounds of 'int[1]' [-Warray-bounds] 507 | DISGUISE(write(poller_wr_pipe[tid], &c, 1)); include/haproxy/compiler.h:92:41: note: in definition of macro 'DISGUISE' 92 | #define DISGUISE(v) ({ typeof(v) __v = (v); ALREADY_CHECKED(__v); __v; }) | ^ src/fd.c:113:5: note: while referencing 'poller_wr_pipe' 113 | int poller_wr_pipe[MAX_THREADS]; // Pipe to wake the threads | ^~~~~~~~~~~~~~ gcc is wrong but this time it cannot be blamed because it doesn't know that the FD's thread_mask always has at least one bit set. Let's add the test for all_threads_mask there. It will also remove that test and drop the else block. --- src/fd.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/fd.c b/src/fd.c index 79a9ec861..7cb864ec9 100644 --- a/src/fd.c +++ b/src/fd.c @@ -394,10 +394,7 @@ int fd_takeover(int fd, void *expected_owner) void updt_fd_polling(const int fd) { - if ((fdtab[fd].thread_mask & all_threads_mask) == tid_bit) { - - /* note: we don't have a test-and-set yet in hathreads */ - + if (all_threads_mask == 1UL || (fdtab[fd].thread_mask & all_threads_mask) == tid_bit) { if (HA_ATOMIC_BTS(&fdtab[fd].update_mask, tid)) return;