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/des.c b/library/des.c
index eddf55e..9908582 100644
--- a/library/des.c
+++ b/library/des.c
@@ -357,9 +357,9 @@
for( i = 0; i < MBEDTLS_DES_KEY_SIZE; i++ )
if( key[i] != odd_parity_table[key[i] / 2] )
- return( 1 );
+ return 1 ;
- return( 0 );
+ return 0 ;
}
/*
@@ -412,9 +412,9 @@
for( i = 0; i < WEAK_KEY_COUNT; i++ )
if( memcmp( weak_key_table[i], key, MBEDTLS_DES_KEY_SIZE) == 0 )
- return( 1 );
+ return 1 ;
- return( 0 );
+ return 0 ;
}
#if !defined(MBEDTLS_DES_SETKEY_ALT)
@@ -495,7 +495,7 @@
{
mbedtls_des_setkey( ctx->sk, key );
- return( 0 );
+ return 0 ;
}
/*
@@ -513,7 +513,7 @@
SWAP( ctx->sk[i + 1], ctx->sk[31 - i] );
}
- return( 0 );
+ return 0 ;
}
static void des3_set2key( uint32_t esk[96],
@@ -552,7 +552,7 @@
des3_set2key( ctx->sk, sk, key );
mbedtls_platform_zeroize( sk, sizeof( sk ) );
- return( 0 );
+ return 0 ;
}
/*
@@ -566,7 +566,7 @@
des3_set2key( sk, ctx->sk, key );
mbedtls_platform_zeroize( sk, sizeof( sk ) );
- return( 0 );
+ return 0 ;
}
static void des3_set3key( uint32_t esk[96],
@@ -603,7 +603,7 @@
des3_set3key( ctx->sk, sk, key );
mbedtls_platform_zeroize( sk, sizeof( sk ) );
- return( 0 );
+ return 0 ;
}
/*
@@ -617,7 +617,7 @@
des3_set3key( sk, ctx->sk, key );
mbedtls_platform_zeroize( sk, sizeof( sk ) );
- return( 0 );
+ return 0 ;
}
/*
@@ -649,7 +649,7 @@
PUT_UINT32_BE( Y, output, 0 );
PUT_UINT32_BE( X, output, 4 );
- return( 0 );
+ return 0 ;
}
#endif /* !MBEDTLS_DES_CRYPT_ECB_ALT */
@@ -668,7 +668,7 @@
unsigned char temp[8];
if( length % 8 )
- return( MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH );
+ return MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH ;
if( mode == MBEDTLS_DES_ENCRYPT )
{
@@ -703,7 +703,7 @@
}
}
- return( 0 );
+ return 0 ;
}
#endif /* MBEDTLS_CIPHER_MODE_CBC */
@@ -748,7 +748,7 @@
PUT_UINT32_BE( Y, output, 0 );
PUT_UINT32_BE( X, output, 4 );
- return( 0 );
+ return 0 ;
}
#endif /* !MBEDTLS_DES3_CRYPT_ECB_ALT */
@@ -767,7 +767,7 @@
unsigned char temp[8];
if( length % 8 )
- return( MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH );
+ return MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH ;
if( mode == MBEDTLS_DES_ENCRYPT )
{
@@ -802,7 +802,7 @@
}
}
- return( 0 );
+ return 0 ;
}
#endif /* MBEDTLS_CIPHER_MODE_CBC */
@@ -919,7 +919,7 @@
break;
default:
- return( 1 );
+ return 1 ;
}
for( j = 0; j < 100; j++ )
@@ -994,7 +994,7 @@
break;
default:
- return( 1 );
+ return 1 ;
}
if( v == MBEDTLS_DES_DECRYPT )
@@ -1050,7 +1050,7 @@
mbedtls_des_free( &ctx );
mbedtls_des3_free( &ctx3 );
- return( ret );
+ return ret ;
}
#endif /* MBEDTLS_SELF_TEST */