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/library/ssl_cookie.c b/library/ssl_cookie.c
index 40b8913..f310a64 100644
--- a/library/ssl_cookie.c
+++ b/library/ssl_cookie.c
@@ -102,19 +102,19 @@
unsigned char key[COOKIE_MD_OUTLEN];
if( ( ret = f_rng( p_rng, key, sizeof( key ) ) ) != 0 )
- return( ret );
+ return ret ;
ret = mbedtls_md_setup( &ctx->hmac_ctx, mbedtls_md_info_from_type( COOKIE_MD ), 1 );
if( ret != 0 )
- return( ret );
+ return ret ;
ret = mbedtls_md_hmac_starts( &ctx->hmac_ctx, key, sizeof( key ) );
if( ret != 0 )
- return( ret );
+ return ret ;
mbedtls_platform_zeroize( key, sizeof( key ) );
- return( 0 );
+ return 0 ;
}
/*
@@ -134,13 +134,13 @@
mbedtls_md_hmac_update( hmac_ctx, cli_id, cli_id_len ) != 0 ||
mbedtls_md_hmac_finish( hmac_ctx, hmac_out ) != 0 )
{
- return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
+ return MBEDTLS_ERR_SSL_INTERNAL_ERROR ;
}
memcpy( *p, hmac_out, COOKIE_HMAC_LEN );
*p += COOKIE_HMAC_LEN;
- return( 0 );
+ return 0 ;
}
/*
@@ -155,7 +155,7 @@
unsigned long t;
if( ctx == NULL || cli_id == NULL )
- return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
+ return MBEDTLS_ERR_SSL_BAD_INPUT_DATA ;
MBEDTLS_SSL_CHK_BUF_PTR( *p, end, COOKIE_LEN );
@@ -173,7 +173,7 @@
#if defined(MBEDTLS_THREADING_C)
if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 )
- return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_SSL_INTERNAL_ERROR, ret ) );
+ return MBEDTLS_ERROR_ADD( MBEDTLS_ERR_SSL_INTERNAL_ERROR, ret ) ;
#endif
ret = ssl_cookie_hmac( &ctx->hmac_ctx, *p - 4,
@@ -185,7 +185,7 @@
MBEDTLS_ERR_THREADING_MUTEX_ERROR ) );
#endif
- return( ret );
+ return ret ;
}
/*
@@ -202,14 +202,14 @@
unsigned long cur_time, cookie_time;
if( ctx == NULL || cli_id == NULL )
- return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
+ return MBEDTLS_ERR_SSL_BAD_INPUT_DATA ;
if( cookie_len != COOKIE_LEN )
- return( -1 );
+ return -1 ;
#if defined(MBEDTLS_THREADING_C)
if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 )
- return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_SSL_INTERNAL_ERROR, ret ) );
+ return MBEDTLS_ERROR_ADD( MBEDTLS_ERR_SSL_INTERNAL_ERROR, ret ) ;
#endif
if( ssl_cookie_hmac( &ctx->hmac_ctx, cookie,
@@ -224,10 +224,10 @@
#endif
if( ret != 0 )
- return( ret );
+ return ret ;
if( mbedtls_ssl_safer_memcmp( cookie + 4, ref_hmac, sizeof( ref_hmac ) ) != 0 )
- return( -1 );
+ return -1 ;
#if defined(MBEDTLS_HAVE_TIME)
cur_time = (unsigned long) mbedtls_time( NULL );
@@ -241,8 +241,8 @@
( (unsigned long) cookie[3] );
if( ctx->timeout != 0 && cur_time - cookie_time > ctx->timeout )
- return( -1 );
+ return -1 ;
- return( 0 );
+ return 0 ;
}
#endif /* MBEDTLS_SSL_COOKIE_C */