Rename variable to avoid a name clash

digits is also a local variable in host_test.function, leading to compilers
complaining about that shadowing the global variable in
test_suite_base64.function.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2021-08-06 16:54:22 +02:00
parent fd489f97c1
commit d3e5dd3f3a

View file

@ -4,7 +4,7 @@
#include <test/constant_flow.h> #include <test/constant_flow.h>
#if defined(MBEDTLS_TEST_HOOKS) #if defined(MBEDTLS_TEST_HOOKS)
static const char digits[] = static const char base64_digits[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
#endif /* MBEDTLS_TEST_HOOKS */ #endif /* MBEDTLS_TEST_HOOKS */
@ -45,7 +45,7 @@ void enc_chars( )
unsigned char digit = mbedtls_base64_enc_char( value ); unsigned char digit = mbedtls_base64_enc_char( value );
TEST_CF_PUBLIC( &value, sizeof( value ) ); TEST_CF_PUBLIC( &value, sizeof( value ) );
TEST_CF_PUBLIC( &digit, sizeof( digit ) ); TEST_CF_PUBLIC( &digit, sizeof( digit ) );
TEST_EQUAL( digit, digits[value] ); TEST_EQUAL( digit, base64_digits[value] );
} }
} }
/* END_CASE */ /* END_CASE */
@ -59,12 +59,12 @@ void dec_chars( )
for( unsigned c = 0; c <= 0xff; c++ ) for( unsigned c = 0; c <= 0xff; c++ )
{ {
mbedtls_test_set_step( c ); mbedtls_test_set_step( c );
/* digits is 0-terminated. sizeof()-1 excludes the trailing 0. */ /* base64_digits is 0-terminated. sizeof()-1 excludes the trailing 0. */
p = memchr( digits, c, sizeof( digits ) - 1 ); p = memchr( base64_digits, c, sizeof( base64_digits ) - 1 );
if( p == NULL ) if( p == NULL )
expected = -1; expected = -1;
else else
expected = p - digits; expected = p - base64_digits;
TEST_CF_SECRET( &c, sizeof( c ) ); TEST_CF_SECRET( &c, sizeof( c ) );
signed char actual = mbedtls_base64_dec_value( c ); signed char actual = mbedtls_base64_dec_value( c );
TEST_CF_PUBLIC( &c, sizeof( c ) ); TEST_CF_PUBLIC( &c, sizeof( c ) );