Remove unnecessary check before calling memcpy()

This check was added earlier to avoid useless calls to `memcpy()`
with length `0` in the _frequent_ case where we're not accumulating.
By now, the whole code path has been moved to a branch which is only
executed if the reader is accumulating, and the only time this check
would be relevant is if we happen to feed an empty fragment to the
reader. In this case, the call to memcpy() could be removed, but
since this case is exceptional and the call to memcpy() is still
correct even for a length 0 copy, we remove the check for simplicity
of the code.

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
This commit is contained in:
Hanno Becker 2021-03-08 16:45:04 +00:00
parent 756abeb4e1
commit d4d33a1b6b

View file

@ -190,8 +190,7 @@ int mbedtls_mps_reader_feed( mbedtls_mps_reader *rd,
copy_to_acc = new_frag_len;
/* Copy new contents to accumulator. */
if( copy_to_acc > 0 )
memcpy( acc, new_frag, copy_to_acc );
memcpy( acc, new_frag, copy_to_acc );
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_comment,
"Copy new data of size %u of %u into accumulator at offset %u",