diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-01-17 16:35:07 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-01-17 16:35:07 -0500 |
commit | 6e8c2a3e46e3578b0268d422b1753995d18fb734 (patch) | |
tree | 0f2952090d871b437021d2f6c6059e78234fa0f5 /src/common/compat.c | |
parent | 1e923dd2fbdc0834b8fb3ba97b658f15a6d5f6b4 (diff) | |
download | tor-6e8c2a3e46e3578b0268d422b1753995d18fb734.tar.gz tor-6e8c2a3e46e3578b0268d422b1753995d18fb734.zip |
Use SOCKET_OK macros in even more places
Add a TOR_INVALID_SOCKET macro to wrap -1/INVALID_SOCKET.
Partial work for bug4533.
Diffstat (limited to 'src/common/compat.c')
-rw-r--r-- | src/common/compat.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index 3af43e80c9..7f8903733b 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -1053,17 +1053,17 @@ tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2]) r = socketpair(family, type, protocol, fd); if (r == 0) { #if !defined(SOCK_CLOEXEC) && defined(FD_CLOEXEC) - if (fd[0] >= 0) + if (SOCKET_OK(fd[0])) fcntl(fd[0], F_SETFD, FD_CLOEXEC); - if (fd[1] >= 0) + if (SOCKET_OK(fd[1])) fcntl(fd[1], F_SETFD, FD_CLOEXEC); #endif socket_accounting_lock(); - if (fd[0] >= 0) { + if (SOCKET_OK(fd[0])) { ++n_sockets_open; mark_socket_open(fd[0]); } - if (fd[1] >= 0) { + if (SOCKET_OK(fd[1])) { ++n_sockets_open; mark_socket_open(fd[1]); } @@ -1100,7 +1100,7 @@ tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2]) } listener = tor_open_socket(AF_INET, type, 0); - if (listener < 0) + if (!SOCKET_OK(listener)) return -tor_socket_errno(-1); memset(&listen_addr, 0, sizeof(listen_addr)); listen_addr.sin_family = AF_INET; @@ -1113,7 +1113,7 @@ tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2]) goto tidy_up_and_fail; connector = tor_open_socket(AF_INET, type, 0); - if (connector < 0) + if (!SOCKET_OK(connector)) goto tidy_up_and_fail; /* We want to find out the port number to connect to. */ size = sizeof(connect_addr); @@ -1128,7 +1128,7 @@ tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2]) size = sizeof(listen_addr); acceptor = tor_accept_socket(listener, (struct sockaddr *) &listen_addr, &size); - if (acceptor < 0) + if (!SOCKET_OK(acceptor)) goto tidy_up_and_fail; if (size != sizeof(listen_addr)) goto abort_tidy_up_and_fail; |