Fixed compile warnings and a memory leak
Fixed -fPIC warnings and unused function warnings on GCC. Fixed fr::TcpSocket not calling freeaddrinfo() on failure to connect, causing a small leak.
This commit is contained in:
parent
8bef6df130
commit
b574800a0a
@ -45,7 +45,7 @@ if(USE_SSL)
|
||||
endif()
|
||||
|
||||
if(NOT MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++14 -pthread")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pthread")
|
||||
endif()
|
||||
|
||||
# Set the library output directory
|
||||
|
||||
@ -21,7 +21,10 @@
|
||||
#include <ws2tcpip.h>
|
||||
#define SOL_TCP SOL_SOCKET
|
||||
#define SHUT_RDWR SD_BOTH
|
||||
#define UNUSED_VAR
|
||||
#else
|
||||
|
||||
#define UNUSED_VAR __attribute__ ((unused))
|
||||
#define closesocket(x) close(x)
|
||||
#define INVALID_SOCKET 0
|
||||
#define SOCKET_ERROR (-1)
|
||||
@ -95,7 +98,7 @@ inline void set_unix_socket_blocking(int32_t socket_descriptor, bool is_blocking
|
||||
#endif
|
||||
}
|
||||
|
||||
static void init_wsa()
|
||||
static UNUSED_VAR void init_wsa()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
static WSADATA wsaData = WSAData();
|
||||
|
||||
@ -20,8 +20,8 @@ namespace fr
|
||||
{
|
||||
public:
|
||||
Packet() noexcept
|
||||
: buffer_read_index(PACKET_HEADER_LENGTH),
|
||||
buffer(PACKET_HEADER_LENGTH, '0')
|
||||
: buffer(PACKET_HEADER_LENGTH, '0'),
|
||||
buffer_read_index(PACKET_HEADER_LENGTH)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@ -117,12 +117,12 @@ namespace fr
|
||||
break;
|
||||
}
|
||||
|
||||
if(c == nullptr)
|
||||
return Socket::Status::Error;
|
||||
|
||||
//We're done with this now, cleanup
|
||||
freeaddrinfo(info);
|
||||
|
||||
if(c == nullptr)
|
||||
return Socket::Status::Error;
|
||||
|
||||
//Update state now we've got a valid socket descriptor
|
||||
remote_address = address + ":" + port;
|
||||
reconfigure_socket();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user