diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-09-22 09:24:56 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-09-22 09:24:56 -0400 |
commit | 0baa276ea9673ba1c7efce009d30a4afb4f63a6a (patch) | |
tree | 7af46f43b15428985566541d123f6bbfd770be18 /src/test | |
parent | 6deeedb5e09fc0998ab5d4e2fc53415bc6dc5c39 (diff) | |
download | tor-0baa276ea9673ba1c7efce009d30a4afb4f63a6a.tar.gz tor-0baa276ea9673ba1c7efce009d30a4afb4f63a6a.zip |
Coverity warning fix: let coverity tell we're closing sockets
Our use of the (mockable) tor_close_socket() in the util/socket_..
tests confused coverity, which could no longer tell that we were
actually closing the sockets.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_util.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index 1edfaa9ead..d2152dd698 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -5074,24 +5074,28 @@ test_util_socket(void *arg) tt_int_op(fd_is_nonblocking(fd4), OP_EQ, 1); #endif - tor_close_socket(fd1); - tor_close_socket(fd2); + tor_assert(tor_close_socket == tor_close_socket__real); + + /* we use close_socket__real here so that coverity can tell that we are + * really closing these sockets. */ + tor_close_socket__real(fd1); + tor_close_socket__real(fd2); fd1 = fd2 = TOR_INVALID_SOCKET; tt_int_op(get_n_open_sockets(), OP_EQ, n + 2); - tor_close_socket(fd3); - tor_close_socket(fd4); + tor_close_socket__real(fd3); + tor_close_socket__real(fd4); fd3 = fd4 = TOR_INVALID_SOCKET; tt_int_op(get_n_open_sockets(), OP_EQ, n); done: if (SOCKET_OK(fd1)) - tor_close_socket(fd1); + tor_close_socket__real(fd1); if (SOCKET_OK(fd2)) - tor_close_socket(fd2); + tor_close_socket__real(fd2); if (SOCKET_OK(fd3)) - tor_close_socket(fd3); + tor_close_socket__real(fd3); if (SOCKET_OK(fd4)) - tor_close_socket(fd4); + tor_close_socket__real(fd4); } static int |