Fix CMakeLists.txt, handle -Weffc++ warnings

This commit is contained in:
Stephen Seo 2023-07-22 13:25:43 +09:00
parent 56465c280c
commit 64a0995e21
4 changed files with 45 additions and 7 deletions

View file

@ -7,9 +7,11 @@ set(UDPC_SOURCES
src/UDPConnection.cpp src/UDPConnection.cpp
) )
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -Wno-missing-braces") add_compile_options(
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") -Wall -Wextra -Wpedantic -Wno-missing-braces
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -D NDEBUG") $<$<COMPILE_LANGUAGE:CXX>:-Weffc++>
$<$<CONFIG:DEBUG>:-O0>
)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Debug', none was specified.") message(STATUS "Setting build type to 'Debug', none was specified.")

View file

@ -67,6 +67,10 @@ class TSLQueue {
unsigned long *msize); unsigned long *msize);
~TSLQIter(); ~TSLQIter();
// Disallow copy.
TSLQIter(const TSLQIter &) = delete;
TSLQIter& operator=(const TSLQIter &) = delete;
std::unique_ptr<T> current(); std::unique_ptr<T> current();
bool next(); bool next();
bool prev(); bool prev();
@ -91,6 +95,7 @@ class TSLQueue {
template <typename T> template <typename T>
TSLQueue<T>::TSLQueue() : TSLQueue<T>::TSLQueue() :
mutex(),
head(std::shared_ptr<TSLQNode>(new TSLQNode())), head(std::shared_ptr<TSLQNode>(new TSLQNode())),
tail(std::shared_ptr<TSLQNode>(new TSLQNode())), tail(std::shared_ptr<TSLQNode>(new TSLQNode())),
msize(0) msize(0)
@ -296,6 +301,9 @@ unsigned long TSLQueue<T>::size() {
template <typename T> template <typename T>
TSLQueue<T>::TSLQNode::TSLQNode() : TSLQueue<T>::TSLQNode::TSLQNode() :
next(),
prev(),
data(),
type(TSLQN_Type::TSLQN_NORMAL) type(TSLQN_Type::TSLQN_NORMAL)
{} {}

View file

@ -94,13 +94,16 @@ toggleT(UDPC::THIRTY_SECONDS),
toggleTimer(std::chrono::steady_clock::duration::zero()), toggleTimer(std::chrono::steady_clock::duration::zero()),
toggledTimer(std::chrono::steady_clock::duration::zero()), toggledTimer(std::chrono::steady_clock::duration::zero()),
addr({0}), addr({0}),
scope_id(0),
port(0), port(0),
sentPkts(), sentPkts(),
sendPkts(), sendPkts(),
priorityPkts(), priorityPkts(),
sentInfoMap(),
received(std::chrono::steady_clock::now()), received(std::chrono::steady_clock::now()),
sent(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.set(0);
flags.reset(1); flags.reset(1);
@ -149,9 +152,11 @@ port(port),
sentPkts(), sentPkts(),
sendPkts(), sendPkts(),
priorityPkts(), priorityPkts(),
sentInfoMap(),
received(std::chrono::steady_clock::now()), received(std::chrono::steady_clock::now()),
sent(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); flags.set(3);
if(isServer) { if(isServer) {
@ -223,11 +228,34 @@ loggingType(UDPC_DEBUG),
#else #else
loggingType(UDPC_WARNING), loggingType(UDPC_WARNING),
#endif #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(), receivedPkts(),
receivedPktsMutex(),
cSendPkts(), cSendPkts(),
internalEvents(),
internalEventsMutex(),
externalEvents(),
externalEventsMutex(),
rng_engine(), rng_engine(),
thread(),
threadRunning(),
conMapMutex(), conMapMutex(),
peerPKWhitelistMutex(), peerPKWhitelistMutex(),
threadedSleepTime(std::chrono::milliseconds(UDPC_UPDATE_MS_DEFAULT)),
keysSet(),
atostrBufIndexMutex(),
atostrBufIndex(0) atostrBufIndex(0)
{ {
std::memset(atostrBuf, 0, UDPC_ATOSTR_SIZE); std::memset(atostrBuf, 0, UDPC_ATOSTR_SIZE);

View file

@ -312,7 +312,7 @@ int main(int argc, char **argv) {
if(isLibSodiumEnabled && whitelist_pk_files_index > 0) { if(isLibSodiumEnabled && whitelist_pk_files_index > 0) {
puts("Enabling pubkey whitelist..."); puts("Enabling pubkey whitelist...");
for(unsigned int i = 0; i < whitelist_pk_files_index; ++i) { 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"); puts("Failed to add pubkey to whitelist");
return 1; return 1;
} }
@ -323,7 +323,7 @@ int main(int argc, char **argv) {
unsigned int tick = 0; unsigned int tick = 0;
unsigned int temp = 0; unsigned int temp = 0;
unsigned int temp2, temp3; unsigned int temp2;
int temp4; int temp4;
unsigned long size; unsigned long size;
UDPC_ConnectionId *list = NULL; UDPC_ConnectionId *list = NULL;