Fix parantheses on return and sizeof statements.
Used script:
```
import re
import sys
for arg in sys.argv[1:]:
print(arg)
with open(arg, 'r') as file:
content = file.read()
content = re.sub(r"return\s?\((?!.*\).*\()\s*\n?(.*)\n?\);", r"return \1;", \
content, flags = re.M)
content = re.sub(r"sizeof ([^\(][a-zA-Z0-9_\[\]]*)", r"sizeof(\1)",\
content, flags = re.M)
with open(arg, 'w') as file:
file.write(content)
```
Executed with:
` find . -regextype posix-egrep -regex ".*\.([hc]|fmt|function)" | xargs -L1 python script.py`
Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
diff --git a/programs/fuzz/common.c b/programs/fuzz/common.c
index ac39ee2..70a5380 100644
--- a/programs/fuzz/common.c
+++ b/programs/fuzz/common.c
@@ -27,9 +27,9 @@
//pretends we wrote everything ok
if( len > INT_MAX ) {
- return( -1 );
+ return -1 ;
}
- return( (int) len );
+ return (int) len ;
}
int fuzz_recv( void *ctx, unsigned char *buf, size_t len )
@@ -39,10 +39,10 @@
if(biomemfuzz->Offset == biomemfuzz->Size) {
//EOF
- return( 0 );
+ return 0 ;
}
if( len > INT_MAX ) {
- return( -1 );
+ return -1 ;
}
if( len + biomemfuzz->Offset > biomemfuzz->Size ) {
//do not overflow
@@ -50,7 +50,7 @@
}
memcpy(buf, biomemfuzz->Data + biomemfuzz->Offset, len);
biomemfuzz->Offset += len;
- return( (int) len );
+ return (int) len ;
}
int dummy_random( void *p_rng, unsigned char *output, size_t output_len )
@@ -69,7 +69,7 @@
//replace result with pseudo random
output[i] = (unsigned char) rand();
}
- return( ret );
+ return ret ;
}
int dummy_entropy( void *data, unsigned char *output, size_t len )
@@ -84,7 +84,7 @@
//replace result with pseudo random
output[i] = (unsigned char) rand();
}
- return( 0 );
+ return 0 ;
}
int fuzz_recv_timeout( void *ctx, unsigned char *buf, size_t len,
diff --git a/programs/hash/generic_sum.c b/programs/hash/generic_sum.c
index 9243f0a..23d78bd 100644
--- a/programs/hash/generic_sum.c
+++ b/programs/hash/generic_sum.c
@@ -57,7 +57,7 @@
if( ret == 2 )
mbedtls_fprintf( stderr, "failed to read: %s\n", filename );
- return( ret );
+ return ret ;
}
static int generic_print( const mbedtls_md_info_t *md_info, char *filename )
@@ -66,13 +66,13 @@
unsigned char sum[MBEDTLS_MD_MAX_SIZE];
if( generic_wrapper( md_info, filename, sum ) != 0 )
- return( 1 );
+ return 1 ;
for( i = 0; i < mbedtls_md_get_size( md_info ); i++ )
mbedtls_printf( "%02x", sum[i] );
mbedtls_printf( " %s\n", filename );
- return( 0 );
+ return 0 ;
}
static int generic_check( const mbedtls_md_info_t *md_info, char *filename )
@@ -94,7 +94,7 @@
if( ( f = fopen( filename, "rb" ) ) == NULL )
{
mbedtls_printf( "failed to open: %s\n", filename );
- return( 1 );
+ return 1 ;
}
nb_err1 = nb_err2 = 0;
@@ -164,7 +164,7 @@
fclose( f );
- return( nb_err1 != 0 || nb_err2 != 0 );
+ return nb_err1 != 0 || nb_err2 != 0 ;
}
int main( int argc, char *argv[] )
diff --git a/programs/pkey/ecdh_curve25519.c b/programs/pkey/ecdh_curve25519.c
index ca046fd..fcef380 100644
--- a/programs/pkey/ecdh_curve25519.c
+++ b/programs/pkey/ecdh_curve25519.c
@@ -73,7 +73,7 @@
mbedtls_entropy_init( &entropy );
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
(const unsigned char *) pers,
- sizeof pers ) ) != 0 )
+ sizeof(pers) ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret );
goto exit;
diff --git a/programs/pkey/ecdsa.c b/programs/pkey/ecdsa.c
index 6b6e951..293bfba 100644
--- a/programs/pkey/ecdsa.c
+++ b/programs/pkey/ecdsa.c
@@ -81,7 +81,7 @@
size_t len;
if( mbedtls_ecp_point_write_binary( &key->MBEDTLS_PRIVATE(grp), &key->MBEDTLS_PRIVATE(Q),
- MBEDTLS_ECP_PF_UNCOMPRESSED, &len, buf, sizeof buf ) != 0 )
+ MBEDTLS_ECP_PF_UNCOMPRESSED, &len, buf, sizeof(buf) ) != 0 )
{
mbedtls_printf("internal error\n");
return;
diff --git a/programs/pkey/gen_key.c b/programs/pkey/gen_key.c
index 4043dfa..8729be3 100644
--- a/programs/pkey/gen_key.c
+++ b/programs/pkey/gen_key.c
@@ -61,7 +61,7 @@
file = fopen( "/dev/random", "rb" );
if( file == NULL )
- return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
+ return MBEDTLS_ERR_ENTROPY_SOURCE_FAILED ;
while( left > 0 )
{
@@ -70,7 +70,7 @@
if( ret == 0 && ferror( file ) )
{
fclose( file );
- return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
+ return MBEDTLS_ERR_ENTROPY_SOURCE_FAILED ;
}
p += ret;
@@ -80,7 +80,7 @@
fclose( file );
*olen = len;
- return( 0 );
+ return 0 ;
}
#endif /* !_WIN32 */
#endif
@@ -157,31 +157,31 @@
if( opt.format == FORMAT_PEM )
{
if( ( ret = mbedtls_pk_write_key_pem( key, output_buf, 16000 ) ) != 0 )
- return( ret );
+ return ret ;
len = strlen( (char *) output_buf );
}
else
{
if( ( ret = mbedtls_pk_write_key_der( key, output_buf, 16000 ) ) < 0 )
- return( ret );
+ return ret ;
len = ret;
c = output_buf + sizeof(output_buf) - len;
}
if( ( f = fopen( output_file, "wb" ) ) == NULL )
- return( -1 );
+ return -1 ;
if( fwrite( c, 1, len, f ) != len )
{
fclose( f );
- return( -1 );
+ return -1 ;
}
fclose( f );
- return( 0 );
+ return 0 ;
}
int main( int argc, char *argv[] )
diff --git a/programs/pkey/key_app_writer.c b/programs/pkey/key_app_writer.c
index 8a09af5..a61cda1 100644
--- a/programs/pkey/key_app_writer.c
+++ b/programs/pkey/key_app_writer.c
@@ -128,7 +128,7 @@
if( opt.output_format == OUTPUT_FORMAT_PEM )
{
if( ( ret = mbedtls_pk_write_pubkey_pem( key, output_buf, 16000 ) ) != 0 )
- return( ret );
+ return ret ;
len = strlen( (char *) output_buf );
}
@@ -136,24 +136,24 @@
#endif
{
if( ( ret = mbedtls_pk_write_pubkey_der( key, output_buf, 16000 ) ) < 0 )
- return( ret );
+ return ret ;
len = ret;
c = output_buf + sizeof(output_buf) - len;
}
if( ( f = fopen( output_file, "w" ) ) == NULL )
- return( -1 );
+ return -1 ;
if( fwrite( c, 1, len, f ) != len )
{
fclose( f );
- return( -1 );
+ return -1 ;
}
fclose( f );
- return( 0 );
+ return 0 ;
}
static int write_private_key( mbedtls_pk_context *key, const char *output_file )
@@ -170,7 +170,7 @@
if( opt.output_format == OUTPUT_FORMAT_PEM )
{
if( ( ret = mbedtls_pk_write_key_pem( key, output_buf, 16000 ) ) != 0 )
- return( ret );
+ return ret ;
len = strlen( (char *) output_buf );
}
@@ -178,24 +178,24 @@
#endif
{
if( ( ret = mbedtls_pk_write_key_der( key, output_buf, 16000 ) ) < 0 )
- return( ret );
+ return ret ;
len = ret;
c = output_buf + sizeof(output_buf) - len;
}
if( ( f = fopen( output_file, "w" ) ) == NULL )
- return( -1 );
+ return -1 ;
if( fwrite( c, 1, len, f ) != len )
{
fclose( f );
- return( -1 );
+ return -1 ;
}
fclose( f );
- return( 0 );
+ return 0 ;
}
int main( int argc, char *argv[] )
diff --git a/programs/psa/crypto_examples.c b/programs/psa/crypto_examples.c
index 935d657..80fe67e 100644
--- a/programs/psa/crypto_examples.c
+++ b/programs/psa/crypto_examples.c
@@ -54,7 +54,7 @@
"and/or MBEDTLS_CIPHER_MODE_WITH_PADDING "
"not defined and/or MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER"
" defined.\r\n" );
- return( 0 );
+ return 0 ;
}
#else
@@ -91,7 +91,7 @@
*output_len += len;
exit:
- return( status );
+ return status ;
}
static psa_status_t cipher_encrypt( psa_key_id_t key,
@@ -122,7 +122,7 @@
exit:
psa_cipher_abort( &operation );
- return( status );
+ return status ;
}
static psa_status_t cipher_decrypt( psa_key_id_t key,
@@ -152,7 +152,7 @@
exit:
psa_cipher_abort( &operation );
- return( status );
+ return status ;
}
static psa_status_t
@@ -201,7 +201,7 @@
exit:
psa_destroy_key( key );
- return( status );
+ return status ;
}
static psa_status_t cipher_example_encrypt_decrypt_aes_cbc_pkcs7_multi( void )
@@ -249,7 +249,7 @@
exit:
psa_destroy_key( key );
- return( status );
+ return status ;
}
static psa_status_t cipher_example_encrypt_decrypt_aes_ctr_multi( void )
@@ -296,7 +296,7 @@
exit:
psa_destroy_key( key );
- return( status );
+ return status ;
}
static void cipher_examples( void )
@@ -325,7 +325,7 @@
cipher_examples( );
exit:
mbedtls_psa_crypto_free( );
- return( 0 );
+ return 0 ;
}
#endif /* MBEDTLS_PSA_CRYPTO_C && MBEDTLS_AES_C && MBEDTLS_CIPHER_MODE_CBC &&
MBEDTLS_CIPHER_MODE_CTR && MBEDTLS_CIPHER_MODE_WITH_PADDING */
diff --git a/programs/psa/key_ladder_demo.c b/programs/psa/key_ladder_demo.c
index cad875e..435c9ce 100644
--- a/programs/psa/key_ladder_demo.c
+++ b/programs/psa/key_ladder_demo.c
@@ -72,7 +72,7 @@
"MBEDTLS_PSA_CRYPTO_C and/or MBEDTLS_FS_IO "
"not defined and/or MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER "
"defined.\n" );
- return( 0 );
+ return 0 ;
}
#else
@@ -184,7 +184,7 @@
exit:
if( key_file != NULL)
fclose( key_file );
- return( status );
+ return status ;
}
/* Generate a master key for use in this demo.
@@ -210,7 +210,7 @@
exit:
(void) psa_destroy_key( key );
- return( status );
+ return status ;
}
/* Load the master key from a file.
@@ -259,7 +259,7 @@
(void) psa_destroy_key( *master_key );
*master_key = 0;
}
- return( status );
+ return status ;
}
/* Derive the intermediate keys, using the list of labels provided on
@@ -314,7 +314,7 @@
psa_destroy_key( *key );
*key = 0;
}
- return( status );
+ return status ;
}
/* Derive a wrapping key from the last intermediate key. */
@@ -351,7 +351,7 @@
exit:
psa_key_derivation_abort( &operation );
- return( status );
+ return status ;
}
static psa_status_t wrap_data( const char *input_file_name,
@@ -433,7 +433,7 @@
if( buffer != NULL )
mbedtls_platform_zeroize( buffer, buffer_size );
free( buffer );
- return( status );
+ return status ;
}
static psa_status_t unwrap_data( const char *input_file_name,
@@ -522,7 +522,7 @@
if( buffer != NULL )
mbedtls_platform_zeroize( buffer, ciphertext_size );
free( buffer );
- return( status );
+ return status ;
}
static psa_status_t run( enum program_mode mode,
@@ -540,7 +540,7 @@
/* Generate mode is unlike the others. Generate the master key and exit. */
if( mode == MODE_GENERATE )
- return( generate( key_file_name ) );
+ return generate( key_file_name ) ;
/* Read the master key. */
PSA_CHECK( import_key_from_file( PSA_KEY_USAGE_DERIVE | PSA_KEY_USAGE_EXPORT,
@@ -584,7 +584,7 @@
(void) psa_destroy_key( wrapping_key );
/* Deinitialize the PSA crypto library. */
mbedtls_psa_crypto_free( );
- return( status );
+ return status ;
}
static void usage( void )
@@ -625,7 +625,7 @@
strcmp( argv[1], "--help" ) == 0 )
{
usage( );
- return( EXIT_SUCCESS );
+ return EXIT_SUCCESS ;
}
for( i = 2; i < argc; i++ )
@@ -646,7 +646,7 @@
{
printf( "Maximum ladder depth %u exceeded.\n",
(unsigned) MAX_LADDER_DEPTH );
- return( EXIT_FAILURE );
+ return EXIT_FAILURE ;
}
ladder[ladder_depth] = q;
++ladder_depth;
@@ -680,13 +680,13 @@
( mode == MODE_WRAP || mode == MODE_UNWRAP ) )
{
printf( "Required argument missing: input\n" );
- return( DEMO_ERROR );
+ return DEMO_ERROR ;
}
if( output_file_name == NULL &&
( mode == MODE_SAVE || mode == MODE_WRAP || mode == MODE_UNWRAP ) )
{
printf( "Required argument missing: output\n" );
- return( DEMO_ERROR );
+ return DEMO_ERROR ;
}
status = run( mode, key_file_name,
@@ -698,6 +698,6 @@
usage_failure:
usage( );
- return( EXIT_FAILURE );
+ return EXIT_FAILURE ;
}
#endif /* MBEDTLS_SHA256_C && MBEDTLS_MD_C && MBEDTLS_AES_C && MBEDTLS_CCM_C && MBEDTLS_PSA_CRYPTO_C && MBEDTLS_FS_IO */
diff --git a/programs/psa/psa_constant_names.c b/programs/psa/psa_constant_names.c
index b5fea04..94edde5 100644
--- a/programs/psa/psa_constant_names.c
+++ b/programs/psa/psa_constant_names.c
@@ -33,7 +33,7 @@
/* Avoid calling the invalid parameter handler by checking ourselves */
if( s == NULL || n == 0 || fmt == NULL )
- return( -1 );
+ return -1 ;
va_start( argp, fmt );
#if defined(_TRUNCATE) && !defined(__MINGW32__)
@@ -48,7 +48,7 @@
#endif
va_end( argp );
- return( ret );
+ return ret ;
}
#endif
diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c
index 25fe21b..5477096 100644
--- a/programs/ssl/ssl_client2.c
+++ b/programs/ssl/ssl_client2.c
@@ -518,7 +518,7 @@
memcpy( peer_crt_info, buf, sizeof( buf ) );
if( opt.debug_level == 0 )
- return( 0 );
+ return 0 ;
mbedtls_printf( "%s", buf );
#else
@@ -534,7 +534,7 @@
mbedtls_printf( "%s\n", buf );
}
- return( 0 );
+ return 0 ;
}
#endif /* MBEDTLS_X509_CRT_PARSE_C */
@@ -548,7 +548,7 @@
int cid_negotiated;
if( opt.transport != MBEDTLS_SSL_TRANSPORT_DATAGRAM )
- return( 0 );
+ return 0 ;
/* Check if the use of a CID has been negotiated,
* but don't ask for the CID value and length.
@@ -566,7 +566,7 @@
{
mbedtls_printf( " failed\n ! mbedtls_ssl_get_peer_cid returned -0x%x\n\n",
(unsigned int) -ret );
- return( ret );
+ return ret ;
}
if( cid_negotiated == MBEDTLS_SSL_CID_DISABLED )
@@ -590,7 +590,7 @@
{
mbedtls_printf( " failed\n ! mbedtls_ssl_get_peer_cid returned -0x%x\n\n",
(unsigned int) -ret );
- return( ret );
+ return ret ;
}
/* Ask for just length + value of the peer's CID. */
@@ -600,7 +600,7 @@
{
mbedtls_printf( " failed\n ! mbedtls_ssl_get_peer_cid returned -0x%x\n\n",
(unsigned int) -ret );
- return( ret );
+ return ret ;
}
mbedtls_printf( "(%s) Peer CID (length %u Bytes): ",
additional_description,
@@ -613,7 +613,7 @@
mbedtls_printf( "\n" );
}
- return( 0 );
+ return 0 ;
}
#endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
diff --git a/programs/ssl/ssl_context_info.c b/programs/ssl/ssl_context_info.c
index 5ad9120..67e922c 100644
--- a/programs/ssl/ssl_context_info.c
+++ b/programs/ssl/ssl_context_info.c
@@ -30,7 +30,7 @@
{
printf("MBEDTLS_X509_CRT_PARSE_C and/or MBEDTLS_ERROR_C and/or "
"MBEDTLS_SSL_TLS_C not defined.\n");
- return( 0 );
+ return 0 ;
}
#else
diff --git a/programs/ssl/ssl_mail_client.c b/programs/ssl/ssl_mail_client.c
index 32960ad..2477979 100644
--- a/programs/ssl/ssl_mail_client.c
+++ b/programs/ssl/ssl_mail_client.c
@@ -190,7 +190,7 @@
mbedtls_strerror( ret, (char *) buf, 1024 );
#endif
mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned %d: %s\n\n", ret, buf );
- return( -1 );
+ return -1 ;
}
}
@@ -227,7 +227,7 @@
mbedtls_printf( "%s\n", buf );
#endif
- return( 0 );
+ return 0 ;
}
static int write_ssl_data( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len )
@@ -244,7 +244,7 @@
}
}
- return( 0 );
+ return 0 ;
}
static int write_ssl_and_get_response( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len )
diff --git a/programs/ssl/ssl_pthread_server.c b/programs/ssl/ssl_pthread_server.c
index a8db4d8..4517309 100644
--- a/programs/ssl/ssl_pthread_server.c
+++ b/programs/ssl/ssl_pthread_server.c
@@ -267,7 +267,7 @@
thread_info->thread_complete = 1;
- return( NULL );
+ return NULL ;
}
static int thread_create( mbedtls_net_context *client_fd )
@@ -292,7 +292,7 @@
}
if( i == MAX_NUM_THREADS )
- return( -1 );
+ return -1 ;
/*
* Fill thread-info for thread
@@ -304,10 +304,10 @@
if( ( ret = pthread_create( &threads[i].thread, NULL, handle_ssl_connection,
&threads[i].data ) ) != 0 )
{
- return( ret );
+ return ret ;
}
- return( 0 );
+ return 0 ;
}
int main( void )
diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c
index d2aa48a..ea6706d 100644
--- a/programs/ssl/ssl_server2.c
+++ b/programs/ssl/ssl_server2.c
@@ -616,13 +616,13 @@
static int get_auth_mode( const char *s )
{
if( strcmp( s, "none" ) == 0 )
- return( MBEDTLS_SSL_VERIFY_NONE );
+ return MBEDTLS_SSL_VERIFY_NONE ;
if( strcmp( s, "optional" ) == 0 )
- return( MBEDTLS_SSL_VERIFY_OPTIONAL );
+ return MBEDTLS_SSL_VERIFY_OPTIONAL ;
if( strcmp( s, "required" ) == 0 )
- return( MBEDTLS_SSL_VERIFY_REQUIRED );
+ return MBEDTLS_SSL_VERIFY_REQUIRED ;
- return( -1 );
+ return -1 ;
}
/*
@@ -701,7 +701,7 @@
if( ( new = mbedtls_calloc( 1, sizeof( sni_entry ) ) ) == NULL )
{
sni_free( cur );
- return( NULL );
+ return NULL ;
}
GET_ITEM( new->name );
@@ -760,12 +760,12 @@
cur = new;
}
- return( cur );
+ return cur ;
error:
sni_free( new );
sni_free( cur );
- return( NULL );
+ return NULL ;
}
/*
@@ -787,13 +787,13 @@
if( cur->authmode != DFL_AUTH_MODE )
mbedtls_ssl_set_hs_authmode( ssl, cur->authmode );
- return( mbedtls_ssl_set_hs_own_cert( ssl, cur->cert, cur->key ) );
+ return mbedtls_ssl_set_hs_own_cert( ssl, cur->cert, cur->key ) ;
}
cur = cur->next;
}
- return( -1 );
+ return -1 ;
}
#endif /* SNI_OPTION */
@@ -830,7 +830,7 @@
{
status = psa_destroy_key( slot );
if( status != PSA_SUCCESS )
- return( status );
+ return status ;
}
#endif /* MBEDTLS_USE_PSA_CRYPTO */
@@ -839,7 +839,7 @@
head = next;
}
- return( 0 );
+ return 0 ;
}
/*
@@ -877,12 +877,12 @@
cur = new;
}
- return( cur );
+ return cur ;
error:
psk_free( new );
psk_free( cur );
- return( 0 );
+ return 0 ;
}
/*
@@ -900,16 +900,16 @@
{
#if defined(MBEDTLS_USE_PSA_CRYPTO)
if( cur->slot != 0 )
- return( mbedtls_ssl_set_hs_psk_opaque( ssl, cur->slot ) );
+ return mbedtls_ssl_set_hs_psk_opaque( ssl, cur->slot ) ;
else
#endif
- return( mbedtls_ssl_set_hs_psk( ssl, cur->key, cur->key_len ) );
+ return mbedtls_ssl_set_hs_psk( ssl, cur->key, cur->key_len ) ;
}
cur = cur->next;
}
- return( -1 );
+ return -1 ;
}
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */
@@ -977,13 +977,13 @@
unsigned delay )
{
if( ctx->slots_used >= sizeof( ctx->slots ) / sizeof( *ctx->slots ) )
- return( -1 );
+ return -1 ;
ctx->slots[ctx->slots_used].cert = cert;
ctx->slots[ctx->slots_used].pk = pk;
ctx->slots[ctx->slots_used].delay = delay;
ctx->slots[ctx->slots_used].pk_owned = pk_take_ownership;
++ctx->slots_used;
- return( 0 );
+ return 0 ;
}
#define SSL_ASYNC_INPUT_MAX_SIZE 512
@@ -1047,7 +1047,7 @@
{
mbedtls_printf( "Async %s callback: no key matches this certificate.\n",
op_name );
- return( MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH );
+ return MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH ;
}
mbedtls_printf( "Async %s callback: using key slot %u, delay=%u.\n",
op_name, slot, config_data->slots[slot].delay );
@@ -1055,15 +1055,15 @@
if( config_data->inject_error == SSL_ASYNC_INJECT_ERROR_START )
{
mbedtls_printf( "Async %s callback: injected error\n", op_name );
- return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE );
+ return MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE ;
}
if( input_len > SSL_ASYNC_INPUT_MAX_SIZE )
- return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
+ return MBEDTLS_ERR_SSL_BAD_INPUT_DATA ;
ctx = mbedtls_calloc( 1, sizeof( *ctx ) );
if( ctx == NULL )
- return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
+ return MBEDTLS_ERR_SSL_ALLOC_FAILED ;
ctx->slot = slot;
ctx->operation_type = op_type;
ctx->md_alg = md_alg;
@@ -1073,9 +1073,9 @@
mbedtls_ssl_set_async_operation_data( ssl, ctx );
if( ctx->remaining_delay == 0 )
- return( 0 );
+ return 0 ;
else
- return( MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS );
+ return MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS ;
}
static int ssl_async_sign( mbedtls_ssl_context *ssl,
@@ -1116,7 +1116,7 @@
--ctx->remaining_delay;
mbedtls_printf( "Async resume (slot %u): call %u more times.\n",
ctx->slot, ctx->remaining_delay );
- return( MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS );
+ return MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS ;
}
switch( ctx->operation_type )
@@ -1138,7 +1138,7 @@
mbedtls_printf( "Async resume (slot %u): unknown operation type %ld. This shouldn't happen.\n",
ctx->slot, (long) ctx->operation_type );
mbedtls_free( ctx );
- return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE );
+ return MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE ;
break;
}
@@ -1149,13 +1149,13 @@
mbedtls_printf( "Async resume callback: %s done but injected error\n",
op_name );
mbedtls_free( ctx );
- return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE );
+ return MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE ;
}
mbedtls_printf( "Async resume (slot %u): %s done, status=%d.\n",
ctx->slot, op_name, ret );
mbedtls_free( ctx );
- return( ret );
+ return ret ;
}
static void ssl_async_cancel( mbedtls_ssl_context *ssl )
@@ -1184,10 +1184,10 @@
if( status != PSA_SUCCESS )
{
fprintf( stderr, "IMPORT\n" );
- return( status );
+ return status ;
}
- return( PSA_SUCCESS );
+ return PSA_SUCCESS ;
}
#endif /* MBEDTLS_USE_PSA_CRYPTO */
@@ -1201,7 +1201,7 @@
int cid_negotiated;
if( opt.transport != MBEDTLS_SSL_TRANSPORT_DATAGRAM )
- return( 0 );
+ return 0 ;
/* Check if the use of a CID has been negotiated */
ret = mbedtls_ssl_get_peer_cid( ssl, &cid_negotiated,
@@ -1210,7 +1210,7 @@
{
mbedtls_printf( " failed\n ! mbedtls_ssl_get_peer_cid returned -0x%x\n\n",
(unsigned int) -ret );
- return( ret );
+ return ret ;
}
if( cid_negotiated == MBEDTLS_SSL_CID_DISABLED )
@@ -1237,7 +1237,7 @@
mbedtls_printf( "\n" );
}
- return( 0 );
+ return 0 ;
}
#endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
diff --git a/programs/ssl/ssl_test_common_source.c b/programs/ssl/ssl_test_common_source.c
index 6ec4171..6ca7af3 100644
--- a/programs/ssl/ssl_test_common_source.c
+++ b/programs/ssl/ssl_test_common_source.c
@@ -152,7 +152,7 @@
* so make a copy. */
tmp_buf = mbedtls_calloc( 1, len );
if( tmp_buf == NULL )
- return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
+ return MBEDTLS_ERR_SSL_ALLOC_FAILED ;
memcpy( tmp_buf, buf, len );
ret_cr1 = mbedtls_ssl_check_record( ssl, tmp_buf, len );
@@ -201,7 +201,7 @@
cleanup:
mbedtls_free( tmp_buf );
- return( my_ret );
+ return my_ret ;
}
int recv_cb( void *ctx, unsigned char *buf, size_t len )
@@ -215,7 +215,7 @@
else
ret = mbedtls_net_recv( io_ctx->net, buf, len );
if( ret < 0 )
- return( ret );
+ return ret ;
recv_len = (size_t) ret;
if( opt.transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )
@@ -224,10 +224,10 @@
* in between receiving the packet from the underlying
* transport and passing it on to the TLS stack. */
if( ssl_check_record( io_ctx->ssl, buf, recv_len ) != 0 )
- return( -1 );
+ return -1 ;
}
- return( (int) recv_len );
+ return (int) recv_len ;
}
int recv_timeout_cb( void *ctx, unsigned char *buf, size_t len,
@@ -239,7 +239,7 @@
ret = mbedtls_net_recv_timeout( io_ctx->net, buf, len, timeout );
if( ret < 0 )
- return( ret );
+ return ret ;
recv_len = (size_t) ret;
if( opt.transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )
@@ -248,10 +248,10 @@
* in between receiving the packet from the underlying
* transport and passing it on to the TLS stack. */
if( ssl_check_record( io_ctx->ssl, buf, recv_len ) != 0 )
- return( -1 );
+ return -1 ;
}
- return( (int) recv_len );
+ return (int) recv_len ;
}
int send_cb( void *ctx, unsigned char const *buf, size_t len )
@@ -259,9 +259,9 @@
io_ctx_t *io_ctx = (io_ctx_t*) ctx;
if( opt.nbio == 2 )
- return( delayed_send( io_ctx->net, buf, len ) );
+ return delayed_send( io_ctx->net, buf, len ) ;
- return( mbedtls_net_send( io_ctx->net, buf, len ) );
+ return mbedtls_net_send( io_ctx->net, buf, len ) ;
}
#if defined(MBEDTLS_X509_CRT_PARSE_C)
@@ -294,7 +294,7 @@
uint32_t flags )
{
#if !defined(MBEDTLS_X509_REMOVE_INFO)
- return( mbedtls_x509_crt_verify_info( buf, size, prefix, flags ) );
+ return mbedtls_x509_crt_verify_info( buf, size, prefix, flags ) ;
#else /* !MBEDTLS_X509_REMOVE_INFO */
int ret;
diff --git a/programs/ssl/ssl_test_lib.c b/programs/ssl/ssl_test_lib.c
index 04e127a..382682f 100644
--- a/programs/ssl/ssl_test_lib.c
+++ b/programs/ssl/ssl_test_lib.c
@@ -65,7 +65,7 @@
//replace result with pseudo random
output[i] = (unsigned char) rand();
}
- return( ret );
+ return ret ;
}
#endif
@@ -95,7 +95,7 @@
{
mbedtls_fprintf( stderr,
"MBEDTLS_USE_PSA_CRYPTO does not support reproducible mode.\n" );
- return( -1 );
+ return -1 ;
}
#endif
#if defined(MBEDTLS_TEST_USE_PSA_CRYPTO_RNG)
@@ -106,9 +106,9 @@
{
mbedtls_fprintf( stderr,
"The PSA RNG does not support reproducible mode.\n" );
- return( -1 );
+ return -1 ;
}
- return( 0 );
+ return 0 ;
#else /* !MBEDTLS_TEST_USE_PSA_CRYPTO_RNG */
int ( *f_entropy )( void *, unsigned char *, size_t ) =
( reproducible ? dummy_entropy : mbedtls_entropy_func );
@@ -142,11 +142,11 @@
{
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n",
(unsigned int) -ret );
- return( ret );
+ return ret ;
}
#endif /* !MBEDTLS_TEST_USE_PSA_CRYPTO_RNG */
- return( 0 );
+ return 0 ;
}
void rng_free( rng_context_t *rng )
@@ -181,9 +181,9 @@
rng_context_t *rng = p_rng;
#if defined(MBEDTLS_CTR_DRBG_C)
- return( mbedtls_ctr_drbg_random( &rng->drbg, output, output_len ) );
+ return mbedtls_ctr_drbg_random( &rng->drbg, output, output_len ) ;
#elif defined(MBEDTLS_HMAC_DRBG_C)
- return( mbedtls_hmac_drbg_random( &rng->drbg, output, output_len ) );
+ return mbedtls_hmac_drbg_random( &rng->drbg, output, output_len ) ;
#else
#error "No DRBG available"
#endif
@@ -243,7 +243,7 @@
}
*candidates = first;
- return( ret );
+ return ret ;
}
#endif /* MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK */
@@ -255,13 +255,13 @@
if( first_try )
{
first_try = 0;
- return( MBEDTLS_ERR_SSL_WANT_READ );
+ return MBEDTLS_ERR_SSL_WANT_READ ;
}
ret = mbedtls_net_recv( ctx, buf, len );
if( ret != MBEDTLS_ERR_SSL_WANT_READ )
first_try = 1; /* Next call will be a new operation */
- return( ret );
+ return ret ;
}
int delayed_send( void *ctx, const unsigned char *buf, size_t len )
@@ -272,13 +272,13 @@
if( first_try )
{
first_try = 0;
- return( MBEDTLS_ERR_SSL_WANT_WRITE );
+ return MBEDTLS_ERR_SSL_WANT_WRITE ;
}
ret = mbedtls_net_send( ctx, buf, len );
if( ret != MBEDTLS_ERR_SSL_WANT_WRITE )
first_try = 1; /* Next call will be a new operation */
- return( ret );
+ return ret ;
}
#if !defined(MBEDTLS_TIMING_C)
@@ -299,7 +299,7 @@
poll_type = MBEDTLS_NET_POLL_READ;
#if !defined(MBEDTLS_TIMING_C)
else
- return( 0 );
+ return 0 ;
#endif
while( 1 )
@@ -318,13 +318,13 @@
{
ret = mbedtls_net_poll( fd, poll_type, 0 );
if( ret < 0 )
- return( ret );
+ return ret ;
if( ret == poll_type )
break;
}
}
- return( 0 );
+ return 0 ;
}
#if defined(MBEDTLS_TEST_HOOKS)
@@ -346,8 +346,8 @@
#endif
if( mbedtls_test_info.result != MBEDTLS_TEST_RESULT_SUCCESS )
- return( 1 );
- return( 0 );
+ return 1 ;
+ return 0 ;
}
void test_hooks_free( void )
diff --git a/programs/test/benchmark.c b/programs/test/benchmark.c
index 5985caf..8e22748 100644
--- a/programs/test/benchmark.c
+++ b/programs/test/benchmark.c
@@ -246,7 +246,7 @@
unsigned long tsc;
__asm rdtsc
__asm mov [tsc], eax
- return( tsc );
+ return tsc ;
}
#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
( _MSC_VER && _M_IX86 ) || __WATCOMC__ */
@@ -262,7 +262,7 @@
{
unsigned long lo, hi;
asm volatile( "rdtsc" : "=a" (lo), "=d" (hi) );
- return( lo );
+ return lo ;
}
#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
__GNUC__ && __i386__ */
@@ -276,7 +276,7 @@
{
unsigned long lo, hi;
asm volatile( "rdtsc" : "=a" (lo), "=d" (hi) );
- return( lo | ( hi << 32 ) );
+ return lo | ( hi << 32 ) ;
}
#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
__GNUC__ && ( __amd64__ || __x86_64__ ) */
@@ -298,7 +298,7 @@
}
while( tbu0 != tbu1 );
- return( tbl );
+ return tbl ;
}
#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
__GNUC__ && ( __powerpc__ || __ppc__ ) */
@@ -315,7 +315,7 @@
{
unsigned long tick;
asm volatile( "rdpr %%tick, %0;" : "=&r" (tick) );
- return( tick );
+ return tick ;
}
#endif /* __OpenBSD__ */
#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
@@ -331,7 +331,7 @@
unsigned long tick;
asm volatile( ".byte 0x83, 0x41, 0x00, 0x00" );
asm volatile( "mov %%g1, %0" : "=r" (tick) );
- return( tick );
+ return tick ;
}
#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
__GNUC__ && __sparc__ && !__sparc64__ */
@@ -345,7 +345,7 @@
{
unsigned long cc;
asm volatile( "rpcc %0" : "=r" (cc) );
- return( cc & 0xFFFFFFFF );
+ return cc & 0xFFFFFFFF ;
}
#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
__GNUC__ && __alpha__ */
@@ -359,7 +359,7 @@
{
unsigned long itc;
asm volatile( "mov %0 = ar.itc" : "=r" (itc) );
- return( itc );
+ return itc ;
}
#endif /* !HAVE_HARDCLOCK && MBEDTLS_HAVE_ASM &&
__GNUC__ && __ia64__ */
@@ -476,7 +476,7 @@
len -= use_len;
}
- return( 0 );
+ return 0 ;
}
#define CHECK_AND_CONTINUE( R ) \
@@ -523,10 +523,10 @@
if( found != NULL )
{
*curve = *found;
- return( 1 );
+ return 1 ;
}
else
- return( 0 );
+ return 0 ;
}
#endif
diff --git a/programs/test/cmake_package/cmake_package.c b/programs/test/cmake_package/cmake_package.c
index 1ae627d..4263bd9 100644
--- a/programs/test/cmake_package/cmake_package.c
+++ b/programs/test/cmake_package/cmake_package.c
@@ -45,5 +45,5 @@
mbedtls_printf( "Built against %s\n", version );
- return( 0 );
+ return 0 ;
}
diff --git a/programs/test/cmake_package_install/cmake_package_install.c b/programs/test/cmake_package_install/cmake_package_install.c
index 9d5d3e4..e8517ba 100644
--- a/programs/test/cmake_package_install/cmake_package_install.c
+++ b/programs/test/cmake_package_install/cmake_package_install.c
@@ -46,5 +46,5 @@
mbedtls_printf( "Built against %s\n", version );
- return( 0 );
+ return 0 ;
}
diff --git a/programs/test/cmake_subproject/cmake_subproject.c b/programs/test/cmake_subproject/cmake_subproject.c
index ff6ebf0..6f9d383 100644
--- a/programs/test/cmake_subproject/cmake_subproject.c
+++ b/programs/test/cmake_subproject/cmake_subproject.c
@@ -46,5 +46,5 @@
mbedtls_printf( "Built against %s\n", version );
- return( 0 );
+ return 0 ;
}
diff --git a/programs/test/query_compile_time_config.c b/programs/test/query_compile_time_config.c
index a6eaf61..e640335 100644
--- a/programs/test/query_compile_time_config.c
+++ b/programs/test/query_compile_time_config.c
@@ -43,8 +43,8 @@
if ( argc != 2 )
{
mbedtls_printf( USAGE, argv[0] );
- return( MBEDTLS_EXIT_FAILURE );
+ return MBEDTLS_EXIT_FAILURE ;
}
- return( query_config( argv[1] ) );
+ return query_config( argv[1] ) ;
}
diff --git a/programs/test/selftest.c b/programs/test/selftest.c
index c7bcc53..72180bb 100644
--- a/programs/test/selftest.c
+++ b/programs/test/selftest.c
@@ -147,7 +147,7 @@
mbedtls_free( empty2 );
mbedtls_free( buffer1 );
mbedtls_free( buffer2 );
- return( failures );
+ return failures ;
}
#endif /* MBEDTLS_SELF_TEST */
@@ -165,10 +165,10 @@
ref_ret != ret ||
memcmp( buf + n, ref + n, sizeof( buf ) - n ) != 0 )
{
- return( 1 );
+ return 1 ;
}
- return( 0 );
+ return 0 ;
}
static int run_test_snprintf( void )
@@ -220,7 +220,7 @@
#if defined(MBEDTLS_ENTROPY_NV_SEED) && !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
create_entropy_seed_file( );
#endif
- return( mbedtls_entropy_self_test( verbose ) );
+ return mbedtls_entropy_self_test( verbose ) ;
}
#endif
@@ -235,7 +235,7 @@
#endif
}
mbedtls_memory_buffer_alloc_free( );
- return( mbedtls_memory_buffer_alloc_self_test( verbose ) );
+ return mbedtls_memory_buffer_alloc_self_test( verbose ) ;
}
#endif
diff --git a/programs/test/udp_proxy.c b/programs/test/udp_proxy.c
index 6546e8f..aa01562 100644
--- a/programs/test/udp_proxy.c
+++ b/programs/test/udp_proxy.c
@@ -332,41 +332,41 @@
static const char *msg_type( unsigned char *msg, size_t len )
{
- if( len < 1 ) return( "Invalid" );
+ if( len < 1 ) return "Invalid" ;
switch( msg[0] )
{
- case MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC: return( "ChangeCipherSpec" );
- case MBEDTLS_SSL_MSG_ALERT: return( "Alert" );
- case MBEDTLS_SSL_MSG_APPLICATION_DATA: return( "ApplicationData" );
- case MBEDTLS_SSL_MSG_CID: return( "CID" );
+ case MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC: return "ChangeCipherSpec" ;
+ case MBEDTLS_SSL_MSG_ALERT: return "Alert" ;
+ case MBEDTLS_SSL_MSG_APPLICATION_DATA: return "ApplicationData" ;
+ case MBEDTLS_SSL_MSG_CID: return "CID" ;
case MBEDTLS_SSL_MSG_HANDSHAKE: break; /* See below */
- default: return( "Unknown" );
+ default: return "Unknown" ;
}
- if( len < 13 + 12 ) return( "Invalid handshake" );
+ if( len < 13 + 12 ) return "Invalid handshake" ;
/*
* Our handshake message are less than 2^16 bytes long, so they should
* have 0 as the first byte of length, frag_offset and frag_length.
* Otherwise, assume they are encrypted.
*/
- if( msg[14] || msg[19] || msg[22] ) return( "Encrypted handshake" );
+ if( msg[14] || msg[19] || msg[22] ) return "Encrypted handshake" ;
switch( msg[13] )
{
- case MBEDTLS_SSL_HS_HELLO_REQUEST: return( "HelloRequest" );
- case MBEDTLS_SSL_HS_CLIENT_HELLO: return( "ClientHello" );
- case MBEDTLS_SSL_HS_SERVER_HELLO: return( "ServerHello" );
- case MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST: return( "HelloVerifyRequest" );
- case MBEDTLS_SSL_HS_NEW_SESSION_TICKET: return( "NewSessionTicket" );
- case MBEDTLS_SSL_HS_CERTIFICATE: return( "Certificate" );
- case MBEDTLS_SSL_HS_SERVER_KEY_EXCHANGE: return( "ServerKeyExchange" );
- case MBEDTLS_SSL_HS_CERTIFICATE_REQUEST: return( "CertificateRequest" );
- case MBEDTLS_SSL_HS_SERVER_HELLO_DONE: return( "ServerHelloDone" );
- case MBEDTLS_SSL_HS_CERTIFICATE_VERIFY: return( "CertificateVerify" );
- case MBEDTLS_SSL_HS_CLIENT_KEY_EXCHANGE: return( "ClientKeyExchange" );
- case MBEDTLS_SSL_HS_FINISHED: return( "Finished" );
- default: return( "Unknown handshake" );
+ case MBEDTLS_SSL_HS_HELLO_REQUEST: return "HelloRequest" ;
+ case MBEDTLS_SSL_HS_CLIENT_HELLO: return "ClientHello" ;
+ case MBEDTLS_SSL_HS_SERVER_HELLO: return "ServerHello" ;
+ case MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST: return "HelloVerifyRequest" ;
+ case MBEDTLS_SSL_HS_NEW_SESSION_TICKET: return "NewSessionTicket" ;
+ case MBEDTLS_SSL_HS_CERTIFICATE: return "Certificate" ;
+ case MBEDTLS_SSL_HS_SERVER_KEY_EXCHANGE: return "ServerKeyExchange" ;
+ case MBEDTLS_SSL_HS_CERTIFICATE_REQUEST: return "CertificateRequest" ;
+ case MBEDTLS_SSL_HS_SERVER_HELLO_DONE: return "ServerHelloDone" ;
+ case MBEDTLS_SSL_HS_CERTIFICATE_VERIFY: return "CertificateVerify" ;
+ case MBEDTLS_SSL_HS_CLIENT_KEY_EXCHANGE: return "ClientKeyExchange" ;
+ case MBEDTLS_SSL_HS_FINISHED: return "Finished" ;
+ default: return "Unknown handshake" ;
}
}
@@ -381,10 +381,10 @@
{
(void) mbedtls_timing_get_timer( &hires, 1 );
initialized = 1;
- return( 0 );
+ return 0 ;
}
- return( mbedtls_timing_get_timer( &hires, 0 ) );
+ return mbedtls_timing_get_timer( &hires, 0 ) ;
}
typedef struct
@@ -417,7 +417,7 @@
buf->len = 0;
buf->num_datagrams = 0;
- return( ret );
+ return ret ;
}
static unsigned ctx_buffer_time_remaining( ctx_buffer *buf )
@@ -425,12 +425,12 @@
unsigned const cur_time = ellapsed_time();
if( buf->num_datagrams == 0 )
- return( (unsigned) -1 );
+ return (unsigned) -1 ;
if( cur_time - buf->packet_lifetime >= opt.pack )
- return( 0 );
+ return 0 ;
- return( opt.pack - ( cur_time - buf->packet_lifetime ) );
+ return opt.pack - ( cur_time - buf->packet_lifetime ) ;
}
static int ctx_buffer_append( ctx_buffer *buf,
@@ -440,13 +440,13 @@
int ret;
if( len > (size_t) INT_MAX )
- return( -1 );
+ return -1 ;
if( len > sizeof( buf->data ) )
{
mbedtls_printf( " ! buffer size %u too large (max %u)\n",
(unsigned) len, (unsigned) sizeof( buf->data ) );
- return( -1 );
+ return -1 ;
}
if( sizeof( buf->data ) - buf->len < len )
@@ -454,7 +454,7 @@
if( ( ret = ctx_buffer_flush( buf ) ) <= 0 )
{
mbedtls_printf( "ctx_buffer_flush failed with -%#04x", (unsigned int) -ret );
- return( ret );
+ return ret ;
}
}
@@ -464,7 +464,7 @@
if( ++buf->num_datagrams == 1 )
buf->packet_lifetime = ellapsed_time();
- return( (int) len );
+ return (int) len ;
}
#endif /* MBEDTLS_TIMING_C */
@@ -483,9 +483,9 @@
buf = &outbuf[1];
if( buf == NULL )
- return( -1 );
+ return -1 ;
- return( ctx_buffer_append( buf, data, len ) );
+ return ctx_buffer_append( buf, data, len ) ;
}
#endif /* MBEDTLS_TIMING_C */
@@ -494,7 +494,7 @@
{
mbedtls_printf( "net_send returned -%#04x\n", (unsigned int) -ret );
}
- return( ret );
+ return ret ;
}
typedef struct
@@ -578,7 +578,7 @@
if( ( ret = dispatch_data( dst, buf, p->len ) ) <= 0 )
{
mbedtls_printf( " ! dispatch returned %d\n", ret );
- return( ret );
+ return ret ;
}
}
@@ -602,7 +602,7 @@
if( ( ret = dispatch_data( dst, buf, p->len ) ) <= 0 )
{
mbedtls_printf( " ! dispatch returned %d\n", ret );
- return( ret );
+ return ret ;
}
}
@@ -610,7 +610,7 @@
if( ( ret = dispatch_data( dst, p->buf, p->len ) ) <= 0 )
{
mbedtls_printf( " ! dispatch returned %d\n", ret );
- return( ret );
+ return ret ;
}
/* Don't duplicate Application Data, only handshake covered */
@@ -623,7 +623,7 @@
if( ( ret = dispatch_data( dst, p->buf, p->len ) ) <= 0 )
{
mbedtls_printf( " ! dispatch returned %d\n", ret );
- return( ret );
+ return ret ;
}
}
@@ -638,13 +638,13 @@
initial_clihlo.len ) ) <= 0 )
{
mbedtls_printf( " ! dispatch returned %d\n", ret );
- return( ret );
+ return ret ;
}
inject_clihlo_state = ICH_INJECTED;
}
- return( 0 );
+ return 0 ;
}
#define MAX_DELAYED_MSG 5
@@ -673,11 +673,11 @@
{
ret = send_packet( &prev[offset], "delayed" );
if( ret != 0 )
- return( ret );
+ return ret ;
}
clear_pending();
- return( 0 );
+ return 0 ;
}
/*
@@ -713,7 +713,7 @@
if( ( ret = mbedtls_net_recv( src, cur.buf, sizeof( cur.buf ) ) ) <= 0 )
{
mbedtls_printf( " ! mbedtls_net_recv returned %d\n", ret );
- return( ret );
+ return ret ;
}
cur.len = ret;
@@ -751,7 +751,7 @@
mbedtls_free( delay_list[delay_idx] );
delay_list[delay_idx] = NULL;
- return( 0 );
+ return 0 ;
}
}
@@ -787,15 +787,15 @@
{
/* forward and possibly duplicate */
if( ( ret = send_packet( &cur, "forwarded" ) ) != 0 )
- return( ret );
+ return ret ;
/* send previously delayed messages if any */
ret = send_delayed();
if( ret != 0 )
- return( ret );
+ return ret ;
}
- return( 0 );
+ return 0 ;
}
int main( int argc, char *argv[] )
diff --git a/programs/util/pem2der.c b/programs/util/pem2der.c
index e273200..f70aaee 100644
--- a/programs/util/pem2der.c
+++ b/programs/util/pem2der.c
@@ -78,11 +78,11 @@
s1 = (unsigned char *) strstr( (const char *) input, "-----BEGIN" );
if( s1 == NULL )
- return( -1 );
+ return -1 ;
s2 = (unsigned char *) strstr( (const char *) input, "-----END" );
if( s2 == NULL )
- return( -1 );
+ return -1 ;
s1 += 10;
while( s1 < end && *s1 != '-' )
@@ -93,24 +93,24 @@
if( *s1 == '\n' ) s1++;
if( s2 <= s1 || s2 > end )
- return( -1 );
+ return -1 ;
ret = mbedtls_base64_decode( NULL, 0, &len, (const unsigned char *) s1, s2 - s1 );
if( ret == MBEDTLS_ERR_BASE64_INVALID_CHARACTER )
- return( ret );
+ return ret ;
if( len > *olen )
- return( -1 );
+ return -1 ;
if( ( ret = mbedtls_base64_decode( output, len, &len, (const unsigned char *) s1,
s2 - s1 ) ) != 0 )
{
- return( ret );
+ return ret ;
}
*olen = len;
- return( 0 );
+ return 0 ;
}
/*
@@ -122,13 +122,13 @@
long size;
if( ( f = fopen( path, "rb" ) ) == NULL )
- return( -1 );
+ return -1 ;
fseek( f, 0, SEEK_END );
if( ( size = ftell( f ) ) == -1 )
{
fclose( f );
- return( -1 );
+ return -1 ;
}
fseek( f, 0, SEEK_SET );
@@ -138,7 +138,7 @@
( *buf = mbedtls_calloc( 1, *n + 1 ) ) == NULL )
{
fclose( f );
- return( -1 );
+ return -1 ;
}
if( fread( *buf, 1, *n, f ) != *n )
@@ -146,14 +146,14 @@
fclose( f );
free( *buf );
*buf = NULL;
- return( -1 );
+ return -1 ;
}
fclose( f );
(*buf)[*n] = '\0';
- return( 0 );
+ return 0 ;
}
/*
@@ -164,16 +164,16 @@
FILE *f;
if( ( f = fopen( path, "wb" ) ) == NULL )
- return( -1 );
+ return -1 ;
if( fwrite( buf, 1, n, f ) != n )
{
fclose( f );
- return( -1 );
+ return -1 ;
}
fclose( f );
- return( 0 );
+ return 0 ;
}
int main( int argc, char *argv[] )
diff --git a/programs/util/strerror.c b/programs/util/strerror.c
index 4b776d3..dda6916 100644
--- a/programs/util/strerror.c
+++ b/programs/util/strerror.c
@@ -65,7 +65,7 @@
if( *end != '\0' )
{
mbedtls_printf( USAGE );
- return( 0 );
+ return 0 ;
}
}
if( val > 0 )
diff --git a/programs/x509/cert_app.c b/programs/x509/cert_app.c
index aab15db..65276e7 100644
--- a/programs/x509/cert_app.c
+++ b/programs/x509/cert_app.c
@@ -138,7 +138,7 @@
mbedtls_printf( "%s\n", buf );
}
- return( 0 );
+ return 0 ;
}
int main( int argc, char *argv[] )
diff --git a/programs/x509/cert_req.c b/programs/x509/cert_req.c
index ed42079..03dbd20 100644
--- a/programs/x509/cert_req.c
+++ b/programs/x509/cert_req.c
@@ -129,22 +129,22 @@
memset( output_buf, 0, 4096 );
if( ( ret = mbedtls_x509write_csr_pem( req, output_buf, 4096, f_rng, p_rng ) ) < 0 )
- return( ret );
+ return ret ;
len = strlen( (char *) output_buf );
if( ( f = fopen( output_file, "w" ) ) == NULL )
- return( -1 );
+ return -1 ;
if( fwrite( output_buf, 1, len, f ) != len )
{
fclose( f );
- return( -1 );
+ return -1 ;
}
fclose( f );
- return( 0 );
+ return 0 ;
}
int main( int argc, char *argv[] )
diff --git a/programs/x509/cert_write.c b/programs/x509/cert_write.c
index 9a20d63..72e823f 100644
--- a/programs/x509/cert_write.c
+++ b/programs/x509/cert_write.c
@@ -191,22 +191,22 @@
memset( output_buf, 0, 4096 );
if( ( ret = mbedtls_x509write_crt_pem( crt, output_buf, 4096,
f_rng, p_rng ) ) < 0 )
- return( ret );
+ return ret ;
len = strlen( (char *) output_buf );
if( ( f = fopen( output_file, "w" ) ) == NULL )
- return( -1 );
+ return -1 ;
if( fwrite( output_buf, 1, len, f ) != len )
{
fclose( f );
- return( -1 );
+ return -1 ;
}
fclose( f );
- return( 0 );
+ return 0 ;
}
int main( int argc, char *argv[] )