Skip to content

Commit 2002c0c

Browse files
Add missing [[maybe_unused]] annotations in unit tests (#33007)
* Added [[maybe_unused]] to allow building unit test and Silabs apps without loggs * Added gating of SILABS_LOG_ENABLED on chip_logging
1 parent 6ba907e commit 2002c0c

File tree

4 files changed

+28
-18
lines changed

4 files changed

+28
-18
lines changed

examples/platform/silabs/SoftwareFaultReports.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,18 @@ void OnSoftwareFaultEventHandler(const char * faultRecordString)
8989
extern "C" __attribute__((used)) void debugHardfault(uint32_t * sp)
9090
{
9191
#if SILABS_LOG_ENABLED
92-
uint32_t cfsr = SCB->CFSR;
93-
uint32_t hfsr = SCB->HFSR;
94-
uint32_t mmfar = SCB->MMFAR;
95-
uint32_t bfar = SCB->BFAR;
96-
uint32_t r0 = sp[0];
97-
uint32_t r1 = sp[1];
98-
uint32_t r2 = sp[2];
99-
uint32_t r3 = sp[3];
100-
uint32_t r12 = sp[4];
101-
uint32_t lr = sp[5];
102-
uint32_t pc = sp[6];
103-
uint32_t psr = sp[7];
92+
[[maybe_unused]] uint32_t cfsr = SCB->CFSR;
93+
[[maybe_unused]] uint32_t hfsr = SCB->HFSR;
94+
[[maybe_unused]] uint32_t mmfar = SCB->MMFAR;
95+
[[maybe_unused]] uint32_t bfar = SCB->BFAR;
96+
[[maybe_unused]] uint32_t r0 = sp[0];
97+
[[maybe_unused]] uint32_t r1 = sp[1];
98+
[[maybe_unused]] uint32_t r2 = sp[2];
99+
[[maybe_unused]] uint32_t r3 = sp[3];
100+
[[maybe_unused]] uint32_t r12 = sp[4];
101+
[[maybe_unused]] uint32_t lr = sp[5];
102+
[[maybe_unused]] uint32_t pc = sp[6];
103+
[[maybe_unused]] uint32_t psr = sp[7];
104104

105105
ChipLogError(NotSpecified, "HardFault:");
106106
ChipLogError(NotSpecified, "SCB->CFSR 0x%08lx", cfsr);

src/crypto/tests/TestChipCryptoPAL.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ static void TestRawIntegerToDerInvalidCases(nlTestSuite * inSuite, void * inCont
640640
{ .input = bad_buffer_empty, .output = good_out_buffer, .expected_status = CHIP_ERROR_INVALID_ARGUMENT }
641641
};
642642

643-
int case_idx = 0;
643+
[[maybe_unused]] int case_idx = 0;
644644
for (const ErrorCase & v : error_cases)
645645
{
646646
CHIP_ERROR status = ConvertIntegerRawToDerWithoutTag(v.input, v.output);
@@ -704,7 +704,7 @@ static void TestReadDerLengthValidCases(nlTestSuite * inSuite, void * inContext)
704704
{ .input_buf = max_byte_length_large_buf, .expected_length = SIZE_MAX },
705705
};
706706

707-
int case_idx = 0;
707+
[[maybe_unused]] int case_idx = 0;
708708
for (const SuccessCase & v : cases)
709709
{
710710
size_t output_length = SIZE_MAX - 1;
@@ -768,7 +768,7 @@ static void TestReadDerLengthInvalidCases(nlTestSuite * inSuite, void * inContex
768768
{ .input_buf = max_byte_length_large_insufficient_bytes_buf, .expected_status = CHIP_ERROR_BUFFER_TOO_SMALL },
769769
};
770770

771-
int case_idx = 0;
771+
[[maybe_unused]] int case_idx = 0;
772772
for (const ErrorCase & v : error_cases)
773773
{
774774
size_t output_length = SIZE_MAX;
@@ -2135,7 +2135,7 @@ static void TestX509_VerifyAttestationCertificateFormat(nlTestSuite * inSuite, v
21352135
};
21362136
// clang-format on
21372137

2138-
int case_idx = 0;
2138+
[[maybe_unused]] int case_idx = 0;
21392139
for (auto & testCase : sValidationTestCases)
21402140
{
21412141
ByteSpan cert = testCase.cert;

third_party/silabs/SiWx917_sdk.gni

+6-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ template("siwx917_sdk") {
166166
"MBEDTLS_CONFIG_FILE=\"siwx917-chip-mbedtls-config.h\"",
167167
"__STARTUP_CLEAR_BSS",
168168
"HARD_FAULT_LOG_ENABLE",
169-
"SILABS_LOG_ENABLED=${silabs_log_enabled}",
170169
"SL_HEAP_SIZE=32768",
171170
"SL_WIFI=1",
172171
"CCP_SI917_BRINGUP=1",
@@ -224,6 +223,12 @@ template("siwx917_sdk") {
224223
"configUSE_POSIX_ERRNO=1",
225224
]
226225

226+
if (silabs_log_enabled && chip_logging) {
227+
defines += [ "SILABS_LOG_ENABLED=1" ]
228+
} else {
229+
defines += [ "SILABS_LOG_ENABLED=0" ]
230+
}
231+
227232
if (chip_build_libshell) {
228233
defines += [ "ENABLE_CHIP_SHELL" ]
229234
}

third_party/silabs/efr32_sdk.gni

+6-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ template("efr32_sdk") {
283283
"__STARTUP_CLEAR_BSS",
284284
"HARD_FAULT_LOG_ENABLE",
285285
"CORTEXM3_EFM32_MICRO",
286-
"SILABS_LOG_ENABLED=${silabs_log_enabled}",
287286
"NVM3_DEFAULT_NVM_SIZE=40960",
288287
"NVM3_DEFAULT_MAX_OBJECT_SIZE=4092",
289288
"KVS_MAX_ENTRIES=${kvs_max_entries}",
@@ -308,6 +307,12 @@ template("efr32_sdk") {
308307
#"__STACK_SIZE=0",
309308
]
310309

310+
if (silabs_log_enabled && chip_logging) {
311+
defines += [ "SILABS_LOG_ENABLED=1" ]
312+
} else {
313+
defines += [ "SILABS_LOG_ENABLED=0" ]
314+
}
315+
311316
# Temporary configuration to enable COAP specific configurations
312317
if (use_thread_coap_lib) {
313318
defines += [ "SL_USE_COAP_CONFIG=1" ]

0 commit comments

Comments
 (0)