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/src/drivers/test_driver_cipher.c b/tests/src/drivers/test_driver_cipher.c
index 89a7b59..20d79d8 100644
--- a/tests/src/drivers/test_driver_cipher.c
+++ b/tests/src/drivers/test_driver_cipher.c
@@ -51,18 +51,18 @@
if( mbedtls_test_driver_cipher_hooks.forced_output != NULL )
{
if( output_size < mbedtls_test_driver_cipher_hooks.forced_output_length )
- return( PSA_ERROR_BUFFER_TOO_SMALL );
+ return PSA_ERROR_BUFFER_TOO_SMALL ;
memcpy( output,
mbedtls_test_driver_cipher_hooks.forced_output,
mbedtls_test_driver_cipher_hooks.forced_output_length );
*output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
- return( mbedtls_test_driver_cipher_hooks.forced_status );
+ return mbedtls_test_driver_cipher_hooks.forced_status ;
}
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
- return( mbedtls_test_driver_cipher_hooks.forced_status );
+ return mbedtls_test_driver_cipher_hooks.forced_status ;
psa_generate_random( output, PSA_CIPHER_IV_LENGTH( attributes->core.type, alg ) );
@@ -88,18 +88,18 @@
if( mbedtls_test_driver_cipher_hooks.forced_output != NULL )
{
if( output_size < mbedtls_test_driver_cipher_hooks.forced_output_length )
- return( PSA_ERROR_BUFFER_TOO_SMALL );
+ return PSA_ERROR_BUFFER_TOO_SMALL ;
memcpy( output,
mbedtls_test_driver_cipher_hooks.forced_output,
mbedtls_test_driver_cipher_hooks.forced_output_length );
*output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
- return( mbedtls_test_driver_cipher_hooks.forced_status );
+ return mbedtls_test_driver_cipher_hooks.forced_status ;
}
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
- return( mbedtls_test_driver_cipher_hooks.forced_status );
+ return mbedtls_test_driver_cipher_hooks.forced_status ;
return( mbedtls_transparent_test_driver_cipher_decrypt(
attributes, key_buffer, key_buffer_size,
@@ -122,7 +122,7 @@
memset( operation, 0, sizeof( *operation ) );
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
- return( mbedtls_test_driver_cipher_hooks.forced_status );
+ return mbedtls_test_driver_cipher_hooks.forced_status ;
return ( mbedtls_transparent_test_driver_cipher_encrypt_setup(
operation, attributes, key, key_length, alg ) );
@@ -137,7 +137,7 @@
mbedtls_test_driver_cipher_hooks.hits++;
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
- return( mbedtls_test_driver_cipher_hooks.forced_status );
+ return mbedtls_test_driver_cipher_hooks.forced_status ;
return ( mbedtls_transparent_test_driver_cipher_decrypt_setup(
operation, attributes, key, key_length, alg ) );
@@ -149,7 +149,7 @@
mbedtls_test_driver_cipher_hooks.hits++;
if( operation->alg == 0 )
- return( PSA_SUCCESS );
+ return PSA_SUCCESS ;
mbedtls_transparent_test_driver_cipher_abort( operation );
@@ -159,7 +159,7 @@
* our context struct. */
memset( operation, 0, sizeof( *operation ) );
- return( mbedtls_test_driver_cipher_hooks.forced_status );
+ return mbedtls_test_driver_cipher_hooks.forced_status ;
}
psa_status_t mbedtls_test_transparent_cipher_set_iv(
@@ -170,7 +170,7 @@
mbedtls_test_driver_cipher_hooks.hits++;
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
- return( mbedtls_test_driver_cipher_hooks.forced_status );
+ return mbedtls_test_driver_cipher_hooks.forced_status ;
return( mbedtls_transparent_test_driver_cipher_set_iv(
operation, iv, iv_length ) );
@@ -196,11 +196,11 @@
mbedtls_test_driver_cipher_hooks.forced_output_length );
*output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
- return( mbedtls_test_driver_cipher_hooks.forced_status );
+ return mbedtls_test_driver_cipher_hooks.forced_status ;
}
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
- return( mbedtls_test_driver_cipher_hooks.forced_status );
+ return mbedtls_test_driver_cipher_hooks.forced_status ;
return( mbedtls_transparent_test_driver_cipher_update(
operation, input, input_length,
@@ -225,11 +225,11 @@
mbedtls_test_driver_cipher_hooks.forced_output_length );
*output_length = mbedtls_test_driver_cipher_hooks.forced_output_length;
- return( mbedtls_test_driver_cipher_hooks.forced_status );
+ return mbedtls_test_driver_cipher_hooks.forced_status ;
}
if( mbedtls_test_driver_cipher_hooks.forced_status != PSA_SUCCESS )
- return( mbedtls_test_driver_cipher_hooks.forced_status );
+ return mbedtls_test_driver_cipher_hooks.forced_status ;
return( mbedtls_transparent_test_driver_cipher_finish(
operation, output, output_size, output_length ) );
@@ -254,7 +254,7 @@
(void) output;
(void) output_size;
(void) output_length;
- return( PSA_ERROR_NOT_SUPPORTED );
+ return PSA_ERROR_NOT_SUPPORTED ;
}
psa_status_t mbedtls_test_opaque_cipher_decrypt(
@@ -273,7 +273,7 @@
(void) output;
(void) output_size;
(void) output_length;
- return( PSA_ERROR_NOT_SUPPORTED );
+ return PSA_ERROR_NOT_SUPPORTED ;
}
psa_status_t mbedtls_test_opaque_cipher_encrypt_setup(
@@ -287,7 +287,7 @@
(void) key;
(void) key_length;
(void) alg;
- return( PSA_ERROR_NOT_SUPPORTED );
+ return PSA_ERROR_NOT_SUPPORTED ;
}
psa_status_t mbedtls_test_opaque_cipher_decrypt_setup(
@@ -301,14 +301,14 @@
(void) key;
(void) key_length;
(void) alg;
- return( PSA_ERROR_NOT_SUPPORTED );
+ return PSA_ERROR_NOT_SUPPORTED ;
}
psa_status_t mbedtls_test_opaque_cipher_abort(
mbedtls_opaque_test_driver_cipher_operation_t *operation )
{
(void) operation;
- return( PSA_ERROR_NOT_SUPPORTED );
+ return PSA_ERROR_NOT_SUPPORTED ;
}
psa_status_t mbedtls_test_opaque_cipher_set_iv(
@@ -319,7 +319,7 @@
(void) operation;
(void) iv;
(void) iv_length;
- return( PSA_ERROR_NOT_SUPPORTED );
+ return PSA_ERROR_NOT_SUPPORTED ;
}
psa_status_t mbedtls_test_opaque_cipher_update(
@@ -336,7 +336,7 @@
(void) output;
(void) output_size;
(void) output_length;
- return( PSA_ERROR_NOT_SUPPORTED );
+ return PSA_ERROR_NOT_SUPPORTED ;
}
psa_status_t mbedtls_test_opaque_cipher_finish(
@@ -349,6 +349,6 @@
(void) output;
(void) output_size;
(void) output_length;
- return( PSA_ERROR_NOT_SUPPORTED );
+ return PSA_ERROR_NOT_SUPPORTED ;
}
#endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && PSA_CRYPTO_DRIVER_TEST */