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/util/pem2der.c b/programs/util/pem2der.c
index e273200..f70aaee 100644
--- a/programs/util/pem2der.c
+++ b/programs/util/pem2der.c
@@ -78,11 +78,11 @@
s1 = (unsigned char *) strstr( (const char *) input, "-----BEGIN" );
if( s1 == NULL )
- return( -1 );
+ return -1 ;
s2 = (unsigned char *) strstr( (const char *) input, "-----END" );
if( s2 == NULL )
- return( -1 );
+ return -1 ;
s1 += 10;
while( s1 < end && *s1 != '-' )
@@ -93,24 +93,24 @@
if( *s1 == '\n' ) s1++;
if( s2 <= s1 || s2 > end )
- return( -1 );
+ return -1 ;
ret = mbedtls_base64_decode( NULL, 0, &len, (const unsigned char *) s1, s2 - s1 );
if( ret == MBEDTLS_ERR_BASE64_INVALID_CHARACTER )
- return( ret );
+ return ret ;
if( len > *olen )
- return( -1 );
+ return -1 ;
if( ( ret = mbedtls_base64_decode( output, len, &len, (const unsigned char *) s1,
s2 - s1 ) ) != 0 )
{
- return( ret );
+ return ret ;
}
*olen = len;
- return( 0 );
+ return 0 ;
}
/*
@@ -122,13 +122,13 @@
long size;
if( ( f = fopen( path, "rb" ) ) == NULL )
- return( -1 );
+ return -1 ;
fseek( f, 0, SEEK_END );
if( ( size = ftell( f ) ) == -1 )
{
fclose( f );
- return( -1 );
+ return -1 ;
}
fseek( f, 0, SEEK_SET );
@@ -138,7 +138,7 @@
( *buf = mbedtls_calloc( 1, *n + 1 ) ) == NULL )
{
fclose( f );
- return( -1 );
+ return -1 ;
}
if( fread( *buf, 1, *n, f ) != *n )
@@ -146,14 +146,14 @@
fclose( f );
free( *buf );
*buf = NULL;
- return( -1 );
+ return -1 ;
}
fclose( f );
(*buf)[*n] = '\0';
- return( 0 );
+ return 0 ;
}
/*
@@ -164,16 +164,16 @@
FILE *f;
if( ( f = fopen( path, "wb" ) ) == NULL )
- return( -1 );
+ return -1 ;
if( fwrite( buf, 1, n, f ) != n )
{
fclose( f );
- return( -1 );
+ return -1 ;
}
fclose( f );
- return( 0 );
+ return 0 ;
}
int main( int argc, char *argv[] )
diff --git a/programs/util/strerror.c b/programs/util/strerror.c
index 4b776d3..dda6916 100644
--- a/programs/util/strerror.c
+++ b/programs/util/strerror.c
@@ -65,7 +65,7 @@
if( *end != '\0' )
{
mbedtls_printf( USAGE );
- return( 0 );
+ return 0 ;
}
}
if( val > 0 )