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/tests/suites/host_test.function b/tests/suites/host_test.function
index a5fd717..f414c38 100644
--- a/tests/suites/host_test.function
+++ b/tests/suites/host_test.function
@@ -15,13 +15,13 @@
{
mbedtls_fprintf( stderr,
"Expected string (with \"\") for parameter and got: %s\n", *str );
- return( -1 );
+ return -1 ;
}
( *str )++;
( *str )[strlen( *str ) - 1] = '\0';
- return( 0 );
+ return 0 ;
}
/**
@@ -71,12 +71,12 @@
else
*value = strtol( str, NULL, 10 );
- return( 0 );
+ return 0 ;
}
mbedtls_fprintf( stderr,
"Expected integer for parameter and got: %s\n", str );
- return( KEY_VALUE_MAPPING_NOT_FOUND );
+ return KEY_VALUE_MAPPING_NOT_FOUND ;
}
@@ -117,7 +117,7 @@
{
ret = fgets( buf, len, f );
if( ret == NULL )
- return( -1 );
+ return -1 ;
str_len = strlen( buf );
@@ -144,7 +144,7 @@
if( ret-- > buf && *ret == '\r' )
*ret = '\0';
- return( 0 );
+ return 0 ;
}
/**
@@ -217,7 +217,7 @@
*q = '\0';
}
- return( cnt );
+ return cnt ;
}
/**
@@ -312,7 +312,7 @@
break;
}
}
- return( ret );
+ return ret ;
}
/**
@@ -342,7 +342,7 @@
const char ref[10] = "xxxxxxxxx";
if( n >= sizeof( buf ) )
- return( -1 );
+ return -1 ;
ret = mbedtls_snprintf( buf, n, "%s", "123" );
if( ret < 0 || (size_t) ret >= n )
ret = -1;
@@ -351,10 +351,10 @@
ref_ret != ret ||
memcmp( buf + n, ref + n, sizeof( buf ) - n ) != 0 )
{
- return( 1 );
+ return 1 ;
}
- return( 0 );
+ return 0 ;
}
/**
@@ -547,7 +547,7 @@
if( pointer != NULL )
{
mbedtls_fprintf( stderr, "all-bits-zero is not a NULL pointer\n" );
- return( 1 );
+ return 1 ;
}
/*
@@ -556,7 +556,7 @@
if( run_test_snprintf() != 0 )
{
mbedtls_fprintf( stderr, "the snprintf implementation is broken\n" );
- return( 1 );
+ return 1 ;
}
if( outcome_file_name != NULL && *outcome_file_name != '\0' )
@@ -623,7 +623,7 @@
test_filename );
if( outcome_file != NULL )
fclose( outcome_file );
- return( 1 );
+ return 1 ;
}
while( !feof( file ) )
@@ -819,5 +819,5 @@
mbedtls_memory_buffer_alloc_free();
#endif
- return( total_errors != 0 );
+ return total_errors != 0 ;
}