diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-05-01 08:44:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-01 08:44:11 +0200 |
commit | 9834b690aea8ecd6fb079a772df5664ff1bae618 (patch) | |
tree | 4378dedf717e6f045caaa7abf748486e3af4d300 /drivers/unix/stream_peer_tcp_posix.cpp | |
parent | 4cce6f34170d693be994d9a451b4b5f96a084cfb (diff) | |
parent | 03bf783f3ce9d2a865bc509035dd883ffe0baa0c (diff) |
Merge pull request #18334 from Faless/coverity_net
Various coverity scan fixes, WS FreeBSD fixes
Diffstat (limited to 'drivers/unix/stream_peer_tcp_posix.cpp')
-rw-r--r-- | drivers/unix/stream_peer_tcp_posix.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/drivers/unix/stream_peer_tcp_posix.cpp b/drivers/unix/stream_peer_tcp_posix.cpp index 17112e5ab5..6d798f32f9 100644 --- a/drivers/unix/stream_peer_tcp_posix.cpp +++ b/drivers/unix/stream_peer_tcp_posix.cpp @@ -124,11 +124,14 @@ void StreamPeerTCPPosix::set_socket(int p_sockfd, IP_Address p_host, int p_port, sock_type = p_sock_type; sockfd = p_sockfd; #ifndef NO_FCNTL - fcntl(sockfd, F_SETFL, O_NONBLOCK); + if (fcntl(sockfd, F_SETFL, O_NONBLOCK) < 0) { + WARN_PRINT("Error setting socket as non blocking"); + } #else int bval = 1; - ioctl(sockfd, FIONBIO, &bval); - + if (ioctl(sockfd, FIONBIO, &bval) < 0) { + WARN_PRINT("Error setting socket as non blocking"); + } #endif status = STATUS_CONNECTING; @@ -150,10 +153,14 @@ Error StreamPeerTCPPosix::connect_to_host(const IP_Address &p_host, uint16_t p_p }; #ifndef NO_FCNTL - fcntl(sockfd, F_SETFL, O_NONBLOCK); + if (fcntl(sockfd, F_SETFL, O_NONBLOCK) < 0) { + WARN_PRINT("Error setting socket as non blocking"); + } #else int bval = 1; - ioctl(sockfd, FIONBIO, &bval); + if (ioctl(sockfd, FIONBIO, &bval) < 0) { + WARN_PRINT("Error setting socket as non blocking"); + } #endif struct sockaddr_storage their_addr; @@ -308,7 +315,9 @@ void StreamPeerTCPPosix::set_no_delay(bool p_enabled) { ERR_FAIL_COND(!is_connected_to_host()); int flag = p_enabled ? 1 : 0; - setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int)); + if (setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int)) < 0) { + ERR_PRINT("Unable to set TCP no delay option"); + } } bool StreamPeerTCPPosix::is_connected_to_host() const { |