]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove a superfluous check of sock->fd against -1
authorAram Sargsyan <aram@isc.org>
Wed, 12 Oct 2022 08:21:35 +0000 (08:21 +0000)
committerAram Sargsyan <aram@isc.org>
Wed, 12 Oct 2022 08:21:35 +0000 (08:21 +0000)
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

lib/isc/netmgr/tcp.c

index 052ec47d79cfaedd07450fec0c01bbf31e4195f7..9525b23f2b30e8e8afa5ebd58c5bf0e085a7c3ea 100644 (file)
@@ -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);
        }