]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: epoll/threads: Add test on MAX_THREADS to avoid warnings when complied without...
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 25 Jan 2018 15:18:09 +0000 (16:18 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 25 Jan 2018 16:52:57 +0000 (17:52 +0100)
When HAProxy is complied without threads, gcc throws following warnings:

  src/ev_epoll.c:222:3: warning: array subscript is outside array bounds [-Warray-bounds]
  ...
  src/ev_epoll.c:199:11: warning: array subscript is outside array bounds [-Warray-bounds]
  ...

Of course, this is not a bug. In such case, tid is always equal to 0. But to
avoid the noise, a check on MAX_THREADS in "if (tid)" lines makes gcc happy.

This patch should be backported in 1.8 with the commit d9e7e36c ("BUG/MEDIUM:
epoll/threads: use one epoll_fd per thread").

src/ev_epoll.c

index 635b8a5fe51e98b165048b33b2d1789910e50fd4..e5c0001c95e68637cc87f8b8c066f2d55f72030b 100644 (file)
@@ -195,7 +195,7 @@ static int init_epoll_per_thread()
        if (epoll_events == NULL)
                goto fail_alloc;
 
-       if (tid) {
+       if (MAX_THREADS > 1 && tid) {
                epoll_fd[tid] = epoll_create(global.maxsock + 1);
                if (epoll_fd[tid] < 0)
                        goto fail_fd;
@@ -218,7 +218,7 @@ static int init_epoll_per_thread()
 
 static void deinit_epoll_per_thread()
 {
-       if (tid)
+       if (MAX_THREADS > 1 && tid)
                close(epoll_fd[tid]);
 
        free(epoll_events);