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/include/psa/crypto_compat.h b/include/psa/crypto_compat.h
index 1d3253c..ca35a2f 100644
--- a/include/psa/crypto_compat.h
+++ b/include/psa/crypto_compat.h
@@ -52,7 +52,7 @@
*/
static inline int psa_key_handle_is_null( psa_key_handle_t handle )
{
- return( mbedtls_svc_key_id_is_null( handle ) );
+ return mbedtls_svc_key_id_is_null( handle ) ;
}
/** Open a handle to an existing persistent key.
diff --git a/include/psa/crypto_extra.h b/include/psa/crypto_extra.h
index 2c0b106..aa50dc9 100644
--- a/include/psa/crypto_extra.h
+++ b/include/psa/crypto_extra.h
@@ -596,46 +596,46 @@
{
case MBEDTLS_ECP_DP_SECP192R1:
*bits = 192;
- return( PSA_ECC_FAMILY_SECP_R1 );
+ return PSA_ECC_FAMILY_SECP_R1 ;
case MBEDTLS_ECP_DP_SECP224R1:
*bits = 224;
- return( PSA_ECC_FAMILY_SECP_R1 );
+ return PSA_ECC_FAMILY_SECP_R1 ;
case MBEDTLS_ECP_DP_SECP256R1:
*bits = 256;
- return( PSA_ECC_FAMILY_SECP_R1 );
+ return PSA_ECC_FAMILY_SECP_R1 ;
case MBEDTLS_ECP_DP_SECP384R1:
*bits = 384;
- return( PSA_ECC_FAMILY_SECP_R1 );
+ return PSA_ECC_FAMILY_SECP_R1 ;
case MBEDTLS_ECP_DP_SECP521R1:
*bits = 521;
- return( PSA_ECC_FAMILY_SECP_R1 );
+ return PSA_ECC_FAMILY_SECP_R1 ;
case MBEDTLS_ECP_DP_BP256R1:
*bits = 256;
- return( PSA_ECC_FAMILY_BRAINPOOL_P_R1 );
+ return PSA_ECC_FAMILY_BRAINPOOL_P_R1 ;
case MBEDTLS_ECP_DP_BP384R1:
*bits = 384;
- return( PSA_ECC_FAMILY_BRAINPOOL_P_R1 );
+ return PSA_ECC_FAMILY_BRAINPOOL_P_R1 ;
case MBEDTLS_ECP_DP_BP512R1:
*bits = 512;
- return( PSA_ECC_FAMILY_BRAINPOOL_P_R1 );
+ return PSA_ECC_FAMILY_BRAINPOOL_P_R1 ;
case MBEDTLS_ECP_DP_CURVE25519:
*bits = 255;
- return( PSA_ECC_FAMILY_MONTGOMERY );
+ return PSA_ECC_FAMILY_MONTGOMERY ;
case MBEDTLS_ECP_DP_SECP192K1:
*bits = 192;
- return( PSA_ECC_FAMILY_SECP_K1 );
+ return PSA_ECC_FAMILY_SECP_K1 ;
case MBEDTLS_ECP_DP_SECP224K1:
*bits = 224;
- return( PSA_ECC_FAMILY_SECP_K1 );
+ return PSA_ECC_FAMILY_SECP_K1 ;
case MBEDTLS_ECP_DP_SECP256K1:
*bits = 256;
- return( PSA_ECC_FAMILY_SECP_K1 );
+ return PSA_ECC_FAMILY_SECP_K1 ;
case MBEDTLS_ECP_DP_CURVE448:
*bits = 448;
- return( PSA_ECC_FAMILY_MONTGOMERY );
+ return PSA_ECC_FAMILY_MONTGOMERY ;
default:
*bits = 0;
- return( 0 );
+ return 0 ;
}
}
@@ -1754,7 +1754,7 @@
static inline psa_algorithm_t psa_pake_cs_get_algorithm(
const psa_pake_cipher_suite_t *cipher_suite)
{
- return(cipher_suite->algorithm);
+ return cipher_suite->algorithm;
}
static inline void psa_pake_cs_set_algorithm(
@@ -1786,7 +1786,7 @@
static inline psa_algorithm_t psa_pake_cs_get_hash(
const psa_pake_cipher_suite_t *cipher_suite)
{
- return(cipher_suite->hash);
+ return cipher_suite->hash;
}
static inline void psa_pake_cs_set_hash(
@@ -1814,7 +1814,7 @@
static inline struct psa_pake_operation_s psa_pake_operation_init(void)
{
const struct psa_pake_operation_s v = PSA_PAKE_OPERATION_INIT;
- return(v);
+ return v;
}
#ifdef __cplusplus
diff --git a/include/psa/crypto_platform.h b/include/psa/crypto_platform.h
index 4787e44..5f1e5c0 100644
--- a/include/psa/crypto_platform.h
+++ b/include/psa/crypto_platform.h
@@ -73,7 +73,7 @@
static inline int mbedtls_key_owner_id_equal( mbedtls_key_owner_id_t id1,
mbedtls_key_owner_id_t id2 )
{
- return( id1 == id2 );
+ return id1 == id2 ;
}
#endif /* MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */
diff --git a/include/psa/crypto_struct.h b/include/psa/crypto_struct.h
index 381abf9..ae732c3 100644
--- a/include/psa/crypto_struct.h
+++ b/include/psa/crypto_struct.h
@@ -93,7 +93,7 @@
static inline struct psa_hash_operation_s psa_hash_operation_init( void )
{
const struct psa_hash_operation_s v = PSA_HASH_OPERATION_INIT;
- return( v );
+ return v ;
}
struct psa_cipher_operation_s
@@ -118,7 +118,7 @@
static inline struct psa_cipher_operation_s psa_cipher_operation_init( void )
{
const struct psa_cipher_operation_s v = PSA_CIPHER_OPERATION_INIT;
- return( v );
+ return v ;
}
/* Include the context definition for the compiled-in drivers for the composite
@@ -143,7 +143,7 @@
static inline struct psa_mac_operation_s psa_mac_operation_init( void )
{
const struct psa_mac_operation_s v = PSA_MAC_OPERATION_INIT;
- return( v );
+ return v ;
}
struct psa_aead_operation_s
@@ -164,7 +164,7 @@
static inline struct psa_aead_operation_s psa_aead_operation_init( void )
{
const struct psa_aead_operation_s v = PSA_AEAD_OPERATION_INIT;
- return( v );
+ return v ;
}
#if defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF)
@@ -251,7 +251,7 @@
void )
{
const struct psa_key_derivation_s v = PSA_KEY_DERIVATION_OPERATION_INIT;
- return( v );
+ return v ;
}
struct psa_key_policy_s
@@ -266,7 +266,7 @@
static inline struct psa_key_policy_s psa_key_policy_init( void )
{
const struct psa_key_policy_s v = PSA_KEY_POLICY_INIT;
- return( v );
+ return v ;
}
/* The type used internally for key sizes.
@@ -339,7 +339,7 @@
static inline struct psa_key_attributes_s psa_key_attributes_init( void )
{
const struct psa_key_attributes_s v = PSA_KEY_ATTRIBUTES_INIT;
- return( v );
+ return v ;
}
static inline void psa_set_key_id( psa_key_attributes_t *attributes,
diff --git a/include/psa/crypto_values.h b/include/psa/crypto_values.h
index daef941..0bf9098 100644
--- a/include/psa/crypto_values.h
+++ b/include/psa/crypto_values.h
@@ -2094,7 +2094,7 @@
{
(void)unused;
- return( key_id );
+ return key_id ;
}
/** Compare two key identifiers.
@@ -2107,7 +2107,7 @@
static inline int mbedtls_svc_key_id_equal( mbedtls_svc_key_id_t id1,
mbedtls_svc_key_id_t id2 )
{
- return( id1 == id2 );
+ return id1 == id2 ;
}
/** Check whether a key identifier is null.
@@ -2118,7 +2118,7 @@
*/
static inline int mbedtls_svc_key_id_is_null( mbedtls_svc_key_id_t key )
{
- return( key == 0 );
+ return key == 0 ;
}
#else /* MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */
@@ -2161,7 +2161,7 @@
*/
static inline int mbedtls_svc_key_id_is_null( mbedtls_svc_key_id_t key )
{
- return( key.MBEDTLS_PRIVATE(key_id) == 0 );
+ return key.MBEDTLS_PRIVATE(key_id) == 0 ;
}
#endif /* !MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */