diff --git a/examples/bridge-app/asr/subdevice/SubDeviceManager.cpp b/examples/bridge-app/asr/subdevice/SubDeviceManager.cpp index ab0f2ef3b707a1..9d4eda96e98438 100644 --- a/examples/bridge-app/asr/subdevice/SubDeviceManager.cpp +++ b/examples/bridge-app/asr/subdevice/SubDeviceManager.cpp @@ -91,12 +91,11 @@ CHIP_ERROR RemoveDeviceEndpoint(SubDevice * dev) { if (gSubDevices[index] == dev) { - EndpointId ep = emberAfClearDynamicEndpoint(index); - gSubDevices[index] = NULL; - ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index); // Silence complaints about unused ep when progress logging // disabled. - UNUSED_VAR(ep); + [[maybe_unused]] EndpointId ep = emberAfClearDynamicEndpoint(index); + gSubDevices[index] = NULL; + ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index); return CHIP_NO_ERROR; } } diff --git a/examples/bridge-app/esp32/main/main.cpp b/examples/bridge-app/esp32/main/main.cpp index 27cdb3c5e2dab5..07db2ba94a534f 100644 --- a/examples/bridge-app/esp32/main/main.cpp +++ b/examples/bridge-app/esp32/main/main.cpp @@ -201,12 +201,11 @@ CHIP_ERROR RemoveDeviceEndpoint(Device * dev) { if (gDevices[index] == dev) { - EndpointId ep = emberAfClearDynamicEndpoint(index); - gDevices[index] = NULL; - ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index); // Silence complaints about unused ep when progress logging // disabled. - UNUSED_VAR(ep); + [[maybe_unused]] EndpointId ep = emberAfClearDynamicEndpoint(index); + gDevices[index] = NULL; + ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index); return CHIP_NO_ERROR; } } diff --git a/examples/bridge-app/linux/main.cpp b/examples/bridge-app/linux/main.cpp index 80c8b17b7fbed5..c569e7c06e8b45 100644 --- a/examples/bridge-app/linux/main.cpp +++ b/examples/bridge-app/linux/main.cpp @@ -300,12 +300,11 @@ int RemoveDeviceEndpoint(Device * dev) { // Todo: Update this to schedule the work rather than use this lock DeviceLayer::StackLock lock; - EndpointId ep = emberAfClearDynamicEndpoint(index); - gDevices[index] = nullptr; - ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index); // Silence complaints about unused ep when progress logging // disabled. - UNUSED_VAR(ep); + [[maybe_unused]] EndpointId ep = emberAfClearDynamicEndpoint(index); + gDevices[index] = nullptr; + ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index); return index; } index++; diff --git a/examples/bridge-app/telink/src/AppTask.cpp b/examples/bridge-app/telink/src/AppTask.cpp index d21897bd2d36b6..72a997c91e9511 100644 --- a/examples/bridge-app/telink/src/AppTask.cpp +++ b/examples/bridge-app/telink/src/AppTask.cpp @@ -224,12 +224,11 @@ CHIP_ERROR RemoveDeviceEndpoint(Device * dev) { if (gDevices[index] == dev) { - EndpointId ep = emberAfClearDynamicEndpoint(index); - gDevices[index] = NULL; - ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index); // Silence complaints about unused ep when progress logging // disabled. - UNUSED_VAR(ep); + [[maybe_unused]] EndpointId ep = emberAfClearDynamicEndpoint(index); + gDevices[index] = NULL; + ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index); return CHIP_NO_ERROR; } } diff --git a/examples/chip-tool/commands/common/DeviceScanner.cpp b/examples/chip-tool/commands/common/DeviceScanner.cpp index 29d31c1fc80565..35d74bd06c844f 100644 --- a/examples/chip-tool/commands/common/DeviceScanner.cpp +++ b/examples/chip-tool/commands/common/DeviceScanner.cpp @@ -218,7 +218,7 @@ void DeviceScanner::Log() const auto resultsCount = mDiscoveredResults.size(); VerifyOrReturn(resultsCount > 0, ChipLogProgress(chipTool, "No device discovered.")); - uint16_t index = 0; + [[maybe_unused]] uint16_t index = 0; for (auto & instance : mDiscoveredResults) { ChipLogProgress(chipTool, "Instance Name: %s ", instance.first.c_str()); diff --git a/examples/chip-tool/commands/discover/DiscoverCommissionersCommand.cpp b/examples/chip-tool/commands/discover/DiscoverCommissionersCommand.cpp index 0d1c9a032de02c..57c7574c4ea2e3 100644 --- a/examples/chip-tool/commands/discover/DiscoverCommissionersCommand.cpp +++ b/examples/chip-tool/commands/discover/DiscoverCommissionersCommand.cpp @@ -29,7 +29,7 @@ CHIP_ERROR DiscoverCommissionersCommand::RunCommand() void DiscoverCommissionersCommand::Shutdown() { - int commissionerCount = 0; + [[maybe_unused]] int commissionerCount = 0; for (int i = 0; i < CHIP_DEVICE_CONFIG_MAX_DISCOVERED_NODES; i++) { const Dnssd::DiscoveredNodeData * commissioner = mCommissionableNodeController.GetDiscoveredCommissioner(i); diff --git a/examples/common/websocket-server/WebSocketServer.cpp b/examples/common/websocket-server/WebSocketServer.cpp index 623dda3dc47527..2dba035601ea0e 100644 --- a/examples/common/websocket-server/WebSocketServer.cpp +++ b/examples/common/websocket-server/WebSocketServer.cpp @@ -24,9 +24,9 @@ #include #include -constexpr uint16_t kDefaultWebSocketServerPort = 9002; -constexpr uint16_t kMaxMessageBufferLen = 8192; -constexpr char kWebSocketServerReadyMessage[] = "== WebSocket Server Ready"; +constexpr uint16_t kDefaultWebSocketServerPort = 9002; +constexpr uint16_t kMaxMessageBufferLen = 8192; +[[maybe_unused]] constexpr char kWebSocketServerReadyMessage[] = "== WebSocket Server Ready"; namespace { lws * gWebSocketInstance = nullptr; diff --git a/examples/light-switch-app/genio/src/main.cpp b/examples/light-switch-app/genio/src/main.cpp index 93bb82a21b0735..d545409c706913 100644 --- a/examples/light-switch-app/genio/src/main.cpp +++ b/examples/light-switch-app/genio/src/main.cpp @@ -51,8 +51,6 @@ using namespace ::chip; using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; -#define UNUSED_PARAMETER(a) (a = a) - volatile int apperror_cnt; /*************************************************************************** diff --git a/examples/lighting-app/genio/src/AppTask.cpp b/examples/lighting-app/genio/src/AppTask.cpp index 6a121673a002a6..d948087833c4dd 100644 --- a/examples/lighting-app/genio/src/AppTask.cpp +++ b/examples/lighting-app/genio/src/AppTask.cpp @@ -66,8 +66,6 @@ #error "Must have portYIELD_FROM_ISR or portEND_SWITCHING_ISR" #endif -#define UNUSED_PARAMETER(a) (a = a) - #if defined(ENABLE_CHIP_SHELL) using chip::Shell::Engine; using chip::Shell::PrintCommandHelp; diff --git a/examples/lighting-app/genio/src/main.cpp b/examples/lighting-app/genio/src/main.cpp index ab578f3f2c75bd..22f654eb5f2f50 100644 --- a/examples/lighting-app/genio/src/main.cpp +++ b/examples/lighting-app/genio/src/main.cpp @@ -51,8 +51,6 @@ using namespace ::chip; using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; -#define UNUSED_PARAMETER(a) (a = a) - volatile int apperror_cnt; /*************************************************************************** diff --git a/examples/lock-app/genio/src/AppTask.cpp b/examples/lock-app/genio/src/AppTask.cpp index 7a438dd4974d3d..1c2f0719790196 100644 --- a/examples/lock-app/genio/src/AppTask.cpp +++ b/examples/lock-app/genio/src/AppTask.cpp @@ -60,8 +60,6 @@ #error "Must have portYIELD_FROM_ISR or portEND_SWITCHING_ISR" #endif -#define UNUSED_PARAMETER(a) (a = a) - namespace { TimerHandle_t sFunctionTimer; // FreeRTOS app sw timer. diff --git a/examples/lock-app/genio/src/main.cpp b/examples/lock-app/genio/src/main.cpp index 416c81c53436d7..92b16a39663ee4 100644 --- a/examples/lock-app/genio/src/main.cpp +++ b/examples/lock-app/genio/src/main.cpp @@ -51,8 +51,6 @@ using namespace ::chip; using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; -#define UNUSED_PARAMETER(a) (a = a) - volatile int apperror_cnt; /*************************************************************************** diff --git a/examples/ota-requestor-app/genio/src/AppTask.cpp b/examples/ota-requestor-app/genio/src/AppTask.cpp index 43c92cf26adeeb..50d1d080a5b7b4 100644 --- a/examples/ota-requestor-app/genio/src/AppTask.cpp +++ b/examples/ota-requestor-app/genio/src/AppTask.cpp @@ -53,8 +53,6 @@ #error "Must have portYIELD_FROM_ISR or portEND_SWITCHING_ISR" #endif -#define UNUSED_PARAMETER(a) (a = a) - namespace { TaskHandle_t sAppTaskHandle; diff --git a/examples/ota-requestor-app/genio/src/main.cpp b/examples/ota-requestor-app/genio/src/main.cpp index dcd85fbb920859..e3676c5c9eacbd 100644 --- a/examples/ota-requestor-app/genio/src/main.cpp +++ b/examples/ota-requestor-app/genio/src/main.cpp @@ -53,8 +53,6 @@ using namespace ::chip; using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; -#define UNUSED_PARAMETER(a) (a = a) - volatile int apperror_cnt; static void OTAEventsHandler(const DeviceLayer::ChipDeviceEvent * event, intptr_t arg) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx32_ncp_host.c b/examples/platform/silabs/efr32/rs911x/hal/efx32_ncp_host.c index 82976deb6a3b09..9f07d3f8f22c16 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx32_ncp_host.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx32_ncp_host.c @@ -57,11 +57,9 @@ LDMA_TransferCfg_t ldmaRXConfig; static osSemaphoreId_t transfer_done_semaphore = NULL; -static bool dma_callback(unsigned int channel, unsigned int sequenceNo, void * userParam) +static bool dma_callback([[maybe_unused]] unsigned int channel, [[maybe_unused]] unsigned int sequenceNo, + [[maybe_unused]] void * userParam) { - UNUSED_PARAMETER(channel); - UNUSED_PARAMETER(sequenceNo); - UNUSED_PARAMETER(userParam); #if defined(SL_CATLOG_POWER_MANAGER_PRESENT) sl_power_manager_remove_em_requirement(SL_POWER_MANAGER_EM1); #endif @@ -69,10 +67,8 @@ static bool dma_callback(unsigned int channel, unsigned int sequenceNo, void * u return false; } -static void gpio_interrupt(uint8_t interrupt_number) +static void gpio_interrupt([[maybe_unused]] uint8_t interrupt_number) { - UNUSED_PARAMETER(interrupt_number); - if (NULL != init_config.rx_irq) { init_config.rx_irq(); @@ -312,4 +308,4 @@ void sl_si91x_host_disable_bus_interrupt(void) bool sl_si91x_host_is_in_irq_context(void) { return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0U; -} \ No newline at end of file +} diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index ad6b5ed5e3418d..9097177b73a585 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -171,10 +171,7 @@ void sl_wfx_host_reset_chip(void) vTaskDelay(pdMS_TO_TICKS(3)); } -void gpio_interrupt(uint8_t interrupt_number) -{ - UNUSED_PARAMETER(interrupt_number); -} +void gpio_interrupt([[maybe_unused]] uint8_t interrupt_number) {} /***************************************************************** * @fn void rsi_hal_board_init(void) diff --git a/examples/thermostat/genio/src/main.cpp b/examples/thermostat/genio/src/main.cpp index 93bb82a21b0735..d545409c706913 100644 --- a/examples/thermostat/genio/src/main.cpp +++ b/examples/thermostat/genio/src/main.cpp @@ -51,8 +51,6 @@ using namespace ::chip; using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; -#define UNUSED_PARAMETER(a) (a = a) - volatile int apperror_cnt; /*************************************************************************** diff --git a/examples/tv-casting-app/linux/CastingUtils.cpp b/examples/tv-casting-app/linux/CastingUtils.cpp index 02b9467d884614..d4d71b5dd2c0ae 100644 --- a/examples/tv-casting-app/linux/CastingUtils.cpp +++ b/examples/tv-casting-app/linux/CastingUtils.cpp @@ -105,7 +105,7 @@ void InitCommissioningFlow(intptr_t commandArg) commissioner->LogDetail(); if (associatedConnectableVideoPlayer.HasValue()) { - TargetVideoPlayerInfo * targetVideoPlayerInfo = associatedConnectableVideoPlayer.Value(); + [[maybe_unused]] TargetVideoPlayerInfo * targetVideoPlayerInfo = associatedConnectableVideoPlayer.Value(); ChipLogProgress(AppServer, "Previously connected with nodeId 0x" ChipLogFormatX64 " fabricIndex: %d", ChipLogValueX64(targetVideoPlayerInfo->GetNodeId()), targetVideoPlayerInfo->GetFabricIndex()); } @@ -305,7 +305,7 @@ void PrintFabrics() ChipLogError(AppServer, " -- Not initialized"); continue; } - NodeId myNodeId = fb.GetNodeId(); + [[maybe_unused]] NodeId myNodeId = fb.GetNodeId(); ChipLogProgress(NotSpecified, "---- Current Fabric nodeId=0x" ChipLogFormatX64 " fabricId=0x" ChipLogFormatX64 " fabricIndex=%d", ChipLogValueX64(myNodeId), ChipLogValueX64(fb.GetFabricId()), fabricIndex); diff --git a/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp b/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp index 41d9feb52977eb..f34b6b2ef16c34 100644 --- a/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp +++ b/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp @@ -257,7 +257,7 @@ void CastingPlayer::LogDetail() const { for (unsigned j = 0; j < mAttributes.numIPs; j++) { - char * ipAddressOut = mAttributes.ipAddresses[j].ToString(buf); + [[maybe_unused]] char * ipAddressOut = mAttributes.ipAddresses[j].ToString(buf); ChipLogDetail(AppServer, "\tIP Address #%d: %s", j + 1, ipAddressOut); } } diff --git a/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp b/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp index 98f6b197a59e33..a3de0a263c3efe 100644 --- a/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp +++ b/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp @@ -695,7 +695,7 @@ void CastingServer::SetDefaultFabricIndex(std::functionGetEndpointId(); - EndpointId ep = emberAfClearDynamicEndpoint(index); - mContentApps[index] = nullptr; - ChipLogProgress(DeviceLayer, "Removed device %d from dynamic endpoint %d (index=%d)", - app->GetApplicationBasicDelegate()->HandleGetVendorId(), ep, index); // Silence complaints about unused ep when progress logging // disabled. - UNUSED_VAR(ep); + /*[[maybe_unused]]*/ EndpointId ep = emberAfClearDynamicEndpoint(index); + mContentApps[index] = nullptr; + ChipLogProgress(DeviceLayer, "Removed device %d from dynamic endpoint %d (index=%d)", + app->GetApplicationBasicDelegate()->HandleGetVendorId(), ep, index); if (curEndpoint == mCurrentAppEndpointId) { mCurrentAppEndpointId = kNoCurrentEndpointId; diff --git a/src/app/server/DefaultAclStorage.cpp b/src/app/server/DefaultAclStorage.cpp index 58d0d18feedda6..6f40cce2599893 100644 --- a/src/app/server/DefaultAclStorage.cpp +++ b/src/app/server/DefaultAclStorage.cpp @@ -138,7 +138,7 @@ CHIP_ERROR DefaultAclStorage::Init(PersistentStorageDelegate & persistentStorage CHIP_ERROR err; - size_t count = 0; + [[maybe_unused]] size_t count = 0; for (auto it = first; it != last; ++it) { diff --git a/src/app/util/types_stub.h b/src/app/util/types_stub.h index ac26684f850cd7..dbd1ea184169e1 100644 --- a/src/app/util/types_stub.h +++ b/src/app/util/types_stub.h @@ -166,12 +166,6 @@ typedef struct } EmberEventControl; -/** - * @description Useful macro for avoiding compiler warnings related to unused - * function arguments or unused variables. - */ -#define UNUSED_VAR(x) (void) (x) - /** * @brief Returns the value of the bitmask \c bits within * the register or byte \c reg. diff --git a/src/controller/tests/data_model/TestRead.cpp b/src/controller/tests/data_model/TestRead.cpp index 917c3a1251e344..fc2cfaf516524b 100644 --- a/src/controller/tests/data_model/TestRead.cpp +++ b/src/controller/tests/data_model/TestRead.cpp @@ -475,7 +475,7 @@ void TestReadInteraction::TestReadSubscribeAttributeResponseWithCache(nlTestSuit // app::InteractionModelEngine::GetInstance()->RegisterReadHandlerAppCallback(&gTestReadInteraction); - int testId = 0; + [[maybe_unused]] int testId = 0; // Read of E2C3A1(dedup), E*C3A1(E1C3A1 not exit, E2C3A1 exist), E2C3A* (5 supported attributes) // Expect no versions would be cached. diff --git a/src/crypto/tests/TestChipCryptoPAL.cpp b/src/crypto/tests/TestChipCryptoPAL.cpp index b2e12568b7c222..db5ee6b74480cd 100644 --- a/src/crypto/tests/TestChipCryptoPAL.cpp +++ b/src/crypto/tests/TestChipCryptoPAL.cpp @@ -2715,7 +2715,7 @@ static void TestVIDPID_StringExtraction(nlTestSuite * inSuite, void * inContext) }; // clang-format on - int caseIdx = 0; + [[maybe_unused]] int caseIdx = 0; for (const auto & testCase : kTestCases) { AttestationCertVidPid vidpid;