Skip to content

Commit 4e226c7

Browse files
committed
Make compatible with Minimal-printf
Remove flags and width format sub-specifiers on `printf()` calls as Minimal-printf does not support them. This commit ensures that the output when built with Minimal-printf is legible and similar to the output when using the standard library.
1 parent 373a411 commit 4e226c7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

hashing/main.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,13 @@ static void print_hex(const char *title, const unsigned char buf[], size_t len)
3737
{
3838
mbedtls_printf("%s: ", title);
3939

40-
for (size_t i = 0; i < len; i++)
41-
mbedtls_printf("%02x", buf[i]);
40+
for (size_t i = 0; i < len; i++) {
41+
if (buf[i] < 0xF) {
42+
mbedtls_printf("0%x", buf[i]);
43+
} else {
44+
mbedtls_printf("%x", buf[i]);
45+
}
46+
}
4247

4348
mbedtls_printf("\n");
4449
}

0 commit comments

Comments
 (0)