Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly annotate things that are unused when logging is disabled. #32141

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions examples/bridge-app/asr/subdevice/SubDeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
7 changes: 3 additions & 4 deletions examples/bridge-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
7 changes: 3 additions & 4 deletions examples/bridge-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
7 changes: 3 additions & 4 deletions examples/bridge-app/telink/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/chip-tool/commands/common/DeviceScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions examples/common/websocket-server/WebSocketServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#include <deque>
#include <mutex>

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;
Expand Down
2 changes: 0 additions & 2 deletions examples/light-switch-app/genio/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/***************************************************************************
Expand Down
2 changes: 0 additions & 2 deletions examples/lighting-app/genio/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions examples/lighting-app/genio/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/***************************************************************************
Expand Down
2 changes: 0 additions & 2 deletions examples/lock-app/genio/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions examples/lock-app/genio/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/***************************************************************************
Expand Down
2 changes: 0 additions & 2 deletions examples/ota-requestor-app/genio/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions examples/ota-requestor-app/genio/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 4 additions & 8 deletions examples/platform/silabs/efr32/rs911x/hal/efx32_ncp_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,18 @@ 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
osSemaphoreRelease(transfer_done_semaphore);
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();
Expand Down Expand Up @@ -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;
}
}
5 changes: 1 addition & 4 deletions examples/platform/silabs/efr32/rs911x/hal/efx_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions examples/thermostat/genio/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/***************************************************************************
Expand Down
4 changes: 2 additions & 2 deletions examples/tv-casting-app/linux/CastingUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ void CastingServer::SetDefaultFabricIndex(std::function<void(TargetVideoPlayerIn
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ using namespace ::chip::app::Clusters;
void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size,
uint8_t * value)
{
ClusterId clusterId = attributePath.mClusterId;
AttributeId attributeId = attributePath.mAttributeId;
[[maybe_unused]] ClusterId clusterId = attributePath.mClusterId;
[[maybe_unused]] AttributeId attributeId = attributePath.mAttributeId;
ChipLogProgress(Zcl, "AttributeChangeCallback cluster: " ChipLogFormatMEI " attribute:" ChipLogFormatMEI,
ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId));
}
Expand Down
9 changes: 4 additions & 5 deletions src/app/app-platform/ContentAppPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,12 @@ EndpointId ContentAppPlatform::RemoveContentApp(ContentApp * app)
if (mContentApps[index] == app)
{
EndpointId curEndpoint = app->GetEndpointId();
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;
Expand Down
2 changes: 1 addition & 1 deletion src/app/server/DefaultAclStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
6 changes: 0 additions & 6 deletions src/app/util/types_stub.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/controller/tests/data_model/TestRead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/tests/TestChipCryptoPAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading