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/programs/pkey/key_app_writer.c b/programs/pkey/key_app_writer.c
index 8a09af5..a61cda1 100644
--- a/programs/pkey/key_app_writer.c
+++ b/programs/pkey/key_app_writer.c
@@ -128,7 +128,7 @@
if( opt.output_format == OUTPUT_FORMAT_PEM )
{
if( ( ret = mbedtls_pk_write_pubkey_pem( key, output_buf, 16000 ) ) != 0 )
- return( ret );
+ return ret ;
len = strlen( (char *) output_buf );
}
@@ -136,24 +136,24 @@
#endif
{
if( ( ret = mbedtls_pk_write_pubkey_der( key, output_buf, 16000 ) ) < 0 )
- return( ret );
+ return ret ;
len = ret;
c = output_buf + sizeof(output_buf) - len;
}
if( ( f = fopen( output_file, "w" ) ) == NULL )
- return( -1 );
+ return -1 ;
if( fwrite( c, 1, len, f ) != len )
{
fclose( f );
- return( -1 );
+ return -1 ;
}
fclose( f );
- return( 0 );
+ return 0 ;
}
static int write_private_key( mbedtls_pk_context *key, const char *output_file )
@@ -170,7 +170,7 @@
if( opt.output_format == OUTPUT_FORMAT_PEM )
{
if( ( ret = mbedtls_pk_write_key_pem( key, output_buf, 16000 ) ) != 0 )
- return( ret );
+ return ret ;
len = strlen( (char *) output_buf );
}
@@ -178,24 +178,24 @@
#endif
{
if( ( ret = mbedtls_pk_write_key_der( key, output_buf, 16000 ) ) < 0 )
- return( ret );
+ return ret ;
len = ret;
c = output_buf + sizeof(output_buf) - len;
}
if( ( f = fopen( output_file, "w" ) ) == NULL )
- return( -1 );
+ return -1 ;
if( fwrite( c, 1, len, f ) != len )
{
fclose( f );
- return( -1 );
+ return -1 ;
}
fclose( f );
- return( 0 );
+ return 0 ;
}
int main( int argc, char *argv[] )