Fixes coverity warnings in the udp_transport module.

BUG=Coverity warnings.
TEST=N/A.

Review URL: https://webrtc-codereview.appspot.com/392012

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1696 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrike@webrtc.org 2012-02-15 19:43:51 +00:00
parent 6b9253eb4f
commit 05e0601160
4 changed files with 21 additions and 8 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -52,12 +52,20 @@ UdpSocketPosix::UdpSocketPosix(const WebRtc_Word32 id, UdpSocketManager* mgr,
_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
}
// Non-blocking mode
int iMode = 1;
ioctl(_socket, FIONBIO, &iMode);
// Set socket to nonblocking mode.
int enable_non_blocking = 1;
if(ioctl(_socket, FIONBIO, &enable_non_blocking) == -1)
{
WEBRTC_TRACE(kTraceWarning, kTraceTransport, id,
"Failed to make socket nonblocking");
}
// Enable close on fork for file descriptor so that it will not block until
// forked process terminates.
fcntl(_socket,F_SETFD,FD_CLOEXEC);
if(fcntl(_socket, F_SETFD, FD_CLOEXEC) == -1)
{
WEBRTC_TRACE(kTraceWarning, kTraceTransport, id,
"Failed to set FD_CLOEXEC for socket");
}
}
UdpSocketPosix::~UdpSocketPosix()

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -35,7 +35,9 @@ bool UdpSocketWrapper::_initiated = false;
#define FD_SETSIZE 1024
#endif
UdpSocketWrapper::UdpSocketWrapper() : _deleteEvent(NULL)
UdpSocketWrapper::UdpSocketWrapper()
: _wantsIncoming(false),
_deleteEvent(NULL)
{
}

View File

@ -2555,6 +2555,10 @@ WebRtc_Word32 UdpTransport::LocalHostAddressIPV6(WebRtc_UWord8 n_localIP[16])
struct in6_addr* in6p;
int fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
if (fd == -1)
{
return -1;
}
// RTM_GETADDR is used to fetch the ip address from the kernel interface
// table. Populate the msg structure (req) the size of the message buffer

View File

@ -219,7 +219,6 @@ private:
SocketAddress _localRTCPAddr;
WebRtc_Word32 _tos;
bool _inCallbackMode;
bool _receiving;
bool _useSetSockOpt;
bool _qos;