From: Aram Sargsyan Date: Wed, 12 Oct 2022 08:21:35 +0000 (+0000) Subject: Remove a superfluous check of sock->fd against -1 X-Git-Tag: v9.19.7~72^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be95ba0119dcd42cbe81ec2776a17b13d2ab947a;p=thirdparty%2Fbind9.git Remove a superfluous check of sock->fd against -1 The check is left from when tcp_connect_direct() called isc__nm_socket() and it was uncertain whether it had succeeded, but now isc__nm_socket() is called before tcp_connect_direct(), so sock->fd cannot be -1. *** CID 357292: (REVERSE_NEGATIVE) /lib/isc/netmgr/tcp.c: 309 in isc_nm_tcpconnect() 303 304 atomic_store(&sock->active, true); 305 306 result = tcp_connect_direct(sock, req); 307 if (result != ISC_R_SUCCESS) { 308 atomic_store(&sock->active, false); >>> CID 357292: (REVERSE_NEGATIVE) >>> You might be using variable "sock->fd" before verifying that it is >= 0. 309 if (sock->fd != (uv_os_sock_t)(-1)) { 310 isc__nm_tcp_close(sock); 311 } 312 isc__nm_connectcb(sock, req, result, true); 313 } 314 --- diff --git a/lib/isc/netmgr/tcp.c b/lib/isc/netmgr/tcp.c index 052ec47d79c..9525b23f2b3 100644 --- a/lib/isc/netmgr/tcp.c +++ b/lib/isc/netmgr/tcp.c @@ -306,9 +306,7 @@ isc_nm_tcpconnect(isc_nm_t *mgr, isc_sockaddr_t *local, isc_sockaddr_t *peer, result = tcp_connect_direct(sock, req); if (result != ISC_R_SUCCESS) { atomic_store(&sock->active, false); - if (sock->fd != (uv_os_sock_t)(-1)) { - isc__nm_tcp_close(sock); - } + isc__nm_tcp_close(sock); isc__nm_connectcb(sock, req, result, true); }