Skip to content

Commit 2978cd8

Browse files
author
Donatien Garnier
committed
Cordio: Make allocating too much memory for pool a warning, not a fatal assert
1 parent 101c569 commit 2978cd8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioBLE.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,14 @@ void BLE::stack_setup()
330330
buf_pool_desc.pool_count, buf_pool_desc.pool_description
331331
);
332332

333-
// This assert will fail if we've either allocated too much or too little memory
334-
// (bytes_used would be set to 0 in that case)
335-
MBED_ASSERT(bytes_used == buf_pool_desc.buffer_size);
333+
// Raise assert if not enough memory was allocated
334+
MBED_ASSERT(bytes_used != 0);
335+
336+
// This warning will be raised if we've allocated too much memory
337+
if(bytes_used < buf_pool_desc.buffer_size)
338+
{
339+
MBED_WARNING1(MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_INVALID_SIZE), "Too much memory allocated for Cordio memory pool, reduce buf_pool_desc.buffer_size by value below.", buf_pool_desc.buffer_size - bytes_used);
340+
}
336341

337342
WsfTimerInit();
338343
SecInit();

0 commit comments

Comments
 (0)