From 3858bad2c6493aa66cbfa62540d89da9c5a16040 Mon Sep 17 00:00:00 2001 From: Jonas Nick Date: Fri, 21 Apr 2023 20:21:28 +0000 Subject: [PATCH 1/2] tests: remove extra semicolon in macro --- src/tests.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tests.c b/src/tests.c index 0f9c35faf2d2b..24355039b3f73 100644 --- a/src/tests.c +++ b/src/tests.c @@ -48,7 +48,8 @@ static int all_bytes_equal(const void* s, unsigned char value, size_t n) { #define PRINT_BUF(buf, len) do { \ printf("%s[%lu] = ", #buf, (unsigned long)len); \ print_buf_plain(buf, len); \ -} while(0); +} while(0) + static void print_buf_plain(const unsigned char *buf, size_t len) { size_t i; printf("{"); From c4062d6b5d83572c1932f32003a7c0e901fffc23 Mon Sep 17 00:00:00 2001 From: Jonas Nick Date: Tue, 25 Apr 2023 16:07:10 +0000 Subject: [PATCH 2/2] debug: move helper for printing buffers into util.h --- src/tests.c | 20 -------------------- src/util.h | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/tests.c b/src/tests.c index 24355039b3f73..6d46b39d74943 100644 --- a/src/tests.c +++ b/src/tests.c @@ -44,26 +44,6 @@ static int all_bytes_equal(const void* s, unsigned char value, size_t n) { return 1; } -/* Debug helper for printing arrays of unsigned char. */ -#define PRINT_BUF(buf, len) do { \ - printf("%s[%lu] = ", #buf, (unsigned long)len); \ - print_buf_plain(buf, len); \ -} while(0) - -static void print_buf_plain(const unsigned char *buf, size_t len) { - size_t i; - printf("{"); - for (i = 0; i < len; i++) { - if (i % 8 == 0) { - printf("\n "); - } else { - printf(" "); - } - printf("0x%02X,", buf[i]); - } - printf("\n}\n"); -} - /* TODO Use CHECK_ILLEGAL(_VOID) everywhere and get rid of the uncounting callback */ /* CHECK that expr_or_stmt calls the illegal callback of ctx exactly once * diff --git a/src/util.h b/src/util.h index f980f47bdc7f3..0e3faf02345da 100644 --- a/src/util.h +++ b/src/util.h @@ -19,6 +19,26 @@ #define DEBUG_CONFIG_MSG(x) "DEBUG_CONFIG: " x #define DEBUG_CONFIG_DEF(x) DEBUG_CONFIG_MSG(#x "=" STR(x)) +/* Debug helper for printing arrays of unsigned char. */ +#define PRINT_BUF(buf, len) do { \ + printf("%s[%lu] = ", #buf, (unsigned long)len); \ + print_buf_plain(buf, len); \ +} while(0) + +static void print_buf_plain(const unsigned char *buf, size_t len) { + size_t i; + printf("{"); + for (i = 0; i < len; i++) { + if (i % 8 == 0) { + printf("\n "); + } else { + printf(" "); + } + printf("0x%02X,", buf[i]); + } + printf("\n}\n"); +} + # if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) # if SECP256K1_GNUC_PREREQ(2,7) # define SECP256K1_INLINE __inline__