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/platform.c b/library/platform.c
index e742fde..7ef6625 100644
--- a/library/platform.c
+++ b/library/platform.c
@@ -38,7 +38,7 @@
{
((void) n);
((void) size);
- return( NULL );
+ return NULL ;
}
#define MBEDTLS_PLATFORM_STD_CALLOC platform_calloc_uninit
@@ -71,7 +71,7 @@
{
mbedtls_calloc_func = calloc_func;
mbedtls_free_func = free_func;
- return( 0 );
+ return 0 ;
}
#endif /* MBEDTLS_PLATFORM_MEMORY &&
!( defined(MBEDTLS_PLATFORM_CALLOC_MACRO) &&
@@ -88,7 +88,7 @@
ret = mbedtls_vsnprintf( s, n, fmt, argp );
va_end( argp );
- return( ret );
+ return ret ;
}
#endif
@@ -103,7 +103,7 @@
((void) s);
((void) n);
((void) format);
- return( 0 );
+ return 0 ;
}
#define MBEDTLS_PLATFORM_STD_SNPRINTF platform_snprintf_uninit
@@ -118,7 +118,7 @@
... ) )
{
mbedtls_snprintf = snprintf_func;
- return( 0 );
+ return 0 ;
}
#endif /* MBEDTLS_PLATFORM_SNPRINTF_ALT */
@@ -130,7 +130,7 @@
/* Avoid calling the invalid parameter handler by checking ourselves */
if( s == NULL || n == 0 || fmt == NULL )
- return( -1 );
+ return -1 ;
#if defined(_TRUNCATE)
ret = vsnprintf_s( s, n, _TRUNCATE, fmt, arg );
@@ -143,7 +143,7 @@
}
#endif
- return( ret );
+ return ret ;
}
#endif
@@ -159,7 +159,7 @@
((void) n);
((void) format);
((void) arg);
- return( -1 );
+ return -1 ;
}
#define MBEDTLS_PLATFORM_STD_VSNPRINTF platform_vsnprintf_uninit
@@ -174,7 +174,7 @@
va_list arg ) )
{
mbedtls_vsnprintf = vsnprintf_func;
- return( 0 );
+ return 0 ;
}
#endif /* MBEDTLS_PLATFORM_VSNPRINTF_ALT */
@@ -186,7 +186,7 @@
static int platform_printf_uninit( const char *format, ... )
{
((void) format);
- return( 0 );
+ return 0 ;
}
#define MBEDTLS_PLATFORM_STD_PRINTF platform_printf_uninit
@@ -197,7 +197,7 @@
int mbedtls_platform_set_printf( int (*printf_func)( const char *, ... ) )
{
mbedtls_printf = printf_func;
- return( 0 );
+ return 0 ;
}
#endif /* MBEDTLS_PLATFORM_PRINTF_ALT */
@@ -210,7 +210,7 @@
{
((void) stream);
((void) format);
- return( 0 );
+ return 0 ;
}
#define MBEDTLS_PLATFORM_STD_FPRINTF platform_fprintf_uninit
@@ -222,7 +222,7 @@
int mbedtls_platform_set_fprintf( int (*fprintf_func)( FILE *, const char *, ... ) )
{
mbedtls_fprintf = fprintf_func;
- return( 0 );
+ return 0 ;
}
#endif /* MBEDTLS_PLATFORM_FPRINTF_ALT */
@@ -244,7 +244,7 @@
int mbedtls_platform_set_exit( void (*exit_func)( int status ) )
{
mbedtls_exit = exit_func;
- return( 0 );
+ return 0 ;
}
#endif /* MBEDTLS_PLATFORM_EXIT_ALT */
@@ -258,7 +258,7 @@
static mbedtls_time_t platform_time_uninit( mbedtls_time_t* timer )
{
((void) timer);
- return( 0 );
+ return 0 ;
}
#define MBEDTLS_PLATFORM_STD_TIME platform_time_uninit
@@ -269,7 +269,7 @@
int mbedtls_platform_set_time( mbedtls_time_t (*time_func)( mbedtls_time_t* timer ) )
{
mbedtls_time = time_func;
- return( 0 );
+ return 0 ;
}
#endif /* MBEDTLS_PLATFORM_TIME_ALT */
@@ -286,17 +286,17 @@
size_t n;
if( ( file = fopen( MBEDTLS_PLATFORM_STD_NV_SEED_FILE, "rb" ) ) == NULL )
- return( -1 );
+ return -1 ;
if( ( n = fread( buf, 1, buf_len, file ) ) != buf_len )
{
fclose( file );
mbedtls_platform_zeroize( buf, buf_len );
- return( -1 );
+ return -1 ;
}
fclose( file );
- return( (int)n );
+ return (int)n ;
}
int mbedtls_platform_std_nv_seed_write( unsigned char *buf, size_t buf_len )
@@ -314,7 +314,7 @@
}
fclose( file );
- return( (int)n );
+ return (int)n ;
}
#endif /* MBEDTLS_PLATFORM_NO_STD_FUNCTIONS */
@@ -327,7 +327,7 @@
{
((void) buf);
((void) buf_len);
- return( -1 );
+ return -1 ;
}
#define MBEDTLS_PLATFORM_STD_NV_SEED_READ platform_nv_seed_read_uninit
@@ -341,7 +341,7 @@
{
((void) buf);
((void) buf_len);
- return( -1 );
+ return -1 ;
}
#define MBEDTLS_PLATFORM_STD_NV_SEED_WRITE platform_nv_seed_write_uninit
@@ -358,7 +358,7 @@
{
mbedtls_nv_seed_read = nv_seed_read_func;
mbedtls_nv_seed_write = nv_seed_write_func;
- return( 0 );
+ return 0 ;
}
#endif /* MBEDTLS_PLATFORM_NV_SEED_ALT */
#endif /* MBEDTLS_ENTROPY_NV_SEED */
@@ -371,7 +371,7 @@
{
(void)ctx;
- return( 0 );
+ return 0 ;
}
/*