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/ripemd160.c b/library/ripemd160.c
index d2ccbbe..1553558 100644
--- a/library/ripemd160.c
+++ b/library/ripemd160.c
@@ -100,7 +100,7 @@
ctx->state[3] = 0x10325476;
ctx->state[4] = 0xC3D2E1F0;
- return( 0 );
+ return 0 ;
}
#if !defined(MBEDTLS_RIPEMD160_PROCESS_ALT)
@@ -297,7 +297,7 @@
/* Zeroise variables to clear sensitive data from memory. */
mbedtls_platform_zeroize( &local, sizeof( local ) );
- return( 0 );
+ return 0 ;
}
#endif /* !MBEDTLS_RIPEMD160_PROCESS_ALT */
@@ -314,7 +314,7 @@
uint32_t left;
if( ilen == 0 )
- return( 0 );
+ return 0 ;
left = ctx->total[0] & 0x3F;
fill = 64 - left;
@@ -330,7 +330,7 @@
memcpy( (void *) (ctx->buffer + left), input, fill );
if( ( ret = mbedtls_internal_ripemd160_process( ctx, ctx->buffer ) ) != 0 )
- return( ret );
+ return ret ;
input += fill;
ilen -= fill;
@@ -340,7 +340,7 @@
while( ilen >= 64 )
{
if( ( ret = mbedtls_internal_ripemd160_process( ctx, input ) ) != 0 )
- return( ret );
+ return ret ;
input += 64;
ilen -= 64;
@@ -351,7 +351,7 @@
memcpy( (void *) (ctx->buffer + left), input, ilen );
}
- return( 0 );
+ return 0 ;
}
static const unsigned char ripemd160_padding[64] =
@@ -385,11 +385,11 @@
ret = mbedtls_ripemd160_update( ctx, ripemd160_padding, padn );
if( ret != 0 )
- return( ret );
+ return ret ;
ret = mbedtls_ripemd160_update( ctx, msglen, 8 );
if( ret != 0 )
- return( ret );
+ return ret ;
PUT_UINT32_LE( ctx->state[0], output, 0 );
PUT_UINT32_LE( ctx->state[1], output, 4 );
@@ -397,7 +397,7 @@
PUT_UINT32_LE( ctx->state[3], output, 12 );
PUT_UINT32_LE( ctx->state[4], output, 16 );
- return( 0 );
+ return 0 ;
}
#endif /* ! MBEDTLS_RIPEMD160_ALT */
@@ -426,7 +426,7 @@
exit:
mbedtls_ripemd160_free( &ctx );
- return( ret );
+ return ret ;
}
#if defined(MBEDTLS_SELF_TEST)
@@ -480,7 +480,7 @@
int i, ret = 0;
unsigned char output[20];
- memset( output, 0, sizeof output );
+ memset( output, 0, sizeof(output) );
for( i = 0; i < TESTS; i++ )
{
@@ -505,13 +505,13 @@
if( verbose != 0 )
mbedtls_printf( "\n" );
- return( 0 );
+ return 0 ;
fail:
if( verbose != 0 )
mbedtls_printf( "failed\n" );
- return( ret );
+ return ret ;
}
#endif /* MBEDTLS_SELF_TEST */