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.
This commit is contained in:
Mohammad Azim Khan 2018-04-12 13:23:01 +01:00
parent 1ec7e6f3d9
commit 76135345c8

View file

@ -339,6 +339,8 @@ static int test_snprintf( size_t n, const char ref_buf[10], int ref_ret )
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;