]> git.seodisparate.com - UDPConnection/commitdiff
Fix CMakeLists.txt, handle -Weffc++ warnings
authorStephen Seo <seo.disparate@gmail.com>
Sat, 22 Jul 2023 04:25:43 +0000 (13:25 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Sat, 22 Jul 2023 04:25:43 +0000 (13:25 +0900)
CMakeLists.txt
src/TSLQueue.hpp
src/UDPConnection.cpp
src/test/UDPC_NetworkTest.c

index ae2a2c82a8a96446d8a08a2e6e1555fdad30da3a..5ebdd6f6c2babcfd9ee8a31b25e8f5520043dec8 100644 (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.")
index 8526cb91eade662df219f640d9b761ef8da955d8..d2c27f8b13efae996f6862b6643450e9667d8f62 100644 (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)
 {}
 
index 7336949272b516d410cd9465e361d74207f518d8..fca2cf96f0317b1b9ddfdc00d9e17d4a583f9178 100644 (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);
index 197ea2e881a7dea48be47eb7fa24b335c6b4c61a..626d44a8cb3823c9dc6b316d701319ece001f679 100644 (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;