CpuUid: buffer size assertion added

Added note in hal that a value higher than 0 is expected from the target implementation for the cpu_uid_get_length() function.

Added MBED_ASSERT for checking cpu_uid_get_length() return value in the driver.
pull/5557/head
Michael Kaplan 2017-11-24 11:05:28 +01:00
parent 3406ff262f
commit 6bdc29395d
2 changed files with 5 additions and 1 deletions

View File

@ -26,6 +26,7 @@ const char CpuUid::_hexChars[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8',
CpuUid::CpuUid() : _data(NULL)
{
_size = cpu_uid_get_length();
MBED_ASSERT(_size > 0);
if (0 < _size)
{
_data = new uint8_t[_size];

View File

@ -37,7 +37,10 @@ extern "C" {
*
* @return Number of uid bytes
*
* @note Shall be used to get the needed size of the byte buffer
* @note
* Shall be used by the driver to get the needed size of the byte buffer.
* Target implementation must return a value higher than 0 or the driver will assert.
*
*/
int cpu_uid_get_length(void);