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
)
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
$<$<COMPILE_LANGUAGE:CXX>:-Weffc++>
$<$<CONFIG:DEBUG>:-O0>
)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Debug', none was specified.")

View file

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

View file

@ -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);

View file

@ -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;