mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 11:55:42 +01:00
Fix -Wshadow warnings
Checked that it is supported by gcc 4.2.1 (FreeBSD 9). fixes #240
This commit is contained in:
parent
4d04cdcd12
commit
ea35666f50
@ -25,7 +25,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
|
||||
# note: starting with CMake 2.8 we could use CMAKE_C_COMPILER_VERSION
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
|
||||
OUTPUT_VARIABLE GCC_VERSION)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -W -Wdeclaration-after-statement -Wwrite-strings")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -W -Wdeclaration-after-statement -Wwrite-strings -Wshadow")
|
||||
if (GCC_VERSION VERSION_GREATER 4.5 OR GCC_VERSION VERSION_EQUAL 4.5)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wlogical-op")
|
||||
endif()
|
||||
@ -39,7 +39,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
|
||||
endif(CMAKE_COMPILER_IS_GNUCC)
|
||||
|
||||
if(CMAKE_COMPILER_IS_CLANG)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -W -Wdeclaration-after-statement -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -W -Wdeclaration-after-statement -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O2")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-O0 -g3")
|
||||
set(CMAKE_C_FLAGS_COVERAGE "-O0 -g3 --coverage")
|
||||
|
@ -29,6 +29,7 @@ Bugfix
|
||||
* Fix bug in mbedtls_rsa_public() and mbedtls_rsa_private() that could
|
||||
result trying to unlock an unlocked mutex on invalid input (found by
|
||||
Fredrik Axelsson) (#257)
|
||||
* Fix -Wshadow warnings (found by hnrkp) (#240)
|
||||
|
||||
Changes
|
||||
* The PEM parser now accepts a trailing space at end of lines (#226).
|
||||
|
@ -140,7 +140,7 @@ int mbedtls_platform_entropy_poll( void *data,
|
||||
unsigned char *output, size_t len, size_t *olen )
|
||||
{
|
||||
FILE *file;
|
||||
size_t ret;
|
||||
size_t read_len;
|
||||
((void) data);
|
||||
|
||||
#if defined(HAVE_GETRANDOM)
|
||||
@ -165,8 +165,8 @@ int mbedtls_platform_entropy_poll( void *data,
|
||||
if( file == NULL )
|
||||
return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
|
||||
|
||||
ret = fread( output, 1, len, file );
|
||||
if( ret != len )
|
||||
read_len = fread( output, 1, len, file );
|
||||
if( read_len != len )
|
||||
{
|
||||
fclose( file );
|
||||
return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
|
||||
|
@ -694,8 +694,6 @@ int mbedtls_ssl_derive_keys( mbedtls_ssl_context *ssl )
|
||||
}
|
||||
else
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Initialize HMAC contexts */
|
||||
if( ( ret = mbedtls_md_setup( &transform->md_ctx_enc, md_info, 1 ) ) != 0 ||
|
||||
( ret = mbedtls_md_setup( &transform->md_ctx_dec, md_info, 1 ) ) != 0 )
|
||||
@ -1455,7 +1453,7 @@ static int ssl_encrypt_buf( mbedtls_ssl_context *ssl )
|
||||
/*
|
||||
* Generate IV
|
||||
*/
|
||||
int ret = ssl->conf->f_rng( ssl->conf->p_rng, ssl->transform_out->iv_enc,
|
||||
ret = ssl->conf->f_rng( ssl->conf->p_rng, ssl->transform_out->iv_enc,
|
||||
ssl->transform_out->ivlen );
|
||||
if( ret != 0 )
|
||||
return( ret );
|
||||
|
@ -1925,7 +1925,7 @@ reset:
|
||||
if( ret == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED )
|
||||
{
|
||||
char vrfy_buf[512];
|
||||
uint32_t flags = mbedtls_ssl_get_verify_result( &ssl );
|
||||
flags = mbedtls_ssl_get_verify_result( &ssl );
|
||||
|
||||
mbedtls_x509_crt_verify_info( vrfy_buf, sizeof( vrfy_buf ), " ! ", flags );
|
||||
|
||||
|
@ -108,31 +108,31 @@ int main( void )
|
||||
|
||||
#define TIME_AND_TSC( TITLE, CODE ) \
|
||||
do { \
|
||||
unsigned long i, j, tsc; \
|
||||
unsigned long ii, jj, tsc; \
|
||||
\
|
||||
mbedtls_printf( HEADER_FORMAT, TITLE ); \
|
||||
mbedtls_printf( HEADER_FORMAT, TITLE ); \
|
||||
fflush( stdout ); \
|
||||
\
|
||||
mbedtls_set_alarm( 1 ); \
|
||||
for( i = 1; ! mbedtls_timing_alarmed; i++ ) \
|
||||
mbedtls_set_alarm( 1 ); \
|
||||
for( ii = 1; ! mbedtls_timing_alarmed; ii++ ) \
|
||||
{ \
|
||||
CODE; \
|
||||
} \
|
||||
\
|
||||
tsc = mbedtls_timing_hardclock(); \
|
||||
for( j = 0; j < 1024; j++ ) \
|
||||
tsc = mbedtls_timing_hardclock(); \
|
||||
for( jj = 0; jj < 1024; jj++ ) \
|
||||
{ \
|
||||
CODE; \
|
||||
} \
|
||||
\
|
||||
mbedtls_printf( "%9lu Kb/s, %9lu cycles/byte\n", \
|
||||
i * BUFSIZE / 1024, \
|
||||
( mbedtls_timing_hardclock() - tsc ) / ( j * BUFSIZE ) ); \
|
||||
mbedtls_printf( "%9lu Kb/s, %9lu cycles/byte\n", \
|
||||
ii * BUFSIZE / 1024, \
|
||||
( mbedtls_timing_hardclock() - tsc ) / ( jj * BUFSIZE ) ); \
|
||||
} while( 0 )
|
||||
|
||||
#if defined(MBEDTLS_ERROR_C)
|
||||
#define PRINT_ERROR \
|
||||
mbedtls_strerror( ret, ( char * )tmp, sizeof( tmp ) ); \
|
||||
mbedtls_strerror( ret, ( char * )tmp, sizeof( tmp ) ); \
|
||||
mbedtls_printf( "FAILED: %s\n", tmp );
|
||||
#else
|
||||
#define PRINT_ERROR \
|
||||
@ -144,12 +144,12 @@ do { \
|
||||
#define MEMORY_MEASURE_INIT \
|
||||
size_t max_used, max_blocks, max_bytes; \
|
||||
size_t prv_used, prv_blocks; \
|
||||
mbedtls_memory_buffer_alloc_cur_get( &prv_used, &prv_blocks ); \
|
||||
mbedtls_memory_buffer_alloc_cur_get( &prv_used, &prv_blocks ); \
|
||||
mbedtls_memory_buffer_alloc_max_reset( );
|
||||
|
||||
#define MEMORY_MEASURE_PRINT( title_len ) \
|
||||
mbedtls_memory_buffer_alloc_max_get( &max_used, &max_blocks ); \
|
||||
for( i = 12 - title_len; i != 0; i-- ) mbedtls_printf( " " ); \
|
||||
mbedtls_memory_buffer_alloc_max_get( &max_used, &max_blocks ); \
|
||||
for( ii = 12 - title_len; ii != 0; ii-- ) mbedtls_printf( " " ); \
|
||||
max_used -= prv_used; \
|
||||
max_blocks -= prv_blocks; \
|
||||
max_bytes = max_used + MEM_BLOCK_OVERHEAD * max_blocks; \
|
||||
@ -162,16 +162,16 @@ do { \
|
||||
|
||||
#define TIME_PUBLIC( TITLE, TYPE, CODE ) \
|
||||
do { \
|
||||
unsigned long i; \
|
||||
unsigned long ii; \
|
||||
int ret; \
|
||||
MEMORY_MEASURE_INIT; \
|
||||
\
|
||||
mbedtls_printf( HEADER_FORMAT, TITLE ); \
|
||||
mbedtls_printf( HEADER_FORMAT, TITLE ); \
|
||||
fflush( stdout ); \
|
||||
mbedtls_set_alarm( 3 ); \
|
||||
mbedtls_set_alarm( 3 ); \
|
||||
\
|
||||
ret = 0; \
|
||||
for( i = 1; ! mbedtls_timing_alarmed && ! ret ; i++ ) \
|
||||
for( ii = 1; ! mbedtls_timing_alarmed && ! ret ; ii++ ) \
|
||||
{ \
|
||||
CODE; \
|
||||
} \
|
||||
@ -182,9 +182,9 @@ do { \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
mbedtls_printf( "%6lu " TYPE "/s", i / 3 ); \
|
||||
mbedtls_printf( "%6lu " TYPE "/s", ii / 3 ); \
|
||||
MEMORY_MEASURE_PRINT( sizeof( TYPE ) + 1 ); \
|
||||
mbedtls_printf( "\n" ); \
|
||||
mbedtls_printf( "\n" ); \
|
||||
} \
|
||||
} while( 0 )
|
||||
|
||||
|
@ -389,7 +389,7 @@ void update_dropped( const packet *p )
|
||||
|
||||
while( cur < end )
|
||||
{
|
||||
size_t len = ( ( cur[11] << 8 ) | cur[12] ) + 13;
|
||||
len = ( ( cur[11] << 8 ) | cur[12] ) + 13;
|
||||
|
||||
id = len % sizeof( dropped );
|
||||
++dropped[id];
|
||||
|
Loading…
Reference in New Issue
Block a user