Skip to content

Commit c4062d6

Browse files
committed
debug: move helper for printing buffers into util.h
1 parent 3858bad commit c4062d6

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

src/tests.c

-20
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,6 @@ static int all_bytes_equal(const void* s, unsigned char value, size_t n) {
4444
return 1;
4545
}
4646

47-
/* Debug helper for printing arrays of unsigned char. */
48-
#define PRINT_BUF(buf, len) do { \
49-
printf("%s[%lu] = ", #buf, (unsigned long)len); \
50-
print_buf_plain(buf, len); \
51-
} while(0)
52-
53-
static void print_buf_plain(const unsigned char *buf, size_t len) {
54-
size_t i;
55-
printf("{");
56-
for (i = 0; i < len; i++) {
57-
if (i % 8 == 0) {
58-
printf("\n ");
59-
} else {
60-
printf(" ");
61-
}
62-
printf("0x%02X,", buf[i]);
63-
}
64-
printf("\n}\n");
65-
}
66-
6747
/* TODO Use CHECK_ILLEGAL(_VOID) everywhere and get rid of the uncounting callback */
6848
/* CHECK that expr_or_stmt calls the illegal callback of ctx exactly once
6949
*

src/util.h

+20
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,26 @@
1919
#define DEBUG_CONFIG_MSG(x) "DEBUG_CONFIG: " x
2020
#define DEBUG_CONFIG_DEF(x) DEBUG_CONFIG_MSG(#x "=" STR(x))
2121

22+
/* Debug helper for printing arrays of unsigned char. */
23+
#define PRINT_BUF(buf, len) do { \
24+
printf("%s[%lu] = ", #buf, (unsigned long)len); \
25+
print_buf_plain(buf, len); \
26+
} while(0)
27+
28+
static void print_buf_plain(const unsigned char *buf, size_t len) {
29+
size_t i;
30+
printf("{");
31+
for (i = 0; i < len; i++) {
32+
if (i % 8 == 0) {
33+
printf("\n ");
34+
} else {
35+
printf(" ");
36+
}
37+
printf("0x%02X,", buf[i]);
38+
}
39+
printf("\n}\n");
40+
}
41+
2242
# if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) )
2343
# if SECP256K1_GNUC_PREREQ(2,7)
2444
# define SECP256K1_INLINE __inline__

0 commit comments

Comments
 (0)