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/tests/suites/test_suite_mpi.function b/tests/suites/test_suite_mpi.function
index 1372668..5c184cb 100644
--- a/tests/suites/test_suite_mpi.function
+++ b/tests/suites/test_suite_mpi.function
@@ -12,10 +12,10 @@
static int sign_is_valid( const mbedtls_mpi *X )
{
if( X->s != 1 && X->s != -1 )
- return( 0 ); // invalid sign bit, e.g. 0
+ return 0 ; // invalid sign bit, e.g. 0
if( mbedtls_mpi_bitlen( X ) == 0 && X->s != 1 )
- return( 0 ); // negative zero
- return( 1 );
+ return 0 ; // negative zero
+ return 1 ;
}
typedef struct mbedtls_test_mpi_random
@@ -38,12 +38,12 @@
mbedtls_test_mpi_random *random = (mbedtls_test_mpi_random*) state;
if( random == NULL || random->data->x == NULL || buf == NULL )
- return( -1 );
+ return -1 ;
if( random->pos + random->chunk_len > random->data->len
|| random->chunk_len > len )
{
- return( -1 );
+ return -1 ;
}
memset( buf, 0, len );
@@ -58,7 +58,7 @@
random->pos += random->chunk_len;
- return( 0 );
+ return 0 ;
}
/* Random generator that is told how many bytes to return. */
@@ -69,11 +69,11 @@
for( i = 0; i < len; i++ )
{
if( *bytes_left == 0 )
- return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
+ return MBEDTLS_ERR_ENTROPY_SOURCE_FAILED ;
buf[i] = *bytes_left & 0xff;
--( *bytes_left );
}
- return( 0 );
+ return 0 ;
}
/* Test whether bytes represents (in big-endian base 256) a number b that
@@ -101,7 +101,7 @@
}
/* 0 is not significantly above a power of 2 */
if( len == 0 )
- return( 0 );
+ return 0 ;
/* Extract the (up to) 2 most significant bytes */
if( len == 1 )
x = p[0];
@@ -117,7 +117,7 @@
* a power of 2 iff x is significantly above 0 compared to 2^8.
* Testing x >= 2^4 amounts to picking A = 1/16 in the function
* description above. */
- return( x >= 0x10 );
+ return x >= 0x10 ;
}
/* END_HEADER */