Skip to content

Commit 9b283f4

Browse files
Correctly annotate things that are unused when logging is disabled.
We don't seem to have very good CI coverage for the logging-disabled configurations. Also removes UNUSED_VAR and UNUSED_PARAMETER use in favor of the standard [[maybe_unused]]. Fixes project-chip#32113
1 parent 274719d commit 9b283f4

File tree

27 files changed

+37
-70
lines changed

27 files changed

+37
-70
lines changed

examples/bridge-app/asr/subdevice/SubDeviceManager.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,11 @@ CHIP_ERROR RemoveDeviceEndpoint(SubDevice * dev)
9191
{
9292
if (gSubDevices[index] == dev)
9393
{
94-
EndpointId ep = emberAfClearDynamicEndpoint(index);
95-
gSubDevices[index] = NULL;
96-
ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index);
9794
// Silence complaints about unused ep when progress logging
9895
// disabled.
99-
UNUSED_VAR(ep);
96+
[[maybe_unused] EndpointId ep = emberAfClearDynamicEndpoint(index);
97+
gSubDevices[index] = NULL;
98+
ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index);
10099
return CHIP_NO_ERROR;
101100
}
102101
}

examples/bridge-app/esp32/main/main.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,11 @@ CHIP_ERROR RemoveDeviceEndpoint(Device * dev)
201201
{
202202
if (gDevices[index] == dev)
203203
{
204-
EndpointId ep = emberAfClearDynamicEndpoint(index);
205-
gDevices[index] = NULL;
206-
ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index);
207204
// Silence complaints about unused ep when progress logging
208205
// disabled.
209-
UNUSED_VAR(ep);
206+
[[maybe_unused]] EndpointId ep = emberAfClearDynamicEndpoint(index);
207+
gDevices[index] = NULL;
208+
ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index);
210209
return CHIP_NO_ERROR;
211210
}
212211
}

examples/bridge-app/linux/main.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,11 @@ int RemoveDeviceEndpoint(Device * dev)
300300
{
301301
// Todo: Update this to schedule the work rather than use this lock
302302
DeviceLayer::StackLock lock;
303-
EndpointId ep = emberAfClearDynamicEndpoint(index);
304-
gDevices[index] = nullptr;
305-
ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index);
306303
// Silence complaints about unused ep when progress logging
307304
// disabled.
308-
UNUSED_VAR(ep);
305+
[[maybe_unused]] EndpointId ep = emberAfClearDynamicEndpoint(index);
306+
gDevices[index] = nullptr;
307+
ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index);
309308
return index;
310309
}
311310
index++;

examples/bridge-app/telink/src/AppTask.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,11 @@ CHIP_ERROR RemoveDeviceEndpoint(Device * dev)
224224
{
225225
if (gDevices[index] == dev)
226226
{
227-
EndpointId ep = emberAfClearDynamicEndpoint(index);
228-
gDevices[index] = NULL;
229-
ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index);
230227
// Silence complaints about unused ep when progress logging
231228
// disabled.
232-
UNUSED_VAR(ep);
229+
[[maybe_unused]] EndpointId ep = emberAfClearDynamicEndpoint(index);
230+
gDevices[index] = NULL;
231+
ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index);
233232
return CHIP_NO_ERROR;
234233
}
235234
}

examples/chip-tool/commands/common/DeviceScanner.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ void DeviceScanner::Log() const
218218
auto resultsCount = mDiscoveredResults.size();
219219
VerifyOrReturn(resultsCount > 0, ChipLogProgress(chipTool, "No device discovered."));
220220

221-
uint16_t index = 0;
221+
[[maybe_unused]] uint16_t index = 0;
222222
for (auto & instance : mDiscoveredResults)
223223
{
224224
ChipLogProgress(chipTool, "Instance Name: %s ", instance.first.c_str());

examples/chip-tool/commands/discover/DiscoverCommissionersCommand.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ CHIP_ERROR DiscoverCommissionersCommand::RunCommand()
2929

3030
void DiscoverCommissionersCommand::Shutdown()
3131
{
32-
int commissionerCount = 0;
32+
[[maybe_unused]] int commissionerCount = 0;
3333
for (int i = 0; i < CHIP_DEVICE_CONFIG_MAX_DISCOVERED_NODES; i++)
3434
{
3535
const Dnssd::DiscoveredNodeData * commissioner = mCommissionableNodeController.GetDiscoveredCommissioner(i);

examples/common/websocket-server/WebSocketServer.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
#include <deque>
2525
#include <mutex>
2626

27-
constexpr uint16_t kDefaultWebSocketServerPort = 9002;
28-
constexpr uint16_t kMaxMessageBufferLen = 8192;
29-
constexpr char kWebSocketServerReadyMessage[] = "== WebSocket Server Ready";
27+
constexpr uint16_t kDefaultWebSocketServerPort = 9002;
28+
constexpr uint16_t kMaxMessageBufferLen = 8192;
29+
[[maybe_unused]] constexpr char kWebSocketServerReadyMessage[] = "== WebSocket Server Ready";
3030

3131
namespace {
3232
lws * gWebSocketInstance = nullptr;

examples/light-switch-app/genio/src/main.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ using namespace ::chip;
5151
using namespace ::chip::Inet;
5252
using namespace ::chip::DeviceLayer;
5353

54-
#define UNUSED_PARAMETER(a) (a = a)
55-
5654
volatile int apperror_cnt;
5755

5856
/***************************************************************************

examples/lighting-app/genio/src/AppTask.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@
6666
#error "Must have portYIELD_FROM_ISR or portEND_SWITCHING_ISR"
6767
#endif
6868

69-
#define UNUSED_PARAMETER(a) (a = a)
70-
7169
#if defined(ENABLE_CHIP_SHELL)
7270
using chip::Shell::Engine;
7371
using chip::Shell::PrintCommandHelp;

examples/lighting-app/genio/src/main.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ using namespace ::chip;
5151
using namespace ::chip::Inet;
5252
using namespace ::chip::DeviceLayer;
5353

54-
#define UNUSED_PARAMETER(a) (a = a)
55-
5654
volatile int apperror_cnt;
5755

5856
/***************************************************************************

examples/lock-app/genio/src/AppTask.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@
6060
#error "Must have portYIELD_FROM_ISR or portEND_SWITCHING_ISR"
6161
#endif
6262

63-
#define UNUSED_PARAMETER(a) (a = a)
64-
6563
namespace {
6664

6765
TimerHandle_t sFunctionTimer; // FreeRTOS app sw timer.

examples/lock-app/genio/src/main.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ using namespace ::chip;
5151
using namespace ::chip::Inet;
5252
using namespace ::chip::DeviceLayer;
5353

54-
#define UNUSED_PARAMETER(a) (a = a)
55-
5654
volatile int apperror_cnt;
5755

5856
/***************************************************************************

examples/ota-requestor-app/genio/src/AppTask.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@
5353
#error "Must have portYIELD_FROM_ISR or portEND_SWITCHING_ISR"
5454
#endif
5555

56-
#define UNUSED_PARAMETER(a) (a = a)
57-
5856
namespace {
5957

6058
TaskHandle_t sAppTaskHandle;

examples/ota-requestor-app/genio/src/main.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ using namespace ::chip;
5353
using namespace ::chip::Inet;
5454
using namespace ::chip::DeviceLayer;
5555

56-
#define UNUSED_PARAMETER(a) (a = a)
57-
5856
volatile int apperror_cnt;
5957

6058
static void OTAEventsHandler(const DeviceLayer::ChipDeviceEvent * event, intptr_t arg)

examples/platform/silabs/efr32/rs911x/hal/efx32_ncp_host.c

+4-7
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,18 @@ LDMA_TransferCfg_t ldmaRXConfig;
5555

5656
static osSemaphoreId_t transfer_done_semaphore = NULL;
5757

58-
static bool dma_callback(unsigned int channel, unsigned int sequenceNo, void * userParam)
58+
static bool dma_callback([[maybe_unused]] unsigned int channel, [[maybe_unused]] unsigned int sequenceNo,
59+
[[maybe_unused]] void * userParam)
5960
{
60-
UNUSED_PARAMETER(channel);
61-
UNUSED_PARAMETER(sequenceNo);
62-
UNUSED_PARAMETER(userParam);
6361
#if defined(SL_CATLOG_POWER_MANAGER_PRESENT)
6462
sl_power_manager_remove_em_requirement(SL_POWER_MANAGER_EM1);
6563
#endif
6664
osSemaphoreRelease(transfer_done_semaphore);
6765
return false;
6866
}
6967

70-
static void gpio_interrupt(uint8_t interrupt_number)
68+
static void gpio_interrupt([[maybe_unused]] uint8_t interrupt_number)
7169
{
72-
UNUSED_PARAMETER(interrupt_number);
7370
sl_si91x_host_set_bus_event(NCP_HOST_BUS_RX_EVENT);
7471
// GPIO_IntClear(0xAAAA);
7572
}
@@ -299,4 +296,4 @@ void sl_si91x_host_disable_bus_interrupt(void)
299296
bool sl_si91x_host_is_in_irq_context(void)
300297
{
301298
return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0U;
302-
}
299+
}

examples/platform/silabs/efr32/rs911x/hal/efx_spi.c

+1-4
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,7 @@ void sl_wfx_host_reset_chip(void)
171171
vTaskDelay(pdMS_TO_TICKS(3));
172172
}
173173

174-
void gpio_interrupt(uint8_t interrupt_number)
175-
{
176-
UNUSED_PARAMETER(interrupt_number);
177-
}
174+
void gpio_interrupt([[maybe_unused]] uint8_t interrupt_number) {}
178175

179176
/*****************************************************************
180177
* @fn void rsi_hal_board_init(void)

examples/providers/DeviceInfoProviderImpl.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ class DeviceInfoProviderImpl : public DeviceInfoProvider
4646
void Release() override { chip::Platform::Delete(this); }
4747

4848
private:
49-
EndpointId mEndpoint = 0;
50-
size_t mIndex = 0;
49+
[[maybe_unused]] EndpointId mEndpoint = 0;
50+
size_t mIndex = 0;
5151
char mFixedLabelNameBuf[kMaxLabelNameLength + 1];
5252
char mFixedLabelValueBuf[kMaxLabelValueLength + 1];
5353
};

examples/thermostat/genio/src/main.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ using namespace ::chip;
5151
using namespace ::chip::Inet;
5252
using namespace ::chip::DeviceLayer;
5353

54-
#define UNUSED_PARAMETER(a) (a = a)
55-
5654
volatile int apperror_cnt;
5755

5856
/***************************************************************************

examples/tv-casting-app/linux/CastingUtils.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void InitCommissioningFlow(intptr_t commandArg)
105105
commissioner->LogDetail();
106106
if (associatedConnectableVideoPlayer.HasValue())
107107
{
108-
TargetVideoPlayerInfo * targetVideoPlayerInfo = associatedConnectableVideoPlayer.Value();
108+
[[maybe_unused]] TargetVideoPlayerInfo * targetVideoPlayerInfo = associatedConnectableVideoPlayer.Value();
109109
ChipLogProgress(AppServer, "Previously connected with nodeId 0x" ChipLogFormatX64 " fabricIndex: %d",
110110
ChipLogValueX64(targetVideoPlayerInfo->GetNodeId()), targetVideoPlayerInfo->GetFabricIndex());
111111
}
@@ -305,7 +305,7 @@ void PrintFabrics()
305305
ChipLogError(AppServer, " -- Not initialized");
306306
continue;
307307
}
308-
NodeId myNodeId = fb.GetNodeId();
308+
[[maybe_unused]] NodeId myNodeId = fb.GetNodeId();
309309
ChipLogProgress(NotSpecified,
310310
"---- Current Fabric nodeId=0x" ChipLogFormatX64 " fabricId=0x" ChipLogFormatX64 " fabricIndex=%d",
311311
ChipLogValueX64(myNodeId), ChipLogValueX64(fb.GetFabricId()), fabricIndex);

examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ void CastingPlayer::LogDetail() const
257257
{
258258
for (unsigned j = 0; j < mAttributes.numIPs; j++)
259259
{
260-
char * ipAddressOut = mAttributes.ipAddresses[j].ToString(buf);
260+
[[maybe_unused]] char * ipAddressOut = mAttributes.ipAddresses[j].ToString(buf);
261261
ChipLogDetail(AppServer, "\tIP Address #%d: %s", j + 1, ipAddressOut);
262262
}
263263
}

examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ void CastingServer::SetDefaultFabricIndex(std::function<void(TargetVideoPlayerIn
695695
ChipLogError(AppServer, " -- Not initialized");
696696
continue;
697697
}
698-
NodeId myNodeId = fb.GetNodeId();
698+
[[maybe_unused]] NodeId myNodeId = fb.GetNodeId();
699699
ChipLogProgress(NotSpecified,
700700
"---- Current Fabric nodeId=0x" ChipLogFormatX64 " fabricId=0x" ChipLogFormatX64 " fabricIndex=%d",
701701
ChipLogValueX64(myNodeId), ChipLogValueX64(fb.GetFabricId()), fabricIndex);

examples/tv-casting-app/tv-casting-common/src/ZCLCallbacks.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ using namespace ::chip::app::Clusters;
3838
void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size,
3939
uint8_t * value)
4040
{
41-
ClusterId clusterId = attributePath.mClusterId;
42-
AttributeId attributeId = attributePath.mAttributeId;
41+
[[maybe_unused]] ClusterId clusterId = attributePath.mClusterId;
42+
[[maybe_unused]] AttributeId attributeId = attributePath.mAttributeId;
4343
ChipLogProgress(Zcl, "AttributeChangeCallback cluster: " ChipLogFormatMEI " attribute:" ChipLogFormatMEI,
4444
ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId));
4545
}

src/app/app-platform/ContentAppPlatform.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,12 @@ EndpointId ContentAppPlatform::RemoveContentApp(ContentApp * app)
237237
if (mContentApps[index] == app)
238238
{
239239
EndpointId curEndpoint = app->GetEndpointId();
240-
EndpointId ep = emberAfClearDynamicEndpoint(index);
241-
mContentApps[index] = nullptr;
242-
ChipLogProgress(DeviceLayer, "Removed device %d from dynamic endpoint %d (index=%d)",
243-
app->GetApplicationBasicDelegate()->HandleGetVendorId(), ep, index);
244240
// Silence complaints about unused ep when progress logging
245241
// disabled.
246-
UNUSED_VAR(ep);
242+
/*[[maybe_unused]]*/ EndpointId ep = emberAfClearDynamicEndpoint(index);
243+
mContentApps[index] = nullptr;
244+
ChipLogProgress(DeviceLayer, "Removed device %d from dynamic endpoint %d (index=%d)",
245+
app->GetApplicationBasicDelegate()->HandleGetVendorId(), ep, index);
247246
if (curEndpoint == mCurrentAppEndpointId)
248247
{
249248
mCurrentAppEndpointId = kNoCurrentEndpointId;

src/app/server/DefaultAclStorage.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ CHIP_ERROR DefaultAclStorage::Init(PersistentStorageDelegate & persistentStorage
138138

139139
CHIP_ERROR err;
140140

141-
size_t count = 0;
141+
[[maybe_unused]] size_t count = 0;
142142

143143
for (auto it = first; it != last; ++it)
144144
{

src/app/util/types_stub.h

-6
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,6 @@ typedef struct
166166

167167
} EmberEventControl;
168168

169-
/**
170-
* @description Useful macro for avoiding compiler warnings related to unused
171-
* function arguments or unused variables.
172-
*/
173-
#define UNUSED_VAR(x) (void) (x)
174-
175169
/**
176170
* @brief Returns the value of the bitmask \c bits within
177171
* the register or byte \c reg.

src/controller/tests/data_model/TestRead.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ void TestReadInteraction::TestReadSubscribeAttributeResponseWithCache(nlTestSuit
475475
//
476476
app::InteractionModelEngine::GetInstance()->RegisterReadHandlerAppCallback(&gTestReadInteraction);
477477

478-
int testId = 0;
478+
[[maybe_unused]] int testId = 0;
479479

480480
// Read of E2C3A1(dedup), E*C3A1(E1C3A1 not exit, E2C3A1 exist), E2C3A* (5 supported attributes)
481481
// Expect no versions would be cached.

src/crypto/tests/TestChipCryptoPAL.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2715,7 +2715,7 @@ static void TestVIDPID_StringExtraction(nlTestSuite * inSuite, void * inContext)
27152715
};
27162716
// clang-format on
27172717

2718-
int caseIdx = 0;
2718+
[[maybe_unused]] int caseIdx = 0;
27192719
for (const auto & testCase : kTestCases)
27202720
{
27212721
AttestationCertVidPid vidpid;

0 commit comments

Comments
 (0)