mirror of https://github.com/ARMmbed/mbed-os.git
HAL CRC: Return early when calling compute with null or 0 size buffer
parent
df93c0151c
commit
167d3f9a1e
|
@ -114,6 +114,9 @@ void hal_crc_compute_partial_start(const uint32_t polynomial);
|
|||
* To obtain the final result of the CRC calculation hal_crc_get_result() is
|
||||
* called to apply the final transformations to the data.
|
||||
*
|
||||
* If the function is passed an undefined pointer, or the size of the buffer is
|
||||
* specified to be 0, this function will do nothing and return.
|
||||
*
|
||||
* This function can be call multiple times in succession, this can be used
|
||||
* to calculate the CRC result of streamed data.
|
||||
*
|
||||
|
|
|
@ -73,7 +73,8 @@ void hal_crc_compute_partial_start(const uint32_t polynomial)
|
|||
}
|
||||
default:
|
||||
MBED_ASSERT("Configuring Mbed CRC with unsupported polynomial");
|
||||
break;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
CRC_Init(CRC0, &config);
|
||||
|
@ -81,6 +82,12 @@ void hal_crc_compute_partial_start(const uint32_t polynomial)
|
|||
|
||||
void hal_crc_compute_partial(const uint8_t *data, const size_t size)
|
||||
{
|
||||
if (data == NULL)
|
||||
return;
|
||||
|
||||
if (size == 0)
|
||||
return;
|
||||
|
||||
CRC_WriteData(CRC0, data, size);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue