Merge pull request #43 from michael-loki/warnings_as_errors

Enable warnings as errors
This commit is contained in:
Jeff 2018-11-06 17:57:01 -05:00 committed by GitHub
commit 5ad0e9d4ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 37 additions and 29 deletions

View File

@ -4,9 +4,9 @@ cmake_minimum_required(VERSION 3.7.0)
set(PROJECT_NAME lokinet)
project(${PROJECT_NAME} C CXX ASM)
option(USE_LIBABYSS "enable libabyss" OFF)
option(USE_CXX17 "enable c++17 features" OFF)
option(USE_AVX2 "enable avx2 code" OFF)
option(USE_LIBABYSS "enable libabyss" )
option(USE_CXX17 "enable c++17 features" )
option(USE_AVX2 "enable avx2 code" )
# Require C++11
# or C++17 on win32
if (NOT WIN32)
@ -25,7 +25,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
# turns off those annoying warnings for
# target-specific crypto code paths not
# applicable to the host's FPU -rick
add_compile_options(-Wall)
add_compile_options(-Wall -Werror -Wno-unknown-pragmas)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fpermissive>)
add_compile_options(-Wno-unused-function -Wno-deprecated-declarations -Wno-unknown-pragmas)

View File

@ -31,8 +31,8 @@ TESTNET_CLIENTS ?= 50
TESTNET_SERVERS ?= 50
TESTNET_DEBUG ?= 0
JSONRPC = OFF
CXX17 = ON
JSONRPC ?= OFF
CXX17 ?= ON
BUILD_ROOT = $(REPO)/build

View File

@ -21,7 +21,6 @@
#include <sodium/private/mutex.h>
static volatile int initialized;
static volatile int locked;
int
sodium_init(void)
@ -56,6 +55,7 @@ sodium_init(void)
static CRITICAL_SECTION _sodium_lock;
static volatile LONG _sodium_lock_initialized;
static volatile int locked;
int
_sodium_crit_init(void)
@ -113,6 +113,7 @@ sodium_crit_leave(void)
#elif defined(HAVE_PTHREAD) && !defined(__EMSCRIPTEN__)
static pthread_mutex_t _sodium_lock = PTHREAD_MUTEX_INITIALIZER;
static volatile int locked;
int
sodium_crit_enter(void)

View File

@ -7,4 +7,4 @@ WORKDIR /src/
COPY . /src/
RUN make -j 8 JSONRPC=ON
RUN make -j 8 JSONRPC=ON CXX17=OFF

View File

@ -29,7 +29,7 @@ namespace abyss
HandleJSONRPC(Method_t method, const Params& params,
Response& response) = 0;
~IRPCHandler();
virtual ~IRPCHandler();
bool
ShouldClose(llarp_time_t now) const;

View File

@ -154,10 +154,6 @@ enum {
ST_NUM_STATES, // used for bounds checking
};
static const cstr flagnames[] = {
"ST_DATA","ST_FIN","ST_STATE","ST_RESET","ST_SYN"
};
enum CONN_STATE {
CS_UNINITIALIZED = 0,
CS_IDLE,
@ -169,10 +165,17 @@ enum CONN_STATE {
CS_DESTROY
};
#if UTP_DEBUG_LOGGING
static const cstr flagnames[] = {
"ST_DATA","ST_FIN","ST_STATE","ST_RESET","ST_SYN"
};
static const cstr statenames[] = {
"UNINITIALIZED", "IDLE","SYN_SENT", "SYN_RECV", "CONNECTED","CONNECTED_FULL","DESTROY_DELAY","RESET","DESTROY"
};
#endif
struct OutgoingPacket {
size_t length;
size_t payload;
@ -1178,7 +1181,7 @@ void UTPSocket::check_timeouts()
// Increase RTO
const uint new_timeout = ignore_loss ? retransmit_timeout : retransmit_timeout * 2;
// They initiated the connection but failed to respond before the rto.
// They initiated the connection but failed to respond before the rto.
// A malicious client can also spoof the destination address of a ST_SYN bringing us to this state.
// Kill the connection and do not notify the upper layer
if (state == CS_SYN_RECV) {
@ -1797,7 +1800,7 @@ size_t utp_process_incoming(UTPSocket *conn, const byte *packet, size_t len, boo
// or a malicious attempt to attach the uTP implementation.
// acking a packet that hasn't been sent yet!
// SYN packets have an exception, since there are no previous packets
if ((pk_flags != ST_SYN || conn->state != CS_SYN_RECV) &&
if ((pk_flags != ST_SYN || conn->state != CS_SYN_RECV) &&
(wrapping_compare_less(conn->seq_nr - 1, pk_ack_nr, ACK_NR_MASK)
|| wrapping_compare_less(pk_ack_nr, conn->seq_nr - 1 - curr_window, ACK_NR_MASK))) {
#if UTP_DEBUG_LOGGING
@ -1966,7 +1969,7 @@ size_t utp_process_incoming(UTPSocket *conn, const byte *packet, size_t len, boo
if (pkt == 0 || pkt->transmissions == 0) continue;
assert((int)(pkt->payload) >= 0);
acked_bytes += pkt->payload;
if (conn->mtu_probe_seq && seq == conn->mtu_probe_seq) {
if (conn->mtu_probe_seq && seq == static_cast< int >(conn->mtu_probe_seq)) {
conn->mtu_floor = conn->mtu_probe_size;
conn->mtu_search_update();
conn->log(UTP_LOG_MTU, "MTU [ACK] floor:%d ceiling:%d current:%d"
@ -2163,7 +2166,7 @@ size_t utp_process_incoming(UTPSocket *conn, const byte *packet, size_t len, boo
// Outgoing connection completion
if (pk_flags == ST_STATE && conn->state == CS_SYN_SENT) {
conn->state = CS_CONNECTED;
// If the user has defined the ON_CONNECT callback, use that to
// notify the user that the socket is now connected. If ON_CONNECT
// has not been defined, notify the user via ON_STATE_CHANGE.
@ -2173,7 +2176,7 @@ size_t utp_process_incoming(UTPSocket *conn, const byte *packet, size_t len, boo
utp_call_on_state_change(conn->ctx, conn, UTP_STATE_CONNECT);
// We've sent a fin, and everything was ACKed (including the FIN).
// cur_window_packets == acks means that this packet acked all
// cur_window_packets == acks means that this packet acked all
// the remaining packets that were in-flight.
} else if (conn->fin_sent && conn->cur_window_packets == acks) {
conn->fin_sent_acked = true;
@ -3075,7 +3078,7 @@ static UTPSocket* parse_icmp_payload(utp_context *ctx, const byte *buffer, size_
// @len: buffer length
// @to: destination address of the original UDP pakcet
// @tolen: address length
// @next_hop_mtu:
// @next_hop_mtu:
int utp_process_icmp_fragmentation(utp_context *ctx, const byte* buffer, size_t len, const struct sockaddr *to, socklen_t tolen, uint16 next_hop_mtu)
{
UTPSocket* conn = parse_icmp_payload(ctx, buffer, len, to, tolen);

View File

@ -1,6 +1,9 @@
#include <llarp/ev.h>
#include <llarp/logic.h>
#include <llarp/string_view.hpp>
#include <stddef.h>
#include "mem.hpp"
#define EV_TICK_INTERVAL 100
@ -166,7 +169,7 @@ llarp_tcp_async_try_connect(struct llarp_ev_loop *loop,
return;
}
const char *end = ptr;
while(*end && (end - begin) < sizeof(tcp->remote))
while(*end && ((end - begin) < static_cast<ptrdiff_t>(sizeof tcp->remote)))
{
++end;
}
@ -242,4 +245,4 @@ namespace llarp
return true;
}
} // namespace llarp
} // namespace llarp

View File

@ -135,9 +135,9 @@ namespace llarp
socklen_t slen = sizeof(sockaddr_in6);
sockaddr* addr = (sockaddr*)&src;
ssize_t ret = ::recvfrom(fd, buf, sz, 0, addr, &slen);
if(ret == -1)
if(ret < 0)
return -1;
if(ret > sz)
if(static_cast< size_t >(ret) > sz)
return -1;
udp->recvfrom(udp, addr, buf, ret);
return 0;

View File

@ -467,7 +467,7 @@ namespace llarp
{
// called in the isolated network thread
TunEndpoint *self = static_cast< TunEndpoint * >(tun->user);
self->m_NetworkToUserPktQueue.Process([self, tun](net::IPv4Packet &pkt) {
self->m_NetworkToUserPktQueue.Process([tun](net::IPv4Packet &pkt) {
if(!llarp_ev_tun_async_write(tun, pkt.buf, pkt.sz))
llarp::LogWarn("packet dropped");
});
@ -489,7 +489,7 @@ namespace llarp
TunEndpoint *self = static_cast< TunEndpoint * >(tun->user);
llarp::LogDebug("got pkt ", sz, " bytes");
if(!self->m_UserToNetworkPktQueue.EmplaceIf(
[self, buf, sz](net::IPv4Packet &pkt) -> bool {
[buf, sz](net::IPv4Packet &pkt) -> bool {
return pkt.Load(llarp::InitBuffer(buf, sz))
&& pkt.Header()->version == 4;
}))

View File

@ -125,7 +125,7 @@ namespace llarp
llarp::LogDebug("utp_writev wrote=", s, " expect=", expect,
" to=", remoteAddr);
while(s > vecq.front().iov_len)
while(s > static_cast< ssize_t >(vecq.front().iov_len))
{
s -= vecq.front().iov_len;
vecq.pop_front();

View File

@ -494,7 +494,7 @@ llarp_router::Tick()
if(inboundLinks.size() == 0)
{
auto N = llarp_nodedb_num_loaded(nodedb);
size_t N = llarp_nodedb_num_loaded(nodedb);
if(N < minRequiredRouters)
{
llarp::LogInfo("We need at least ", minRequiredRouters,

View File

@ -82,7 +82,7 @@ struct llarp_router
/// hard upperbound limit on the number of router to router connections
size_t maxConnectedRouters = 2000;
int minRequiredRouters = 4;
size_t minRequiredRouters = 4;
// should we be sending padded messages every interval?
bool sendPadding = false;

View File

@ -184,7 +184,8 @@ TEST_F(AbyssTest, TestClientAndServer)
params.SetObject();
QueueRPC(method, std::move(params),
std::bind(&AbyssTest::NewConn, this, std::placeholders::_1));
AsyncFlush();
RunLoop();
ASSERT_TRUE(called);
};
};