Fixes printf formatting issues caused by the toolchain

This commit is contained in:
Alexandre Paillier
2022-05-04 11:27:51 +02:00
parent 4442ba5716
commit b6e4f887cb
2 changed files with 11 additions and 9 deletions

View File

@@ -43,15 +43,15 @@ char *mem_alloc_and_format_uint(uint32_t value,
size += 1;
}
// +1 for the null character
if ((mem_ptr = mem_alloc(sizeof(char) * (size + 1))) == NULL)
if ((mem_ptr = mem_alloc(sizeof(char) * (size + 1))))
{
return 0;
}
snprintf(mem_ptr, (size + 1), "%u", value);
mem_dealloc(sizeof(char)); // to skip the null character
if (length != NULL)
{
*length = size;
// should be using %u, but not supported by toolchain
snprintf(mem_ptr, (size + 1), "%d", value);
mem_dealloc(sizeof(char)); // to skip the null character
if (length != NULL)
{
*length = size;
}
}
return mem_ptr;
}

View File

@@ -137,7 +137,9 @@ static bool path_depth_list_pop(void)
PRINTF("Hash = 0x");
for (int idx = 0; idx < KECCAK256_HASH_BYTESIZE; ++idx)
{
PRINTF("%.02x", shash[idx]);
// manual 0 padding, %.02x not supported by toolchain
if (shash[idx] < 0x10) PRINTF("0");
PRINTF("%x", shash[idx]);
}
PRINTF("\n\n");
}