From 17ed347dd1dabc1520464f03117d89dcac7c227f Mon Sep 17 00:00:00 2001 From: Brandon L Black Date: Thu, 4 Jan 2024 08:34:52 -0600 Subject: [PATCH] dnsio_tcp: minor refactoring on listen() This is just to satisfy the gcc-13 analyzer, which otherwise indicates an FD leak here. I'm guessing it can't correctly parse listen() on a sockfd accessed from a pointer to a struct? No functional change whatsoever. --- src/dnsio_tcp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dnsio_tcp.c b/src/dnsio_tcp.c index cd81b9ec..0f981ebb 100644 --- a/src/dnsio_tcp.c +++ b/src/dnsio_tcp.c @@ -1028,10 +1028,11 @@ void* dnsio_tcp_start(void* thread_asvoid) thread_t thr = { 0 }; const int backlog = (int)(addrconf->tcp_backlog ? addrconf->tcp_backlog : SOMAXCONN); - if (listen(t->sock, backlog) == -1) + const int lsock = t->sock; // copied out here just for gcc analyzer's sake + if (listen(lsock, backlog) == -1) log_fatal("Failed to listen(s, %i) on TCP socket %s: %s", backlog, logf_anysin(&addrconf->addr), logf_errno()); - set_accf(addrconf, t->sock); + set_accf(addrconf, lsock); pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); @@ -1056,7 +1057,7 @@ void* dnsio_tcp_start(void* thread_asvoid) idle_watcher->data = &thr; ev_io* accept_watcher = &thr.accept_watcher; - ev_io_init(accept_watcher, accept_handler, t->sock, EV_READ); + ev_io_init(accept_watcher, accept_handler, lsock, EV_READ); ev_set_priority(accept_watcher, -1); accept_watcher->data = &thr;