diff --git a/CMakeLists.txt b/CMakeLists.txt index ae2a2c8..5ebdd6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,9 +7,11 @@ set(UDPC_SOURCES src/UDPConnection.cpp ) -set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -Wno-missing-braces") -set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") -set(CMAKE_CXX_FLAGS_RELEASE "-O3 -D NDEBUG") +add_compile_options( + -Wall -Wextra -Wpedantic -Wno-missing-braces + $<$:-Weffc++> + $<$:-O0> +) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Setting build type to 'Debug', none was specified.") diff --git a/src/TSLQueue.hpp b/src/TSLQueue.hpp index 8526cb9..d2c27f8 100644 --- a/src/TSLQueue.hpp +++ b/src/TSLQueue.hpp @@ -67,6 +67,10 @@ class TSLQueue { unsigned long *msize); ~TSLQIter(); + // Disallow copy. + TSLQIter(const TSLQIter &) = delete; + TSLQIter& operator=(const TSLQIter &) = delete; + std::unique_ptr current(); bool next(); bool prev(); @@ -91,6 +95,7 @@ class TSLQueue { template TSLQueue::TSLQueue() : + mutex(), head(std::shared_ptr(new TSLQNode())), tail(std::shared_ptr(new TSLQNode())), msize(0) @@ -296,6 +301,9 @@ unsigned long TSLQueue::size() { template TSLQueue::TSLQNode::TSLQNode() : +next(), +prev(), +data(), type(TSLQN_Type::TSLQN_NORMAL) {} diff --git a/src/UDPConnection.cpp b/src/UDPConnection.cpp index 7336949..fca2cf9 100644 --- a/src/UDPConnection.cpp +++ b/src/UDPConnection.cpp @@ -94,13 +94,16 @@ toggleT(UDPC::THIRTY_SECONDS), toggleTimer(std::chrono::steady_clock::duration::zero()), toggledTimer(std::chrono::steady_clock::duration::zero()), addr({0}), +scope_id(0), port(0), sentPkts(), sendPkts(), priorityPkts(), +sentInfoMap(), received(std::chrono::steady_clock::now()), sent(std::chrono::steady_clock::now()), -rtt(std::chrono::steady_clock::duration::zero()) +rtt(std::chrono::steady_clock::duration::zero()), +verifyMessage() { flags.set(0); flags.reset(1); @@ -149,9 +152,11 @@ port(port), sentPkts(), sendPkts(), priorityPkts(), +sentInfoMap(), received(std::chrono::steady_clock::now()), sent(std::chrono::steady_clock::now()), -rtt(std::chrono::steady_clock::duration::zero()) +rtt(std::chrono::steady_clock::duration::zero()), +verifyMessage() { flags.set(3); if(isServer) { @@ -223,11 +228,34 @@ loggingType(UDPC_DEBUG), #else loggingType(UDPC_WARNING), #endif +authPolicy(UDPC_AUTH_POLICY_FALLBACK), +#if UDPC_PLATFORM == UPDC_PLATFORM_WINDOWS +socketHandle(INVALID_SOCKET), +#else +socketHandle(0), +#endif +socketInfo(), +lastUpdated(), +conMap(), +addrConMap(), +idMap(), +deletionMap(), +peerPKWhitelist(), receivedPkts(), +receivedPktsMutex(), cSendPkts(), +internalEvents(), +internalEventsMutex(), +externalEvents(), +externalEventsMutex(), rng_engine(), +thread(), +threadRunning(), conMapMutex(), peerPKWhitelistMutex(), +threadedSleepTime(std::chrono::milliseconds(UDPC_UPDATE_MS_DEFAULT)), +keysSet(), +atostrBufIndexMutex(), atostrBufIndex(0) { std::memset(atostrBuf, 0, UDPC_ATOSTR_SIZE); diff --git a/src/test/UDPC_NetworkTest.c b/src/test/UDPC_NetworkTest.c index 197ea2e..626d44a 100644 --- a/src/test/UDPC_NetworkTest.c +++ b/src/test/UDPC_NetworkTest.c @@ -312,7 +312,7 @@ int main(int argc, char **argv) { if(isLibSodiumEnabled && whitelist_pk_files_index > 0) { puts("Enabling pubkey whitelist..."); for(unsigned int i = 0; i < whitelist_pk_files_index; ++i) { - if(UDPC_add_whitelist_pk(context, whitelist_pks[i]) != i + 1) { + if((unsigned int)UDPC_add_whitelist_pk(context, whitelist_pks[i]) != i + 1) { puts("Failed to add pubkey to whitelist"); return 1; } @@ -323,7 +323,7 @@ int main(int argc, char **argv) { unsigned int tick = 0; unsigned int temp = 0; - unsigned int temp2, temp3; + unsigned int temp2; int temp4; unsigned long size; UDPC_ConnectionId *list = NULL;