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/sha256.c b/library/sha256.c
index 6ec6da2..017bac6 100644
--- a/library/sha256.c
+++ b/library/sha256.c
@@ -142,7 +142,7 @@
ctx->is224 = is224;
- return( 0 );
+ return 0 ;
}
#if !defined(MBEDTLS_SHA256_PROCESS_ALT)
@@ -277,7 +277,7 @@
/* Zeroise buffers and variables to clear sensitive data from memory. */
mbedtls_platform_zeroize( &local, sizeof( local ) );
- return( 0 );
+ return 0 ;
}
#endif /* !MBEDTLS_SHA256_PROCESS_ALT */
@@ -297,7 +297,7 @@
SHA256_VALIDATE_RET( ilen == 0 || input != NULL );
if( ilen == 0 )
- return( 0 );
+ return 0 ;
left = ctx->total[0] & 0x3F;
fill = 64 - left;
@@ -313,7 +313,7 @@
memcpy( (void *) (ctx->buffer + left), input, fill );
if( ( ret = mbedtls_internal_sha256_process( ctx, ctx->buffer ) ) != 0 )
- return( ret );
+ return ret ;
input += fill;
ilen -= fill;
@@ -323,7 +323,7 @@
while( ilen >= 64 )
{
if( ( ret = mbedtls_internal_sha256_process( ctx, input ) ) != 0 )
- return( ret );
+ return ret ;
input += 64;
ilen -= 64;
@@ -332,7 +332,7 @@
if( ilen > 0 )
memcpy( (void *) (ctx->buffer + left), input, ilen );
- return( 0 );
+ return 0 ;
}
/*
@@ -366,7 +366,7 @@
memset( ctx->buffer + used, 0, 64 - used );
if( ( ret = mbedtls_internal_sha256_process( ctx, ctx->buffer ) ) != 0 )
- return( ret );
+ return ret ;
memset( ctx->buffer, 0, 56 );
}
@@ -382,7 +382,7 @@
PUT_UINT32_BE( low, ctx->buffer, 60 );
if( ( ret = mbedtls_internal_sha256_process( ctx, ctx->buffer ) ) != 0 )
- return( ret );
+ return ret ;
/*
* Output final state
@@ -400,7 +400,7 @@
#endif
PUT_UINT32_BE( ctx->state[7], output, 28 );
- return( 0 );
+ return 0 ;
}
#endif /* !MBEDTLS_SHA256_ALT */
@@ -439,7 +439,7 @@
exit:
mbedtls_sha256_free( &ctx );
- return( ret );
+ return ret ;
}
#if defined(MBEDTLS_SELF_TEST)
@@ -509,7 +509,7 @@
if( verbose != 0 )
mbedtls_printf( "Buffer allocation failed\n" );
- return( 1 );
+ return 1 ;
}
mbedtls_sha256_init( &ctx );
@@ -572,7 +572,7 @@
mbedtls_sha256_free( &ctx );
mbedtls_free( buf );
- return( ret );
+ return ret ;
}
#endif /* MBEDTLS_SELF_TEST */