From d4d33a1b6b5f9f83aff7cd4bd5eeca0a035a7505 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Mon, 8 Mar 2021 16:45:04 +0000 Subject: [PATCH] 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 --- library/mps_reader.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/mps_reader.c b/library/mps_reader.c index 097f2fe22..63a19543a 100644 --- a/library/mps_reader.c +++ b/library/mps_reader.c @@ -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",