Use size_t instead of int for index in buffer loops in MPS unit test

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
This commit is contained in:
Hanno Becker 2021-02-22 16:50:01 +00:00
parent 8a04b10ed8
commit b17212a8bf

View file

@ -40,7 +40,7 @@ void mbedtls_mps_reader_no_pausing_single_step_single_round( int with_acc )
unsigned char acc[10]; unsigned char acc[10];
unsigned char *tmp; unsigned char *tmp;
mbedtls_mps_reader rd; mbedtls_mps_reader rd;
for( int i=0; (unsigned) i < sizeof( bufA ); i++ ) for( size_t i=0; (unsigned) i < sizeof( bufA ); i++ )
bufA[i] = (unsigned char) i; bufA[i] = (unsigned char) i;
/* Preparation (lower layer) */ /* Preparation (lower layer) */
@ -82,9 +82,9 @@ void mbedtls_mps_reader_no_pausing_single_step_multiple_rounds( int with_acc )
unsigned char acc[10]; unsigned char acc[10];
unsigned char *tmp; unsigned char *tmp;
mbedtls_mps_reader rd; mbedtls_mps_reader rd;
for( int i=0; (unsigned) i < sizeof( bufA ); i++ ) for( size_t i=0; (unsigned) i < sizeof( bufA ); i++ )
bufA[i] = (unsigned char) i; bufA[i] = (unsigned char) i;
for( int i=0; (unsigned) i < sizeof( bufB ); i++ ) for( size_t i=0; (unsigned) i < sizeof( bufB ); i++ )
bufB[i] = ~ ((unsigned char) i); bufB[i] = ~ ((unsigned char) i);
/* Preparation (lower layer) */ /* Preparation (lower layer) */
@ -137,7 +137,7 @@ void mbedtls_mps_reader_no_pausing_multiple_steps_single_round( int with_acc )
unsigned char *tmp; unsigned char *tmp;
mbedtls_mps_size_t tmp_len; mbedtls_mps_size_t tmp_len;
mbedtls_mps_reader rd; mbedtls_mps_reader rd;
for( int i=0; (unsigned) i < sizeof( buf ); i++ ) for( size_t i=0; (unsigned) i < sizeof( buf ); i++ )
buf[i] = (unsigned char) i; buf[i] = (unsigned char) i;
/* Preparation (lower layer) */ /* Preparation (lower layer) */
@ -172,9 +172,9 @@ void mbedtls_mps_reader_no_pausing_multiple_steps_multiple_rounds( int with_acc
unsigned char *tmp; unsigned char *tmp;
mbedtls_mps_size_t tmp_len; mbedtls_mps_size_t tmp_len;
mbedtls_mps_reader rd; mbedtls_mps_reader rd;
for( int i=0; (unsigned) i < sizeof( bufA ); i++ ) for( size_t i=0; (unsigned) i < sizeof( bufA ); i++ )
bufA[i] = (unsigned char) i; bufA[i] = (unsigned char) i;
for( int i=0; (unsigned) i < sizeof( bufB ); i++ ) for( size_t i=0; (unsigned) i < sizeof( bufB ); i++ )
bufB[i] = ~ ((unsigned char) i); bufB[i] = ~ ((unsigned char) i);
/* Preparation (lower layer) */ /* Preparation (lower layer) */
@ -217,7 +217,7 @@ void mbedtls_mps_reader_pausing_needed_disabled()
unsigned char buf[100]; unsigned char buf[100];
unsigned char *tmp; unsigned char *tmp;
mbedtls_mps_reader rd; mbedtls_mps_reader rd;
for( int i=0; (unsigned) i < sizeof( buf ); i++ ) for( size_t i=0; (unsigned) i < sizeof( buf ); i++ )
buf[i] = (unsigned char) i; buf[i] = (unsigned char) i;
/* Preparation (lower layer) */ /* Preparation (lower layer) */
@ -257,7 +257,7 @@ void mbedtls_mps_reader_pausing_needed_buffer_too_small()
mbedtls_mps_reader rd; mbedtls_mps_reader rd;
mbedtls_mps_size_t tmp_len; mbedtls_mps_size_t tmp_len;
for( int i=0; (unsigned) i < sizeof( buf ); i++ ) for( size_t i=0; (unsigned) i < sizeof( buf ); i++ )
buf[i] = (unsigned char) i; buf[i] = (unsigned char) i;
/* Preparation (lower layer) */ /* Preparation (lower layer) */
@ -306,9 +306,9 @@ void mbedtls_mps_reader_pausing( int option )
unsigned char *tmp; unsigned char *tmp;
unsigned char acc[40]; unsigned char acc[40];
mbedtls_mps_reader rd; mbedtls_mps_reader rd;
for( int i=0; (unsigned) i < sizeof( bufA ); i++ ) for( size_t i=0; (unsigned) i < sizeof( bufA ); i++ )
bufA[i] = (unsigned char) i; bufA[i] = (unsigned char) i;
for( int i=0; (unsigned) i < sizeof( bufB ); i++ ) for( size_t i=0; (unsigned) i < sizeof( bufB ); i++ )
bufB[i] = ~ ((unsigned char) i); bufB[i] = ~ ((unsigned char) i);
/* Preparation (lower layer) */ /* Preparation (lower layer) */
@ -427,9 +427,9 @@ void mbedtls_mps_reader_pausing_multiple_feeds( int option )
unsigned char acc[70]; unsigned char acc[70];
mbedtls_mps_reader rd; mbedtls_mps_reader rd;
mbedtls_mps_size_t fetch_len; mbedtls_mps_size_t fetch_len;
for( int i=0; (unsigned) i < sizeof( bufA ); i++ ) for( size_t i=0; (unsigned) i < sizeof( bufA ); i++ )
bufA[i] = (unsigned char) i; bufA[i] = (unsigned char) i;
for( int i=0; (unsigned) i < sizeof( bufB ); i++ ) for( size_t i=0; (unsigned) i < sizeof( bufB ); i++ )
bufB[i] = ~ ((unsigned char) i); bufB[i] = ~ ((unsigned char) i);
/* Preparation (lower layer) */ /* Preparation (lower layer) */
@ -458,7 +458,7 @@ void mbedtls_mps_reader_pausing_multiple_feeds( int option )
break; break;
case 1: /* 50 x 1byte */ case 1: /* 50 x 1byte */
for( int num_feed=0; num_feed<49; num_feed++ ) for( size_t num_feed=0; num_feed<49; num_feed++ )
{ {
TEST_ASSERT( mbedtls_mps_reader_feed( &rd, bufB + num_feed, 1 ) == TEST_ASSERT( mbedtls_mps_reader_feed( &rd, bufB + num_feed, 1 ) ==
MBEDTLS_ERR_MPS_READER_NEED_MORE ); MBEDTLS_ERR_MPS_READER_NEED_MORE );
@ -467,7 +467,7 @@ void mbedtls_mps_reader_pausing_multiple_feeds( int option )
break; break;
case 2: /* 49 x 1byte + 51bytes */ case 2: /* 49 x 1byte + 51bytes */
for( int num_feed=0; num_feed<49; num_feed++ ) for( size_t num_feed=0; num_feed<49; num_feed++ )
{ {
TEST_ASSERT( mbedtls_mps_reader_feed( &rd, bufB + num_feed, 1 ) == TEST_ASSERT( mbedtls_mps_reader_feed( &rd, bufB + num_feed, 1 ) ==
MBEDTLS_ERR_MPS_READER_NEED_MORE ); MBEDTLS_ERR_MPS_READER_NEED_MORE );
@ -522,7 +522,7 @@ void mbedtls_mps_reader_reclaim_data_left( int option )
unsigned char buf[100]; unsigned char buf[100];
unsigned char *tmp; unsigned char *tmp;
mbedtls_mps_reader rd; mbedtls_mps_reader rd;
for( int i=0; (unsigned) i < sizeof( buf ); i++ ) for( size_t i=0; (unsigned) i < sizeof( buf ); i++ )
buf[i] = (unsigned char) i; buf[i] = (unsigned char) i;
/* Preparation (lower layer) */ /* Preparation (lower layer) */
@ -582,7 +582,7 @@ void mbedtls_mps_reader_reclaim_data_left_retry()
unsigned char *tmp; unsigned char *tmp;
mbedtls_mps_reader rd; mbedtls_mps_reader rd;
for( int i=0; (unsigned) i < sizeof( buf ); i++ ) for( size_t i=0; (unsigned) i < sizeof( buf ); i++ )
buf[i] = (unsigned char) i; buf[i] = (unsigned char) i;
/* Preparation (lower layer) */ /* Preparation (lower layer) */
@ -626,11 +626,11 @@ void mbedtls_mps_reader_multiple_pausing( int option )
unsigned char acc[50]; unsigned char acc[50];
mbedtls_mps_size_t tmp_len; mbedtls_mps_size_t tmp_len;
mbedtls_mps_reader rd; mbedtls_mps_reader rd;
for( int i=0; (unsigned) i < sizeof( bufA ); i++ ) for( size_t i=0; (unsigned) i < sizeof( bufA ); i++ )
bufA[i] = (unsigned char) i; bufA[i] = (unsigned char) i;
for( int i=0; (unsigned) i < sizeof( bufB ); i++ ) for( size_t i=0; (unsigned) i < sizeof( bufB ); i++ )
bufB[i] = ~ ((unsigned char) i); bufB[i] = ~ ((unsigned char) i);
for( int i=0; (unsigned) i < sizeof( bufC ); i++ ) for( size_t i=0; (unsigned) i < sizeof( bufC ); i++ )
bufC[i] = ~ ((unsigned char) i); bufC[i] = ~ ((unsigned char) i);
/* Preparation (lower layer) */ /* Preparation (lower layer) */
@ -945,9 +945,9 @@ void mbedtls_reader_inconsistent_usage( int option )
unsigned char acc[40]; unsigned char acc[40];
mbedtls_mps_reader rd; mbedtls_mps_reader rd;
int success = 0; int success = 0;
for( int i=0; (unsigned) i < sizeof( bufA ); i++ ) for( size_t i=0; (unsigned) i < sizeof( bufA ); i++ )
bufA[i] = (unsigned char) i; bufA[i] = (unsigned char) i;
for( int i=0; (unsigned) i < sizeof( bufB ); i++ ) for( size_t i=0; (unsigned) i < sizeof( bufB ); i++ )
bufB[i] = ~ ((unsigned char) i); bufB[i] = ~ ((unsigned char) i);
/* Preparation (lower layer) */ /* Preparation (lower layer) */
@ -1080,7 +1080,7 @@ void mbedtls_mps_reader_feed_empty( int option )
unsigned char buf[100]; unsigned char buf[100];
unsigned char *tmp; unsigned char *tmp;
mbedtls_mps_reader rd; mbedtls_mps_reader rd;
for( int i=0; (unsigned) i < sizeof( buf ); i++ ) for( size_t i=0; (unsigned) i < sizeof( buf ); i++ )
buf[i] = (unsigned char) i; buf[i] = (unsigned char) i;
/* Preparation (lower layer) */ /* Preparation (lower layer) */