peer_connection_server: fix static analysis issues

coverity flags two issues on this:
* no copy constructor (and assignment operator) for things that free in the destructor
* missing return value check on setsockopt

BUG=None

Change-Id: I0671bf5f9bc0ede968f80c3686bf7bbd8eb63e98
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226743
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34547}
This commit is contained in:
Philipp Hancke
2021-07-22 13:51:21 +02:00
committed by WebRTC LUCI CQ
parent cae23d9cc3
commit c91c2f5bc5
2 changed files with 8 additions and 2 deletions

View File

@ -269,8 +269,12 @@ bool DataSocket::ParseContentLengthAndType(const char* headers, size_t length) {
bool ListeningSocket::Listen(unsigned short port) {
RTC_DCHECK(valid());
int enabled = 1;
setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR,
reinterpret_cast<const char*>(&enabled), sizeof(enabled));
if (setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR,
reinterpret_cast<const char*>(&enabled),
sizeof(enabled)) != 0) {
printf("setsockopt failed\n");
return false;
}
struct sockaddr_in addr = {0};
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_ANY);

View File

@ -37,6 +37,8 @@ class SocketBase {
public:
SocketBase() : socket_(INVALID_SOCKET) {}
explicit SocketBase(NativeSocket socket) : socket_(socket) {}
SocketBase(SocketBase& other) = delete;
SocketBase& operator=(const SocketBase& other) = delete;
~SocketBase() { Close(); }
NativeSocket socket() const { return socket_; }