Merge pull request #3153 from kennethsoerensen/format-signedness

Fix GCC format-signedness warnings
This commit is contained in:
danh-arm 2020-04-23 11:00:45 +01:00 committed by GitHub
commit 494f6cb823
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 160 additions and 157 deletions

View file

@ -135,7 +135,7 @@ if(CMAKE_COMPILER_IS_GNU)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wlogical-op")
endif()
if (GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow -Wformat-signedness")
endif()
set(CMAKE_C_FLAGS_RELEASE "-O2")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g3")

View file

@ -0,0 +1,3 @@
Changes
* Fix warnings about signedness issues in format strings. The build is now
clean of -Wformat-signedness warnings. Contributed by Kenneth Soerensen in #3153.

View file

@ -1847,7 +1847,7 @@ int mbedtls_aes_self_test( int verbose )
mode = i & 1;
if( verbose != 0 )
mbedtls_printf( " AES-ECB-%3d (%s): ", keybits,
mbedtls_printf( " AES-ECB-%3u (%s): ", keybits,
( mode == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" );
memset( buf, 0, 16 );
@ -1909,7 +1909,7 @@ int mbedtls_aes_self_test( int verbose )
mode = i & 1;
if( verbose != 0 )
mbedtls_printf( " AES-CBC-%3d (%s): ", keybits,
mbedtls_printf( " AES-CBC-%3u (%s): ", keybits,
( mode == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" );
memset( iv , 0, 16 );
@ -1984,7 +1984,7 @@ int mbedtls_aes_self_test( int verbose )
mode = i & 1;
if( verbose != 0 )
mbedtls_printf( " AES-CFB128-%3d (%s): ", keybits,
mbedtls_printf( " AES-CFB128-%3u (%s): ", keybits,
( mode == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" );
memcpy( iv, aes_test_cfb128_iv, 16 );
@ -2047,7 +2047,7 @@ int mbedtls_aes_self_test( int verbose )
mode = i & 1;
if( verbose != 0 )
mbedtls_printf( " AES-OFB-%3d (%s): ", keybits,
mbedtls_printf( " AES-OFB-%3u (%s): ", keybits,
( mode == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" );
memcpy( iv, aes_test_ofb_iv, 16 );

View file

@ -2938,7 +2938,7 @@ int mbedtls_mpi_self_test( int verbose )
cleanup:
if( ret != 0 && verbose != 0 )
mbedtls_printf( "Unexpected error, return code = %08X\n", ret );
mbedtls_printf( "Unexpected error, return code = %08X\n", (unsigned int) ret );
mbedtls_mpi_free( &A ); mbedtls_mpi_free( &E ); mbedtls_mpi_free( &N ); mbedtls_mpi_free( &X );
mbedtls_mpi_free( &Y ); mbedtls_mpi_free( &U ); mbedtls_mpi_free( &V );

View file

@ -784,7 +784,7 @@ static int cmac_test_subkeys( int verbose,
for( i = 0; i < num_tests; i++ )
{
if( verbose != 0 )
mbedtls_printf( " %s CMAC subkey #%u: ", testname, i + 1 );
mbedtls_printf( " %s CMAC subkey #%d: ", testname, i + 1 );
mbedtls_cipher_init( &ctx );
@ -865,7 +865,7 @@ static int cmac_test_wth_cipher( int verbose,
for( i = 0; i < num_tests; i++ )
{
if( verbose != 0 )
mbedtls_printf( " %s CMAC #%u: ", testname, i + 1 );
mbedtls_printf( " %s CMAC #%d: ", testname, i + 1 );
if( ( ret = mbedtls_cipher_cmac( cipher_info, key, keybits, messages,
message_lengths[i], output ) ) != 0 )
@ -900,7 +900,7 @@ static int test_aes128_cmac_prf( int verbose )
for( i = 0; i < NB_PRF_TESTS; i++ )
{
mbedtls_printf( " AES CMAC 128 PRF #%u: ", i );
mbedtls_printf( " AES CMAC 128 PRF #%d: ", i );
ret = mbedtls_aes_cmac_prf_128( PRFK, PRFKlen[i], PRFM, 20, output );
if( ret != 0 ||
memcmp( output, PRFT[i], MBEDTLS_AES_BLOCK_SIZE ) != 0 )

View file

@ -132,7 +132,7 @@ void mbedtls_debug_print_ret( const mbedtls_ssl_context *ssl, int level,
return;
mbedtls_snprintf( str, sizeof( str ), "%s() returned %d (-0x%04x)\n",
text, ret, -ret );
text, ret, (unsigned int) -ret );
debug_send_line( ssl, level, file, line, str );
}

View file

@ -3156,7 +3156,7 @@ int mbedtls_ecp_self_test( int verbose )
cleanup:
if( ret < 0 && verbose != 0 )
mbedtls_printf( "Unexpected error, return code = %08X\n", ret );
mbedtls_printf( "Unexpected error, return code = %08X\n", (unsigned int) ret );
mbedtls_ecp_group_free( &grp );
mbedtls_ecp_point_free( &R );

View file

@ -1171,7 +1171,7 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen )
high_level_error_description = mbedtls_high_level_strerr( ret );
if( high_level_error_description == NULL )
mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret );
mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", (unsigned int) use_ret );
else
mbedtls_snprintf( buf, buflen, "%s", high_level_error_description );
@ -1208,7 +1208,7 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen )
low_level_error_description = mbedtls_low_level_strerr( ret );
if( low_level_error_description == NULL )
mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret );
mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", (unsigned int) use_ret );
else
mbedtls_snprintf( buf, buflen, "%s", low_level_error_description );
}

View file

@ -761,7 +761,7 @@ int mbedtls_oid_get_numeric_string( char *buf, size_t size,
if( !( oid->p[i] & 0x80 ) )
{
/* Last byte */
ret = mbedtls_snprintf( p, n, ".%d", value );
ret = mbedtls_snprintf( p, n, ".%u", value );
OID_SAFE_SNPRINTF;
value = 0;
}

View file

@ -870,7 +870,7 @@ int mbedtls_x509_sig_alg_gets( char *buf, size_t size, const mbedtls_x509_buf *s
ret = mbedtls_snprintf( p, n, " (%s, MGF1-%s, 0x%02X)",
md_info ? mbedtls_md_get_name( md_info ) : "???",
mgf_md_info ? mbedtls_md_get_name( mgf_md_info ) : "???",
pss_opts->expected_salt_len );
(unsigned int) pss_opts->expected_salt_len );
MBEDTLS_X509_SAFE_SNPRINTF;
}
#else

View file

@ -118,7 +118,7 @@ int main( int argc, char *argv[] )
ret = mbedtls_md_setup( &sha_ctx, mbedtls_md_info_from_type( MBEDTLS_MD_SHA256 ), 1 );
if( ret != 0 )
{
mbedtls_printf( " ! mbedtls_md_setup() returned -0x%04x\n", -ret );
mbedtls_printf( " ! mbedtls_md_setup() returned -0x%04x\n", (unsigned int) -ret );
goto exit;
}
@ -298,7 +298,7 @@ int main( int argc, char *argv[] )
if( fread( buffer, 1, n, fin ) != (size_t) n )
{
mbedtls_fprintf( stderr, "fread(%d bytes) failed\n", n );
mbedtls_fprintf( stderr, "fread(%u bytes) failed\n", n );
goto exit;
}
@ -413,7 +413,7 @@ int main( int argc, char *argv[] )
if( fwrite( buffer, 1, n, fout ) != (size_t) n )
{
mbedtls_fprintf( stderr, "fwrite(%d bytes) failed\n", n );
mbedtls_fprintf( stderr, "fwrite(%u bytes) failed\n", n );
goto exit;
}
}

View file

@ -219,7 +219,7 @@ int main( int argc, char *argv[] )
p = &argv[6][4];
keylen = 0;
while( sscanf( p, "%02X", &n ) > 0 &&
while( sscanf( p, "%02X", (unsigned int*) &n ) > 0 &&
keylen < (int) sizeof( key ) )
{
key[keylen++] = (unsigned char) n;
@ -417,7 +417,7 @@ int main( int argc, char *argv[] )
( ( filesize - mbedtls_md_get_size( md_info ) ) %
mbedtls_cipher_get_block_size( &cipher_ctx ) ) != 0 )
{
mbedtls_fprintf( stderr, "File content not a multiple of the block size (%d).\n",
mbedtls_fprintf( stderr, "File content not a multiple of the block size (%u).\n",
mbedtls_cipher_get_block_size( &cipher_ctx ));
goto exit;
}
@ -484,7 +484,7 @@ int main( int argc, char *argv[] )
if( fread( buffer, 1, ilen, fin ) != ilen )
{
mbedtls_fprintf( stderr, "fread(%d bytes) failed\n",
mbedtls_fprintf( stderr, "fread(%u bytes) failed\n",
mbedtls_cipher_get_block_size( &cipher_ctx ) );
goto exit;
}

View file

@ -302,7 +302,7 @@ int main( int argc, char *argv[] )
NULL, DEV_RANDOM_THRESHOLD,
MBEDTLS_ENTROPY_SOURCE_STRONG ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_entropy_add_source returned -0x%04x\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_entropy_add_source returned -0x%04x\n", (unsigned int) -ret );
goto exit;
}
@ -315,7 +315,7 @@ int main( int argc, char *argv[] )
(const unsigned char *) pers,
strlen( pers ) ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%04x\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%04x\n", (unsigned int) -ret );
goto exit;
}
@ -328,7 +328,7 @@ int main( int argc, char *argv[] )
if( ( ret = mbedtls_pk_setup( &key,
mbedtls_pk_info_from_type( (mbedtls_pk_type_t) opt.type ) ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_pk_setup returned -0x%04x", -ret );
mbedtls_printf( " failed\n ! mbedtls_pk_setup returned -0x%04x", (unsigned int) -ret );
goto exit;
}
@ -339,7 +339,7 @@ int main( int argc, char *argv[] )
opt.rsa_keysize, 65537 );
if( ret != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_rsa_gen_key returned -0x%04x", -ret );
mbedtls_printf( " failed\n ! mbedtls_rsa_gen_key returned -0x%04x", (unsigned int) -ret );
goto exit;
}
}
@ -353,7 +353,7 @@ int main( int argc, char *argv[] )
mbedtls_ctr_drbg_random, &ctr_drbg );
if( ret != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ecp_gen_key returned -0x%04x", -ret );
mbedtls_printf( " failed\n ! mbedtls_ecp_gen_key returned -0x%04x", (unsigned int) -ret );
goto exit;
}
}

View file

@ -187,7 +187,7 @@ int main( int argc, char *argv[] )
if( ret != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%04x\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%04x\n", (unsigned int) -ret );
goto cleanup;
}
@ -248,7 +248,7 @@ int main( int argc, char *argv[] )
if( ret != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_pk_parse_public_keyfile returned -0x%04x\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_pk_parse_public_keyfile returned -0x%04x\n", (unsigned int) -ret );
goto cleanup;
}

View file

@ -299,7 +299,7 @@ int main( int argc, char *argv[] )
if( ret != 0 )
{
mbedtls_strerror( ret, (char *) buf, sizeof(buf) );
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%04x - %s\n\n", -ret, buf );
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
goto exit;
}
@ -360,7 +360,7 @@ int main( int argc, char *argv[] )
if( ret != 0 )
{
mbedtls_strerror( ret, (char *) buf, sizeof(buf) );
mbedtls_printf( " failed\n ! mbedtls_pk_parse_public_key returned -0x%04x - %s\n\n", -ret, buf );
mbedtls_printf( " failed\n ! mbedtls_pk_parse_public_key returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
goto exit;
}

View file

@ -100,7 +100,7 @@ int main( int argc, char *argv[] )
strlen( pers ) ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%04x\n",
-ret );
(unsigned int) -ret );
goto exit;
}
@ -109,7 +109,7 @@ int main( int argc, char *argv[] )
if( ( ret = mbedtls_pk_parse_keyfile( &pk, argv[1], "" ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%04x\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%04x\n", (unsigned int) -ret );
goto exit;
}
@ -124,7 +124,7 @@ int main( int argc, char *argv[] )
}
i = 0;
while( fscanf( f, "%02X", &c ) > 0 &&
while( fscanf( f, "%02X", (unsigned int*) &c ) > 0 &&
i < (int) sizeof( buf ) )
{
buf[i++] = (unsigned char) c;
@ -142,7 +142,7 @@ int main( int argc, char *argv[] )
mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_pk_decrypt returned -0x%04x\n",
-ret );
(unsigned int) -ret );
goto exit;
}

View file

@ -98,7 +98,7 @@ int main( int argc, char *argv[] )
strlen( pers ) ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%04x\n",
-ret );
(unsigned int) -ret );
goto exit;
}
@ -107,7 +107,7 @@ int main( int argc, char *argv[] )
if( ( ret = mbedtls_pk_parse_public_keyfile( &pk, argv[1] ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_pk_parse_public_keyfile returned -0x%04x\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_pk_parse_public_keyfile returned -0x%04x\n", (unsigned int) -ret );
goto exit;
}
@ -130,7 +130,7 @@ int main( int argc, char *argv[] )
mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_pk_encrypt returned -0x%04x\n",
-ret );
(unsigned int) -ret );
goto exit;
}

View file

@ -96,7 +96,7 @@ int main( int argc, char *argv[] )
(const unsigned char *) pers,
strlen( pers ) ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%04x\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%04x\n", (unsigned int) -ret );
goto exit;
}
@ -127,7 +127,7 @@ int main( int argc, char *argv[] )
if( ( ret = mbedtls_pk_sign( &pk, MBEDTLS_MD_SHA256, hash, 0, buf, &olen,
mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_pk_sign returned -0x%04x\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_pk_sign returned -0x%04x\n", (unsigned int) -ret );
goto exit;
}

View file

@ -86,7 +86,7 @@ int main( int argc, char *argv[] )
if( ( ret = mbedtls_pk_parse_public_keyfile( &pk, argv[1] ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_pk_parse_public_keyfile returned -0x%04x\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_pk_parse_public_keyfile returned -0x%04x\n", (unsigned int) -ret );
goto exit;
}
@ -123,7 +123,7 @@ int main( int argc, char *argv[] )
if( ( ret = mbedtls_pk_verify( &pk, MBEDTLS_MD_SHA256, hash, 0,
buf, i ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_pk_verify returned -0x%04x\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_pk_verify returned -0x%04x\n", (unsigned int) -ret );
goto exit;
}

View file

@ -160,7 +160,7 @@ int main( int argc, char *argv[] )
i = 0;
while( fscanf( f, "%02X", &c ) > 0 &&
while( fscanf( f, "%02X", (unsigned int*) &c ) > 0 &&
i < (int) sizeof( buf ) )
buf[i++] = (unsigned char) c;

View file

@ -129,7 +129,7 @@ int main( int argc, char *argv[] )
fflush( stdout );
if( ( ret = mbedtls_rsa_check_privkey( &rsa ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_rsa_check_privkey failed with -0x%0x\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_rsa_check_privkey failed with -0x%0x\n", (unsigned int) -ret );
goto exit;
}
@ -151,7 +151,7 @@ int main( int argc, char *argv[] )
if( ( ret = mbedtls_rsa_pkcs1_sign( &rsa, NULL, NULL, MBEDTLS_RSA_PRIVATE, MBEDTLS_MD_SHA256,
20, hash, buf ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_rsa_pkcs1_sign returned -0x%0x\n\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_rsa_pkcs1_sign returned -0x%0x\n\n", (unsigned int) -ret );
goto exit;
}

View file

@ -114,7 +114,7 @@ int main( int argc, char *argv[] )
}
i = 0;
while( fscanf( f, "%02X", &c ) > 0 &&
while( fscanf( f, "%02X", (unsigned int*) &c ) > 0 &&
i < (int) sizeof( buf ) )
buf[i++] = (unsigned char) c;
@ -144,7 +144,7 @@ int main( int argc, char *argv[] )
if( ( ret = mbedtls_rsa_pkcs1_verify( &rsa, NULL, NULL, MBEDTLS_RSA_PUBLIC,
MBEDTLS_MD_SHA256, 20, hash, buf ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_rsa_pkcs1_verify returned -0x%0x\n\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_rsa_pkcs1_verify returned -0x%0x\n\n", (unsigned int) -ret );
goto exit;
}

View file

@ -101,7 +101,7 @@ int main( void )
status = ( expr ); \
if( status != PSA_SUCCESS ) \
{ \
printf( "Error %d at line %u: %s\n", \
printf( "Error %d at line %d: %s\n", \
(int) status, \
__LINE__, \
#expr ); \

View file

@ -80,7 +80,7 @@ int main( int argc, char *argv[] )
if( ret != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_entropy_func returned -%04X\n",
ret );
(unsigned int) ret );
goto cleanup;
}

View file

@ -149,7 +149,7 @@ int main( int argc, char *argv[] )
mbedtls_test_cas_pem_len );
if( ret < 0 )
{
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", (unsigned int) -ret );
goto exit;
}
@ -225,7 +225,7 @@ int main( int argc, char *argv[] )
if( ret != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", (unsigned int) -ret );
goto exit;
}
@ -303,7 +303,7 @@ send_request:
goto close_notify;
default:
mbedtls_printf( " mbedtls_ssl_read returned -0x%x\n\n", -ret );
mbedtls_printf( " mbedtls_ssl_read returned -0x%x\n\n", (unsigned int) -ret );
goto exit;
}
}

View file

@ -291,7 +291,7 @@ reset:
client_ip, cliip_len ) ) != 0 )
{
printf( " failed\n ! "
"mbedtls_ssl_set_client_transport_id() returned -0x%x\n\n", -ret );
"mbedtls_ssl_set_client_transport_id() returned -0x%x\n\n", (unsigned int) -ret );
goto exit;
}
@ -318,7 +318,7 @@ reset:
}
else if( ret != 0 )
{
printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", -ret );
printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", (unsigned int) -ret );
goto reset;
}
@ -351,7 +351,7 @@ reset:
goto close_notify;
default:
printf( " mbedtls_ssl_read returned -0x%x\n\n", -ret );
printf( " mbedtls_ssl_read returned -0x%x\n\n", (unsigned int) -ret );
goto reset;
}
}

View file

@ -134,7 +134,7 @@ int main( void )
mbedtls_test_cas_pem_len );
if( ret < 0 )
{
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", (unsigned int) -ret );
goto exit;
}
@ -203,7 +203,7 @@ int main( void )
{
if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", (unsigned int) -ret );
goto exit;
}
}

View file

@ -833,7 +833,7 @@ static int ssl_check_record( mbedtls_ssl_context const *ssl,
break;
default:
mbedtls_printf( "mbedtls_ssl_check_record() failed fatally with -%#04x.\n", -ret );
mbedtls_printf( "mbedtls_ssl_check_record() failed fatally with -%#04x.\n", (unsigned int) -ret );
return( -1 );
}
@ -1077,7 +1077,7 @@ int report_cid_usage( mbedtls_ssl_context *ssl,
if( ret != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_get_peer_cid returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
return( ret );
}
@ -1101,7 +1101,7 @@ int report_cid_usage( mbedtls_ssl_context *ssl,
if( ret != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_get_peer_cid returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
return( ret );
}
@ -1111,7 +1111,7 @@ int report_cid_usage( mbedtls_ssl_context *ssl,
if( ret != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_get_peer_cid returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
return( ret );
}
mbedtls_printf( "(%s) Peer CID (length %u Bytes): ",
@ -2013,7 +2013,7 @@ int main( int argc, char *argv[] )
strlen( pers ) ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n",
-ret );
(unsigned int) -ret );
goto exit;
}
}
@ -2024,7 +2024,7 @@ int main( int argc, char *argv[] )
strlen( pers ) ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n",
-ret );
(unsigned int) -ret );
goto exit;
}
}
@ -2082,7 +2082,7 @@ int main( int argc, char *argv[] )
if( ret < 0 )
{
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
@ -2117,7 +2117,7 @@ int main( int argc, char *argv[] )
if( ret != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
@ -2142,7 +2142,7 @@ int main( int argc, char *argv[] )
if( ret != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_pk_parse_key returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
@ -2179,7 +2179,7 @@ int main( int argc, char *argv[] )
MBEDTLS_NET_PROTO_TCP : MBEDTLS_NET_PROTO_UDP ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_net_connect returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
@ -2190,7 +2190,7 @@ int main( int argc, char *argv[] )
if( ret != 0 )
{
mbedtls_printf( " failed\n ! net_set_(non)block() returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
@ -2208,7 +2208,7 @@ int main( int argc, char *argv[] )
MBEDTLS_SSL_PRESET_DEFAULT ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_config_defaults returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
@ -2249,7 +2249,7 @@ int main( int argc, char *argv[] )
if( ret != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_conf_cid_len returned -%#04x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
}
@ -2447,7 +2447,7 @@ int main( int argc, char *argv[] )
if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
@ -2527,7 +2527,7 @@ int main( int argc, char *argv[] )
ret != MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n",
-ret );
(unsigned int) -ret );
if( ret == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED )
mbedtls_printf(
" Unable to verify the server's certificate. "
@ -2599,7 +2599,7 @@ int main( int argc, char *argv[] )
!= 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_tls_prf returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
@ -2620,7 +2620,7 @@ int main( int argc, char *argv[] )
sizeof( eap_tls_iv ) ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_tls_prf returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
@ -2667,7 +2667,7 @@ int main( int argc, char *argv[] )
&session_data_len ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_session_saved returned -0x%04x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
}
@ -2676,7 +2676,7 @@ int main( int argc, char *argv[] )
if( ( ret = mbedtls_ssl_get_session( &ssl, &saved_session ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_get_session returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
}
@ -2827,7 +2827,7 @@ send_request:
ret != MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_write returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
@ -2955,7 +2955,7 @@ send_request:
default:
mbedtls_printf( " mbedtls_ssl_read returned -0x%x\n",
-ret );
(unsigned int) -ret );
goto exit;
}
}
@ -3019,7 +3019,7 @@ send_request:
goto close_notify;
default:
mbedtls_printf( " mbedtls_ssl_read returned -0x%x\n", -ret );
mbedtls_printf( " mbedtls_ssl_read returned -0x%x\n", (unsigned int) -ret );
goto exit;
}
}
@ -3047,7 +3047,7 @@ send_request:
if( ( ret = mbedtls_ssl_session_reset( &ssl ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_session_reset returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
@ -3058,7 +3058,7 @@ send_request:
ret != MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
@ -3092,7 +3092,7 @@ send_request:
if( ret != MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_context_save returned "
"-0x%x\n\n", -ret );
"-0x%x\n\n", (unsigned int) -ret );
goto exit;
}
@ -3110,7 +3110,7 @@ send_request:
buf_len, &buf_len ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_context_save returned "
"-0x%x\n\n", -ret );
"-0x%x\n\n", (unsigned int) -ret );
goto exit;
}
@ -3139,7 +3139,7 @@ send_request:
context_buf, buf_len ) ) != 0 )
{
mbedtls_printf( "failed\n ! mbedtls_base64_encode returned "
"-0x%x\n", -ret );
"-0x%x\n", (unsigned int) -ret );
mbedtls_free( b64_buf );
goto exit;
}
@ -3184,7 +3184,7 @@ send_request:
if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned "
"-0x%x\n\n", -ret );
"-0x%x\n\n", (unsigned int) -ret );
goto exit;
}
@ -3211,7 +3211,7 @@ send_request:
buf_len ) ) != 0 )
{
mbedtls_printf( "failed\n ! mbedtls_ssl_context_load returned "
"-0x%x\n\n", -ret );
"-0x%x\n\n", (unsigned int) -ret );
goto exit;
}
@ -3283,7 +3283,7 @@ reconnect:
if( ( ret = mbedtls_ssl_session_reset( &ssl ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_session_reset returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
@ -3294,7 +3294,7 @@ reconnect:
session_data_len ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_session_load returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
}
@ -3302,7 +3302,7 @@ reconnect:
if( ( ret = mbedtls_ssl_set_session( &ssl, &saved_session ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_set_session returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
@ -3312,7 +3312,7 @@ reconnect:
MBEDTLS_NET_PROTO_TCP : MBEDTLS_NET_PROTO_UDP ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_net_connect returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
@ -3323,7 +3323,7 @@ reconnect:
if( ret != 0 )
{
mbedtls_printf( " failed\n ! net_set_(non)block() returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
@ -3334,7 +3334,7 @@ reconnect:
ret != MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
}
@ -3353,7 +3353,7 @@ exit:
{
char error_buf[100];
mbedtls_strerror( ret, error_buf, 100 );
mbedtls_printf("Last error was: -0x%X - %s\n\n", -ret, error_buf );
mbedtls_printf("Last error was: -0x%X - %s\n\n", (unsigned int) -ret, error_buf );
}
#endif

View file

@ -309,7 +309,7 @@ reset:
break;
default:
mbedtls_printf( " mbedtls_ssl_read returned -0x%x\n", -ret );
mbedtls_printf( " mbedtls_ssl_read returned -0x%x\n", (unsigned int) -ret );
break;
}

View file

@ -932,7 +932,7 @@ static int ssl_check_record( mbedtls_ssl_context const *ssl,
break;
default:
mbedtls_printf( "mbedtls_ssl_check_record() failed fatally with -%#04x.\n", -ret );
mbedtls_printf( "mbedtls_ssl_check_record() failed fatally with -%#04x.\n", (unsigned int) -ret );
return( -1 );
}
@ -1720,7 +1720,7 @@ int report_cid_usage( mbedtls_ssl_context *ssl,
if( ret != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_get_peer_cid returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
return( ret );
}
@ -2755,7 +2755,7 @@ int main( int argc, char *argv[] )
strlen( pers ) ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n",
-ret );
(unsigned int) -ret );
goto exit;
}
}
@ -2766,7 +2766,7 @@ int main( int argc, char *argv[] )
strlen( pers ) ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n",
-ret );
(unsigned int) -ret );
goto exit;
}
}
@ -2823,7 +2823,7 @@ int main( int argc, char *argv[] )
#endif /* MBEDTLS_CERTS_C */
if( ret < 0 )
{
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", (unsigned int) -ret );
goto exit;
}
@ -2842,7 +2842,7 @@ int main( int argc, char *argv[] )
if( ( ret = mbedtls_x509_crt_parse_file( &srvcert, opt.crt_file ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_file returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
}
@ -2851,7 +2851,7 @@ int main( int argc, char *argv[] )
key_cert_init++;
if( ( ret = mbedtls_pk_parse_keyfile( &pkey, opt.key_file, "" ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%x\n\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%x\n\n", (unsigned int) -ret );
goto exit;
}
}
@ -2867,7 +2867,7 @@ int main( int argc, char *argv[] )
if( ( ret = mbedtls_x509_crt_parse_file( &srvcert2, opt.crt_file2 ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_file(2) returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
}
@ -2877,7 +2877,7 @@ int main( int argc, char *argv[] )
if( ( ret = mbedtls_pk_parse_keyfile( &pkey2, opt.key_file2, "" ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile(2) returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
}
@ -2904,7 +2904,7 @@ int main( int argc, char *argv[] )
mbedtls_test_srv_crt_rsa_len ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
if( ( ret = mbedtls_pk_parse_key( &pkey,
@ -2912,7 +2912,7 @@ int main( int argc, char *argv[] )
mbedtls_test_srv_key_rsa_len, NULL, 0 ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_pk_parse_key returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
key_cert_init = 2;
@ -2923,7 +2923,7 @@ int main( int argc, char *argv[] )
mbedtls_test_srv_crt_ec_len ) ) != 0 )
{
mbedtls_printf( " failed\n ! x509_crt_parse2 returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
if( ( ret = mbedtls_pk_parse_key( &pkey2,
@ -2931,7 +2931,7 @@ int main( int argc, char *argv[] )
mbedtls_test_srv_key_ec_len, NULL, 0 ) ) != 0 )
{
mbedtls_printf( " failed\n ! pk_parse_key2 returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
key_cert_init2 = 2;
@ -2951,7 +2951,7 @@ int main( int argc, char *argv[] )
if( ( ret = mbedtls_dhm_parse_dhmfile( &dhm, opt.dhm_file ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_dhm_parse_dhmfile returned -0x%04X\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
@ -2988,7 +2988,7 @@ int main( int argc, char *argv[] )
opt.transport == MBEDTLS_SSL_TRANSPORT_STREAM ?
MBEDTLS_NET_PROTO_TCP : MBEDTLS_NET_PROTO_UDP ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_net_bind returned -0x%x\n\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_net_bind returned -0x%x\n\n", (unsigned int) -ret );
goto exit;
}
@ -3005,7 +3005,7 @@ int main( int argc, char *argv[] )
opt.transport,
MBEDTLS_SSL_PRESET_DEFAULT ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_config_defaults returned -0x%x\n\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_ssl_config_defaults returned -0x%x\n\n", (unsigned int) -ret );
goto exit;
}
@ -3064,7 +3064,7 @@ int main( int argc, char *argv[] )
if( ret != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_conf_cid_len returned -%#04x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
}
@ -3390,7 +3390,7 @@ int main( int argc, char *argv[] )
strlen( opt.psk_identity ) );
if( ret != 0 )
{
mbedtls_printf( " failed\n mbedtls_ssl_conf_psk returned -0x%04X\n\n", - ret );
mbedtls_printf( " failed\n mbedtls_ssl_conf_psk returned -0x%04X\n\n", (unsigned int) -ret );
goto exit;
}
}
@ -3431,7 +3431,7 @@ int main( int argc, char *argv[] )
#endif
if( ret != 0 )
{
mbedtls_printf( " failed\n mbedtls_ssl_conf_dh_param returned -0x%04X\n\n", - ret );
mbedtls_printf( " failed\n mbedtls_ssl_conf_dh_param returned -0x%04X\n\n", (unsigned int) -ret );
goto exit;
}
#endif
@ -3444,7 +3444,7 @@ int main( int argc, char *argv[] )
if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned -0x%x\n\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned -0x%x\n\n", (unsigned int) -ret );
goto exit;
}
@ -3529,7 +3529,7 @@ reset:
}
#endif
mbedtls_printf( " failed\n ! mbedtls_net_accept returned -0x%x\n\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_net_accept returned -0x%x\n\n", (unsigned int) -ret );
goto exit;
}
@ -3539,7 +3539,7 @@ reset:
ret = mbedtls_net_set_block( &client_fd );
if( ret != 0 )
{
mbedtls_printf( " failed\n ! net_set_(non)block() returned -0x%x\n\n", -ret );
mbedtls_printf( " failed\n ! net_set_(non)block() returned -0x%x\n\n", (unsigned int) -ret );
goto exit;
}
@ -3552,7 +3552,7 @@ reset:
client_ip, cliip_len ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_set_client_transport_id() returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
}
@ -3615,7 +3615,7 @@ handshake:
}
else if( ret != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", (unsigned int) -ret );
#if defined(MBEDTLS_X509_CRT_PARSE_C)
if( ret == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED )
@ -3709,7 +3709,7 @@ handshake:
!= 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_tls_prf returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
@ -3730,7 +3730,7 @@ handshake:
sizeof( eap_tls_iv ) ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_tls_prf returned -0x%x\n\n",
-ret );
(unsigned int) -ret );
goto exit;
}
@ -3821,7 +3821,7 @@ data_exchange:
goto reset;
default:
mbedtls_printf( " mbedtls_ssl_read returned -0x%x\n", -ret );
mbedtls_printf( " mbedtls_ssl_read returned -0x%x\n", (unsigned int) -ret );
goto reset;
}
}
@ -3867,7 +3867,7 @@ data_exchange:
}
larger_buf[ori_len + extra_len] = '\0';
mbedtls_printf( " %u bytes read (%u + %u)\n\n%s\n",
mbedtls_printf( " %d bytes read (%d + %d)\n\n%s\n",
ori_len + extra_len, ori_len, extra_len,
(char *) larger_buf );
@ -3935,7 +3935,7 @@ data_exchange:
goto close_notify;
default:
mbedtls_printf( " mbedtls_ssl_read returned -0x%x\n", -ret );
mbedtls_printf( " mbedtls_ssl_read returned -0x%x\n", (unsigned int) -ret );
goto reset;
}
}
@ -4092,7 +4092,7 @@ data_exchange:
if( ret != MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_context_save returned "
"-0x%x\n\n", -ret );
"-0x%x\n\n", (unsigned int) -ret );
goto exit;
}
@ -4110,7 +4110,7 @@ data_exchange:
buf_len, &buf_len ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_context_save returned "
"-0x%x\n\n", -ret );
"-0x%x\n\n", (unsigned int) -ret );
goto exit;
}
@ -4139,7 +4139,7 @@ data_exchange:
context_buf, buf_len ) ) != 0 )
{
mbedtls_printf( "failed\n ! mbedtls_base64_encode returned "
"-0x%x\n", -ret );
"-0x%x\n", (unsigned int) -ret );
mbedtls_free( b64_buf );
goto exit;
}
@ -4199,7 +4199,7 @@ data_exchange:
if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned "
"-0x%x\n\n", -ret );
"-0x%x\n\n", (unsigned int) -ret );
goto exit;
}
@ -4232,7 +4232,7 @@ data_exchange:
buf_len ) ) != 0 )
{
mbedtls_printf( "failed\n ! mbedtls_ssl_context_load returned "
"-0x%x\n\n", -ret );
"-0x%x\n\n", (unsigned int) -ret );
goto exit;
}
@ -4275,7 +4275,7 @@ exit:
{
char error_buf[100];
mbedtls_strerror( ret, error_buf, 100 );
mbedtls_printf("Last error was: -0x%X - %s\n\n", -ret, error_buf );
mbedtls_printf("Last error was: -0x%X - %s\n\n", (unsigned int) -ret, error_buf );
}
#endif

View file

@ -112,7 +112,7 @@ int main( void )
mbedtls_printf( "FAILED: %s\n", tmp );
#else
#define PRINT_ERROR \
mbedtls_printf( "FAILED: -0x%04x\n", -ret );
mbedtls_printf( "FAILED: -0x%04x\n", (unsigned int) -ret );
#endif
#define TIME_AND_TSC( TITLE, CODE ) \

View file

@ -456,7 +456,7 @@ static int ctx_buffer_append( ctx_buffer *buf,
{
if( ( ret = ctx_buffer_flush( buf ) ) <= 0 )
{
mbedtls_printf( "ctx_buffer_flush failed with -%#04x", -ret );
mbedtls_printf( "ctx_buffer_flush failed with -%#04x", (unsigned int) -ret );
return( ret );
}
}
@ -495,7 +495,7 @@ static int dispatch_data( mbedtls_net_context *ctx,
ret = mbedtls_net_send( ctx, data, len );
if( ret < 0 )
{
mbedtls_printf( "net_send returned -%#04x\n", -ret );
mbedtls_printf( "net_send returned -%#04x\n", (unsigned int) -ret );
}
return( ret );
}
@ -999,7 +999,7 @@ exit:
{
char error_buf[100];
mbedtls_strerror( ret, error_buf, 100 );
mbedtls_printf( "Last error was: -0x%04X - %s\n\n", - ret, error_buf );
mbedtls_printf( "Last error was: -0x%04X - %s\n\n", (unsigned int) -ret, error_buf );
fflush( stdout );
}
#endif

View file

@ -79,7 +79,7 @@ int main( int argc, char *argv[] )
{
char error_buf[200];
mbedtls_strerror( val, error_buf, 200 );
mbedtls_printf("Last error was: -0x%04x - %s\n\n", (int) -val, error_buf );
mbedtls_printf("Last error was: -0x%04x - %s\n\n", (unsigned int) -val, error_buf );
}
#if defined(_WIN32)

View file

@ -258,7 +258,7 @@ int main( int argc, char *argv[] )
{
if( ( ret = mbedtls_x509_crt_parse_path( &cacert, opt.ca_path ) ) < 0 )
{
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_path returned -0x%x\n\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_path returned -0x%x\n\n", (unsigned int) -ret );
goto exit;
}
@ -268,7 +268,7 @@ int main( int argc, char *argv[] )
{
if( ( ret = mbedtls_x509_crt_parse_file( &cacert, opt.ca_file ) ) < 0 )
{
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_file returned -0x%x\n\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_file returned -0x%x\n\n", (unsigned int) -ret );
goto exit;
}
@ -282,7 +282,7 @@ int main( int argc, char *argv[] )
{
if( ( ret = mbedtls_x509_crl_parse_file( &cacrl, opt.crl_file ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_x509_crl_parse returned -0x%x\n\n", -ret );
mbedtls_printf( " failed\n ! mbedtls_x509_crl_parse returned -0x%x\n\n", (unsigned int) -ret );
goto exit;
}

View file

@ -507,7 +507,7 @@ int main( int argc, char *argv[] )
{
mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_mpi_read_string "
"returned -0x%04x - %s\n\n", -ret, buf );
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
goto exit;
}
@ -527,7 +527,7 @@ int main( int argc, char *argv[] )
{
mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_file "
"returned -0x%04x - %s\n\n", -ret, buf );
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
goto exit;
}
@ -537,7 +537,7 @@ int main( int argc, char *argv[] )
{
mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509_dn_gets "
"returned -0x%04x - %s\n\n", -ret, buf );
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
goto exit;
}
@ -561,7 +561,7 @@ int main( int argc, char *argv[] )
{
mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509_csr_parse_file "
"returned -0x%04x - %s\n\n", -ret, buf );
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
goto exit;
}
@ -571,7 +571,7 @@ int main( int argc, char *argv[] )
{
mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509_dn_gets "
"returned -0x%04x - %s\n\n", -ret, buf );
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
goto exit;
}
@ -596,7 +596,7 @@ int main( int argc, char *argv[] )
{
mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile "
"returned -0x%04x - %s\n\n", -ret, buf );
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
goto exit;
}
@ -612,7 +612,7 @@ int main( int argc, char *argv[] )
{
mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile "
"returned -x%02x - %s\n\n", -ret, buf );
"returned -x%02x - %s\n\n", (unsigned int) -ret, buf );
goto exit;
}
@ -646,7 +646,7 @@ int main( int argc, char *argv[] )
{
mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_subject_name "
"returned -0x%04x - %s\n\n", -ret, buf );
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
goto exit;
}
@ -654,7 +654,7 @@ int main( int argc, char *argv[] )
{
mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_issuer_name "
"returned -0x%04x - %s\n\n", -ret, buf );
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
goto exit;
}
@ -669,7 +669,7 @@ int main( int argc, char *argv[] )
{
mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_serial "
"returned -0x%04x - %s\n\n", -ret, buf );
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
goto exit;
}
@ -678,7 +678,7 @@ int main( int argc, char *argv[] )
{
mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_validity "
"returned -0x%04x - %s\n\n", -ret, buf );
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
goto exit;
}
@ -696,7 +696,7 @@ int main( int argc, char *argv[] )
{
mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! x509write_crt_set_basic_contraints "
"returned -0x%04x - %s\n\n", -ret, buf );
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
goto exit;
}
@ -716,7 +716,7 @@ int main( int argc, char *argv[] )
mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_subject"
"_key_identifier returned -0x%04x - %s\n\n",
-ret, buf );
(unsigned int) -ret, buf );
goto exit;
}
@ -735,7 +735,7 @@ int main( int argc, char *argv[] )
mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_authority_"
"key_identifier returned -0x%04x - %s\n\n",
-ret, buf );
(unsigned int) -ret, buf );
goto exit;
}
@ -754,7 +754,7 @@ int main( int argc, char *argv[] )
{
mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_key_usage "
"returned -0x%04x - %s\n\n", -ret, buf );
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
goto exit;
}
@ -772,7 +772,7 @@ int main( int argc, char *argv[] )
{
mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_ns_cert_type "
"returned -0x%04x - %s\n\n", -ret, buf );
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
goto exit;
}
@ -790,7 +790,7 @@ int main( int argc, char *argv[] )
{
mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! write_certificate -0x%04x - %s\n\n",
-ret, buf );
(unsigned int) -ret, buf );
goto exit;
}

View file

@ -113,7 +113,7 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen )
high_level_error_description = mbedtls_high_level_strerr( ret );
if( high_level_error_description == NULL )
mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret );
mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", (unsigned int) use_ret );
else
mbedtls_snprintf( buf, buflen, "%s", high_level_error_description );
@ -150,7 +150,7 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen )
low_level_error_description = mbedtls_low_level_strerr( ret );
if( low_level_error_description == NULL )
mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret );
mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", (unsigned int) use_ret );
else
mbedtls_snprintf( buf, buflen, "%s", low_level_error_description );
}

View file

@ -52,7 +52,7 @@ void check_runtime_version( char * version_str )
mbedtls_version_get_string( get_str );
mbedtls_version_get_string_full( get_str_full );
mbedtls_snprintf( build_str, 100, "%d.%d.%d",
mbedtls_snprintf( build_str, 100, "%u.%u.%u",
(get_int >> 24) & 0xFF,
(get_int >> 16) & 0xFF,
(get_int >> 8) & 0xFF );

View file

@ -237,7 +237,7 @@ int verify_parse_san( mbedtls_x509_subject_alternative_name *san,
char *p = *buf;
size_t n = *size;
ret = mbedtls_snprintf( p, n, "type : %u", san->type );
ret = mbedtls_snprintf( p, n, "type : %d", san->type );
MBEDTLS_X509_SAFE_SNPRINTF;
switch( san->type )