diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 311f45470328f4..e1e356406153e7 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -157,6 +157,7 @@ config("strict_warnings") { "-Wall", "-Wextra", "-Wshadow", + "-Wunreachable-code", ] cflags_cc = [ "-Wnon-virtual-dtor" ] diff --git a/src/app/server/Mdns.cpp b/src/app/server/Mdns.cpp index 24ac44190ba1d1..874d5c9b6331e6 100644 --- a/src/app/server/Mdns.cpp +++ b/src/app/server/Mdns.cpp @@ -51,7 +51,8 @@ NodeId GetCurrentNodeId() // mdns advertises a single node id as parameter. // Search for one admin pariing and use its node id. - for (auto pairing = GetGlobalAdminPairingTable().cbegin(); pairing != GetGlobalAdminPairingTable().cend(); pairing++) + auto pairing = GetGlobalAdminPairingTable().cbegin(); + if (pairing != GetGlobalAdminPairingTable().cend()) { ChipLogProgress(Discovery, "Found admin paring for admin %" PRIX64 ", node %" PRIX64, pairing->GetAdminId(), pairing->GetNodeId()); diff --git a/src/app/util/util.cpp b/src/app/util/util.cpp index d0b37837540240..6447fec604cd60 100644 --- a/src/app/util/util.cpp +++ b/src/app/util/util.cpp @@ -315,7 +315,7 @@ void emberAfStackDown(void) // (Issue 77101) Also don't clear the table if the stack has gone down as a // a result of losing its parent or some other transient state where a future // rejoin is expected to get us back online. - if (false + if ((false) // emberStackIsPerformingRejoin() == false // && emberNetworkState() == EMBER_NO_NETWORK ) diff --git a/src/controller/java/CHIPDeviceController-JNI.cpp b/src/controller/java/CHIPDeviceController-JNI.cpp index 159c90251f18a7..c2457a5b793262 100644 --- a/src/controller/java/CHIPDeviceController-JNI.cpp +++ b/src/controller/java/CHIPDeviceController-JNI.cpp @@ -28,6 +28,7 @@ #include "AndroidDeviceControllerWrapper.h" #include +#include #include #include #include @@ -1048,13 +1049,16 @@ void * IOThreadMain(void * arg) sJVM->AttachCurrentThreadAsDaemon((void **) &env, (void *) &attachArgs); #endif + // Set to true to quit the loop. This is currently unused. + std::atomic quit; + ChipLogProgress(Controller, "IO thread starting"); // Lock the stack to prevent collisions with Java threads. pthread_mutex_lock(&sStackLock); // Loop until we are told to exit. - while (true) + while (!quit.load(std::memory_order_relaxed)) { numFDs = 0; FD_ZERO(&readFDs); diff --git a/src/system/tests/TestSystemObject.cpp b/src/system/tests/TestSystemObject.cpp index 2bac3901431478..29079f2881525a 100644 --- a/src/system/tests/TestSystemObject.cpp +++ b/src/system/tests/TestSystemObject.cpp @@ -87,12 +87,9 @@ class TestObject : public Object #if CHIP_SYSTEM_CONFIG_POSIX_LOCKING unsigned int mDelay; - enum - { - kNumThreads = 16, - kLoopIterations = 100000, - kMaxDelayIterations = 3 - }; + static constexpr int kNumThreads = 16; + static constexpr int kLoopIterations = 100000; + static constexpr int kMaxDelayIterations = 3; void Delay(volatile unsigned int & aAccumulator); static void * CheckConcurrencyThread(void * aContext); diff --git a/src/transport/AdminPairingTable.cpp b/src/transport/AdminPairingTable.cpp index 394bb8cf268d5a..50fefd0afd640d 100644 --- a/src/transport/AdminPairingTable.cpp +++ b/src/transport/AdminPairingTable.cpp @@ -133,7 +133,7 @@ void AdminPairingTable::Reset() { for (size_t i = 0; i < CHIP_CONFIG_MAX_DEVICE_ADMINS; i++) { - return mStates[i].Reset(); + mStates[i].Reset(); } }