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/sha1.c b/library/sha1.c
index 545d093..582b91b 100644
--- a/library/sha1.c
+++ b/library/sha1.c
@@ -111,7 +111,7 @@
ctx->state[3] = 0x10325476;
ctx->state[4] = 0xC3D2E1F0;
- return( 0 );
+ return 0 ;
}
#if !defined(MBEDTLS_SHA1_PROCESS_ALT)
@@ -284,7 +284,7 @@
/* Zeroise buffers and variables to clear sensitive data from memory. */
mbedtls_platform_zeroize( &local, sizeof( local ) );
- return( 0 );
+ return 0 ;
}
#endif /* !MBEDTLS_SHA1_PROCESS_ALT */
@@ -304,7 +304,7 @@
SHA1_VALIDATE_RET( ilen == 0 || input != NULL );
if( ilen == 0 )
- return( 0 );
+ return 0 ;
left = ctx->total[0] & 0x3F;
fill = 64 - left;
@@ -320,7 +320,7 @@
memcpy( (void *) (ctx->buffer + left), input, fill );
if( ( ret = mbedtls_internal_sha1_process( ctx, ctx->buffer ) ) != 0 )
- return( ret );
+ return ret ;
input += fill;
ilen -= fill;
@@ -330,7 +330,7 @@
while( ilen >= 64 )
{
if( ( ret = mbedtls_internal_sha1_process( ctx, input ) ) != 0 )
- return( ret );
+ return ret ;
input += 64;
ilen -= 64;
@@ -339,7 +339,7 @@
if( ilen > 0 )
memcpy( (void *) (ctx->buffer + left), input, ilen );
- return( 0 );
+ return 0 ;
}
/*
@@ -373,7 +373,7 @@
memset( ctx->buffer + used, 0, 64 - used );
if( ( ret = mbedtls_internal_sha1_process( ctx, ctx->buffer ) ) != 0 )
- return( ret );
+ return ret ;
memset( ctx->buffer, 0, 56 );
}
@@ -389,7 +389,7 @@
PUT_UINT32_BE( low, ctx->buffer, 60 );
if( ( ret = mbedtls_internal_sha1_process( ctx, ctx->buffer ) ) != 0 )
- return( ret );
+ return ret ;
/*
* Output final state
@@ -400,7 +400,7 @@
PUT_UINT32_BE( ctx->state[3], output, 12 );
PUT_UINT32_BE( ctx->state[4], output, 16 );
- return( 0 );
+ return 0 ;
}
#endif /* !MBEDTLS_SHA1_ALT */
@@ -432,7 +432,7 @@
exit:
mbedtls_sha1_free( &ctx );
- return( ret );
+ return ret ;
}
#if defined(MBEDTLS_SELF_TEST)
@@ -528,7 +528,7 @@
exit:
mbedtls_sha1_free( &ctx );
- return( ret );
+ return ret ;
}
#endif /* MBEDTLS_SELF_TEST */