From 4bbce780c4bd18264bb7d84e36f5eddc36dc4d7e Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Thu, 8 Jun 2017 12:40:03 +0200 Subject: [PATCH] always provide `compare_testvector()` as a function --- src/headers/tomcrypt_misc.h | 6 ------ src/misc/compare_testvector.c | 11 +++++++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/headers/tomcrypt_misc.h b/src/headers/tomcrypt_misc.h index 8bacea8..fa0b795 100644 --- a/src/headers/tomcrypt_misc.h +++ b/src/headers/tomcrypt_misc.h @@ -99,13 +99,7 @@ void crc32_finish(crc32_state *ctx, void *hash, unsigned long size); int crc32_test(void); #endif -#if defined(LTC_TEST) && defined(LTC_TEST_DBG) -void print_hex(const char* what, const void* v, const unsigned long l); int compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which); -#else -#define compare_testvector(is, is_len, should, should_len, what, which) \ - ((((is_len) != (should_len)) || (XMEMCMP((is), (should), (is_len)) != 0)) ? 1 : 0) -#endif /* $Source$ */ /* $Revision$ */ diff --git a/src/misc/compare_testvector.c b/src/misc/compare_testvector.c index 2bf02ee..64e4e63 100644 --- a/src/misc/compare_testvector.c +++ b/src/misc/compare_testvector.c @@ -15,8 +15,7 @@ Function to compare two testvectors and print a (detailed) error-message if required, Steffen Jaeckel */ -#ifndef compare_testvector - +#if defined(LTC_TEST) && defined(LTC_TEST_DBG) static void _print_hex(const char* what, const void* v, const unsigned long l) { const unsigned char* p = v; @@ -49,6 +48,7 @@ static void _print_hex(const char* what, const void* v, const unsigned long l) } } } +#endif int compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which) { @@ -58,16 +58,19 @@ int compare_testvector(const void* is, const unsigned long is_len, const void* s else res = XMEMCMP(is, should, MAX(is_len, should_len)); +#if defined(LTC_TEST) && defined(LTC_TEST_DBG) if (res != 0) { fprintf(stderr, "Testvector #%i of %s failed:\n", which, what); _print_hex("SHOULD", should, should_len); _print_hex("IS ", is, is_len); } +#else + LTC_UNUSED_PARAM(which); + LTC_UNUSED_PARAM(what); +#endif return res; } -#endif - /* $Source$ */ /* $Revision$ */