Skip to content

Commit d6f4d99

Browse files
committed
core system: Fix warnings in compilation when assertions are disabled
Adds a CI config for hello world that sets this, to catch future regressions
1 parent ac77665 commit d6f4d99

File tree

45 files changed

+114
-61
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+114
-61
lines changed

components/bootloader_support/src/idf/bootloader_sha.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ void bootloader_sha256_data(bootloader_sha256_handle_t handle, const void *data,
3939
mbedtls_sha256_context *ctx = (mbedtls_sha256_context *)handle;
4040
int ret = mbedtls_sha256_update_ret(ctx, data, data_len);
4141
assert(ret == 0);
42+
(void)ret;
4243
}
4344

4445
void bootloader_sha256_finish(bootloader_sha256_handle_t handle, uint8_t *digest)
@@ -48,6 +49,7 @@ void bootloader_sha256_finish(bootloader_sha256_handle_t handle, uint8_t *digest
4849
if (digest != NULL) {
4950
int ret = mbedtls_sha256_finish_ret(ctx, digest);
5051
assert(ret == 0);
52+
(void)ret;
5153
}
5254
mbedtls_sha256_free(ctx);
5355
free(handle);

components/bt/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,3 +599,13 @@ if(CONFIG_BT_ENABLED)
599599
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app btbb)
600600
endif()
601601
endif()
602+
603+
if(CONFIG_BT_NIMBLE_MESH)
604+
set_source_files_properties("host/nimble/nimble/nimble/host/mesh/src/net.c"
605+
PROPERTIES COMPILE_FLAGS -Wno-type-limits)
606+
endif()
607+
608+
if(CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE AND CONFIG_BT_NIMBLE_ENABLED)
609+
# some variables in NimBLE are only used by asserts
610+
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-unused-but-set-variable -Wno-unused-variable)
611+
endif()

components/bt/common/osi/hash_map.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ bool hash_map_set(hash_map_t *hash_map, const void *key, void *data)
144144
// Calls hash_map callback to delete the hash_map_entry.
145145
bool rc = list_remove(hash_bucket_list, hash_map_entry);
146146
assert(rc == true);
147+
(void)rc;
147148
} else {
148149
hash_map->hash_size++;
149150
}

components/bt/controller/esp32/bt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,8 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
13091309
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
13101310
#endif
13111311

1312-
bool select_src_ret, set_div_ret;
1312+
bool select_src_ret __attribute__((unused));
1313+
bool set_div_ret __attribute__((unused));
13131314
if (btdm_lpclk_sel == BTDM_LPCLK_SEL_XTAL) {
13141315
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL);
13151316
set_div_ret = btdm_lpclk_set_div(rtc_clk_xtal_freq_get() * 2 - 1);

components/bt/controller/esp32c3/bt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,8 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
10501050
s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
10511051
#endif
10521052

1053-
bool select_src_ret, set_div_ret;
1053+
bool select_src_ret __attribute__((unused));
1054+
bool set_div_ret __attribute__((unused));
10541055
if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_XTAL) {
10551056
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL);
10561057
set_div_ret = btdm_lpclk_set_div(rtc_clk_xtal_freq_get() * 2);

components/bt/controller/esp32s3/bt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -988,8 +988,8 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
988988
cfg->sleep_clock = ESP_BT_SLEEP_CLOCK_FPGA_32K;
989989
ESP_LOGW(BTDM_LOG_TAG, "%s sleep clock overwrite on FPGA", __func__);
990990
#endif
991-
bool select_src_ret = false;
992-
bool set_div_ret = false;
991+
bool select_src_ret __attribute__((unused));
992+
bool set_div_ret __attribute__((unused));
993993
if (cfg->sleep_clock == ESP_BT_SLEEP_CLOCK_MAIN_XTAL) {
994994
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL);
995995
set_div_ret = btdm_lpclk_set_div(rtc_clk_xtal_freq_get() * 2);

components/bt/host/bluedroid/hci/hci_packet_parser.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,19 +227,19 @@ static uint8_t *read_command_complete_header(
227227
uint8_t *stream = response->data + response->offset;
228228

229229
// Read the event header
230-
uint8_t event_code;
231-
uint8_t parameter_length;
230+
uint8_t event_code __attribute__((unused));
231+
uint8_t parameter_length __attribute__((unused));
232232
STREAM_TO_UINT8(event_code, stream);
233233
STREAM_TO_UINT8(parameter_length, stream);
234234

235-
const size_t parameter_bytes_we_read_here = 4;
235+
const size_t parameter_bytes_we_read_here __attribute__((unused)) = 4;
236236

237237
// Check the event header values against what we expect
238238
assert(event_code == HCI_COMMAND_COMPLETE_EVT);
239239
assert(parameter_length >= (parameter_bytes_we_read_here + minimum_bytes_after));
240240

241241
// Read the command complete header
242-
command_opcode_t opcode;
242+
command_opcode_t opcode __attribute__((unused));
243243
uint8_t status;
244244
STREAM_SKIP_UINT8(stream); // skip the number of hci command packets field
245245
STREAM_TO_UINT16(opcode, stream);

components/bt/host/bluedroid/hci/packet_fragmenter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static void reassemble_and_dispatch(BT_HDR *packet)
141141
uint8_t *stream = packet->data + packet->offset;
142142
uint16_t handle;
143143
uint16_t l2cap_length;
144-
uint16_t acl_length;
144+
uint16_t acl_length __attribute__((unused));
145145

146146
STREAM_TO_UINT16(handle, stream);
147147
STREAM_TO_UINT16(acl_length, stream);

components/cxx/cxx_guards.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ static void wait_for_guard_obj(guard_t* g)
8282
do {
8383
auto result = xSemaphoreGive(s_static_init_mutex);
8484
assert(result);
85+
static_cast<void>(result);
8586
/* Task may be preempted here, but this isn't a problem,
8687
* as the semaphore will be given exactly the s_static_init_waiting_count
8788
* number of times; eventually the current task will execute next statement,
@@ -140,6 +141,7 @@ extern "C" int __cxa_guard_acquire(__guard* pg)
140141
*/
141142
auto result = xSemaphoreTake(s_static_init_mutex, portMAX_DELAY);
142143
assert(result);
144+
static_cast<void>(result);
143145
if (g->pending) {
144146
/* Another task is doing initialization at the moment; wait until it calls
145147
* __cxa_guard_release or __cxa_guard_abort
@@ -168,6 +170,7 @@ extern "C" int __cxa_guard_acquire(__guard* pg)
168170
if (scheduler_started) {
169171
auto result = xSemaphoreGive(s_static_init_mutex);
170172
assert(result);
173+
static_cast<void>(result);
171174
}
172175
return ret;
173176
}
@@ -179,6 +182,7 @@ extern "C" void __cxa_guard_release(__guard* pg)
179182
if (scheduler_started) {
180183
auto result = xSemaphoreTake(s_static_init_mutex, portMAX_DELAY);
181184
assert(result);
185+
static_cast<void>(result);
182186
}
183187
assert(g->pending && "tried to release a guard which wasn't acquired");
184188
g->pending = 0;
@@ -189,6 +193,7 @@ extern "C" void __cxa_guard_release(__guard* pg)
189193
signal_waiting_tasks();
190194
auto result = xSemaphoreGive(s_static_init_mutex);
191195
assert(result);
196+
static_cast<void>(result);
192197
}
193198
}
194199

@@ -199,6 +204,7 @@ extern "C" void __cxa_guard_abort(__guard* pg)
199204
if (scheduler_started) {
200205
auto result = xSemaphoreTake(s_static_init_mutex, portMAX_DELAY);
201206
assert(result);
207+
static_cast<void>(result);
202208
}
203209
assert(!g->ready && "tried to abort a guard which is ready");
204210
assert(g->pending && "tried to release a guard which is not acquired");
@@ -208,6 +214,7 @@ extern "C" void __cxa_guard_abort(__guard* pg)
208214
signal_waiting_tasks();
209215
auto result = xSemaphoreGive(s_static_init_mutex);
210216
assert(result);
217+
static_cast<void>(result);
211218
}
212219
}
213220

components/driver/sdio_slave.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ void sdio_slave_deinit(void)
375375
}
376376
esp_err_t ret = esp_intr_free(context.intr_handle);
377377
assert(ret==ESP_OK);
378+
(void)ret;
378379
context.intr_handle = NULL;
379380
deinit_context();
380381
}
@@ -532,7 +533,7 @@ static void sdio_intr_send(void* arg)
532533

533534
uint32_t returned_cnt;
534535
if (sdio_slave_hal_send_eof_happened(context.hal)) {
535-
portBASE_TYPE ret = pdTRUE;
536+
portBASE_TYPE ret __attribute__((unused));
536537

537538
esp_err_t err;
538539
while (1) {
@@ -549,7 +550,7 @@ static void sdio_intr_send(void* arg)
549550
}
550551
//get_next_finished_arg returns the total amount of returned descs.
551552
for(size_t i = 0; i < returned_cnt; i++) {
552-
portBASE_TYPE ret = xSemaphoreGiveFromISR(context.remain_cnt, &yield);
553+
ret = xSemaphoreGiveFromISR(context.remain_cnt, &yield);
553554
assert(ret == pdTRUE);
554555
}
555556
}
@@ -603,16 +604,17 @@ esp_err_t sdio_slave_transmit(uint8_t* addr, size_t len)
603604
static esp_err_t send_flush_data(void)
604605
{
605606
esp_err_t err;
607+
portBASE_TYPE ret __attribute__((unused));
606608

607609
while (1) {
608610
void *finished_arg;
609611
uint32_t return_cnt = 0;
610612
err = sdio_slave_hal_send_flush_next_buffer(context.hal, &finished_arg, &return_cnt);
611613
if (err == ESP_OK) {
612-
portBASE_TYPE ret = xQueueSend(context.ret_queue, &finished_arg, portMAX_DELAY);
614+
ret = xQueueSend(context.ret_queue, &finished_arg, portMAX_DELAY);
613615
assert(ret == pdTRUE);
614616
for (size_t i = 0; i < return_cnt; i++) {
615-
portBASE_TYPE ret = xSemaphoreGive(context.remain_cnt);
617+
ret = xSemaphoreGive(context.remain_cnt);
616618
assert(ret == pdTRUE);
617619
}
618620
} else {

0 commit comments

Comments
 (0)