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/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 )