Fix gcc-7 -Wformat-truncation warning
Function test_snprintf() is called by run_test_snprintf() with constant test
data. It gets inlined and is subjected to snprintf format truncation checks
introduced by -Wformat-truncation in gcc-7. -Wformat-truncation is turned
On by -Wall and other similar options. It results in error with -Werror.
-Wformat-truncation makes tests performed by run_test_snprintf() redundant
on gcc. But they are still relevant for other compilers. This commit prevents
inlining of test_snprintf() to avoid gcc compile time checks.
diff --git a/tests/suites/host_test.function b/tests/suites/host_test.function
index a4a5a82..1243180 100644
--- a/tests/suites/host_test.function
+++ b/tests/suites/host_test.function
@@ -339,6 +339,8 @@
char buf[10] = "xxxxxxxxx";
const char ref[10] = "xxxxxxxxx";
+ if( n >= sizeof( buf ) )
+ return( -1 );
ret = mbedtls_snprintf( buf, n, "%s", "123" );
if( ret < 0 || (size_t) ret >= n )
ret = -1;