modify scripts/* and tests/* to use polarssl_snprintf

This commit is contained in:
Rich Evans 2015-01-30 11:18:42 +00:00
parent 783d9d1c3e
commit 6aa04bcd85
3 changed files with 15 additions and 9 deletions

View File

@ -30,6 +30,12 @@
#include "polarssl/error.h" #include "polarssl/error.h"
#endif #endif
#if defined(POLARSSL_PLATFORM_C)
#include "polarssl/platform.h"
#else
#define polarssl_snprintf snprintf
#endif
#if defined(POLARSSL_ERROR_C) #if defined(POLARSSL_ERROR_C)
HEADER_INCLUDED HEADER_INCLUDED
@ -67,7 +73,7 @@ HIGH_LEVEL_CODE_CHECKS
// END generated code // END generated code
if( strlen( buf ) == 0 ) if( strlen( buf ) == 0 )
snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); polarssl_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret );
} }
use_ret = ret & ~0xFF80; use_ret = ret & ~0xFF80;
@ -85,7 +91,7 @@ HIGH_LEVEL_CODE_CHECKS
if( buflen - len < 5 ) if( buflen - len < 5 )
return; return;
snprintf( buf + len, buflen - len, " : " ); polarssl_snprintf( buf + len, buflen - len, " : " );
buf += len + 3; buf += len + 3;
buflen -= len + 3; buflen -= len + 3;
@ -100,7 +106,7 @@ LOW_LEVEL_CODE_CHECKS
if( strlen( buf ) != 0 ) if( strlen( buf ) != 0 )
return; return;
snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); polarssl_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret );
} }
#if defined(POLARSSL_ERROR_STRERROR_BC) #if defined(POLARSSL_ERROR_STRERROR_BC)

View File

@ -152,14 +152,14 @@ while (my $line = <GREP>)
{ {
${$code_check} .= "${white_space}if( use_ret == -($error_name) )\n". ${$code_check} .= "${white_space}if( use_ret == -($error_name) )\n".
"${white_space}\{\n". "${white_space}\{\n".
"${white_space} snprintf( buf, buflen, \"$module_name - $description\" );\n". "${white_space} polarssl_snprintf( buf, buflen, \"$module_name - $description\" );\n".
"${white_space} return;\n". "${white_space} return;\n".
"${white_space}}\n" "${white_space}}\n"
} }
else else
{ {
${$code_check} .= "${white_space}if( use_ret == -($error_name) )\n". ${$code_check} .= "${white_space}if( use_ret == -($error_name) )\n".
"${white_space} snprintf( buf, buflen, \"$module_name - $description\" );\n" "${white_space} polarssl_snprintf( buf, buflen, \"$module_name - $description\" );\n"
} }
}; };

View File

@ -17,10 +17,10 @@ void check_compiletime_version( char *version_str )
memset( build_str, 0, 100 ); memset( build_str, 0, 100 );
memset( build_str_full, 0, 100 ); memset( build_str_full, 0, 100 );
snprintf (build_str, 100, "%d.%d.%d", POLARSSL_VERSION_MAJOR, polarssl_snprintf( build_str, 100, "%d.%d.%d", POLARSSL_VERSION_MAJOR,
POLARSSL_VERSION_MINOR, POLARSSL_VERSION_PATCH ); POLARSSL_VERSION_MINOR, POLARSSL_VERSION_PATCH );
snprintf( build_str_full, 100, "mbed TLS %d.%d.%d", POLARSSL_VERSION_MAJOR, polarssl_snprintf( build_str_full, 100, "mbed TLS %d.%d.%d", POLARSSL_VERSION_MAJOR,
POLARSSL_VERSION_MINOR, POLARSSL_VERSION_PATCH ); POLARSSL_VERSION_MINOR, POLARSSL_VERSION_PATCH );
build_int = POLARSSL_VERSION_MAJOR << 24 | build_int = POLARSSL_VERSION_MAJOR << 24 |
@ -52,11 +52,11 @@ void check_runtime_version( char *version_str )
version_get_string( get_str ); version_get_string( get_str );
version_get_string_full( get_str_full ); version_get_string_full( get_str_full );
snprintf( build_str, 100, "%d.%d.%d", polarssl_snprintf( build_str, 100, "%d.%d.%d",
(get_int >> 24) & 0xFF, (get_int >> 24) & 0xFF,
(get_int >> 16) & 0xFF, (get_int >> 16) & 0xFF,
(get_int >> 8) & 0xFF ); (get_int >> 8) & 0xFF );
snprintf( build_str_full, 100, "mbed TLS %s", version_str ); polarssl_snprintf( build_str_full, 100, "mbed TLS %s", version_str );
TEST_ASSERT( strcmp( build_str, version_str ) == 0 ); TEST_ASSERT( strcmp( build_str, version_str ) == 0 );
TEST_ASSERT( strcmp( build_str_full, get_str_full ) == 0 ); TEST_ASSERT( strcmp( build_str_full, get_str_full ) == 0 );