From 6aa04bcd853dca13be268aa9bfd56be6374371b3 Mon Sep 17 00:00:00 2001 From: Rich Evans Date: Fri, 30 Jan 2015 11:18:42 +0000 Subject: [PATCH] modify scripts/* and tests/* to use polarssl_snprintf --- scripts/data_files/error.fmt | 12 +++++++++--- scripts/generate_errors.pl | 4 ++-- tests/suites/test_suite_version.function | 8 ++++---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/scripts/data_files/error.fmt b/scripts/data_files/error.fmt index b7bfbf20f..107b5e115 100644 --- a/scripts/data_files/error.fmt +++ b/scripts/data_files/error.fmt @@ -30,6 +30,12 @@ #include "polarssl/error.h" #endif +#if defined(POLARSSL_PLATFORM_C) +#include "polarssl/platform.h" +#else +#define polarssl_snprintf snprintf +#endif + #if defined(POLARSSL_ERROR_C) HEADER_INCLUDED @@ -67,7 +73,7 @@ HIGH_LEVEL_CODE_CHECKS // END generated code 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; @@ -85,7 +91,7 @@ HIGH_LEVEL_CODE_CHECKS if( buflen - len < 5 ) return; - snprintf( buf + len, buflen - len, " : " ); + polarssl_snprintf( buf + len, buflen - len, " : " ); buf += len + 3; buflen -= len + 3; @@ -100,7 +106,7 @@ LOW_LEVEL_CODE_CHECKS if( strlen( buf ) != 0 ) 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) diff --git a/scripts/generate_errors.pl b/scripts/generate_errors.pl index 04591b28b..c0d9685f6 100755 --- a/scripts/generate_errors.pl +++ b/scripts/generate_errors.pl @@ -152,14 +152,14 @@ while (my $line = ) { ${$code_check} .= "${white_space}if( use_ret == -($error_name) )\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}}\n" } else { ${$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" } }; diff --git a/tests/suites/test_suite_version.function b/tests/suites/test_suite_version.function index f50a6c29b..fd12032e1 100644 --- a/tests/suites/test_suite_version.function +++ b/tests/suites/test_suite_version.function @@ -17,10 +17,10 @@ void check_compiletime_version( char *version_str ) memset( build_str, 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 ); - 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 ); 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_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 >> 16) & 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_full, get_str_full ) == 0 );