[cli] fix prints when OT_COAP_BLOCK is enabled (#12021)

`cli_coap.cpp` and `cli_coap_secure.cpp` both try to print `uint32_t`
values with `%i`, which causes build errors on some systems.
This commit uses `%lu` together with `ToUlong` to fix this and make
the code more portable.

Additionally, `%u` was used to print unsigned values instead of `%i`
This commit is contained in:
Thomas
2025-10-10 14:32:03 -07:00
committed by GitHub
parent 6f0993065e
commit 7e3deb891e
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -1117,7 +1117,7 @@ otError Coap::BlockwiseReceiveHook(const uint8_t *aBlock,
OT_UNUSED_VARIABLE(aMore);
OT_UNUSED_VARIABLE(aTotalLength);
OutputLine("received block: Num %i Len %i", aPosition / aBlockLength, aBlockLength);
OutputLine("received block: Num %lu Len %u", ToUlong(aPosition / aBlockLength), aBlockLength);
for (uint16_t i = 0; i < aBlockLength / 16; i++)
{
@@ -1144,7 +1144,7 @@ otError Coap::BlockwiseTransmitHook(uint8_t *aBlock, uint32_t aPosition, uint16_
// Send a random payload
otRandomNonCryptoFillBuffer(aBlock, *aBlockLength);
OutputLine("send block: Num %i Len %i", blockCount, *aBlockLength);
OutputLine("send block: Num %lu Len %u", ToUlong(blockCount), *aBlockLength);
for (uint16_t i = 0; i < *aBlockLength / 16; i++)
{
+2 -2
View File
@@ -1001,7 +1001,7 @@ otError CoapSecure::BlockwiseReceiveHook(const uint8_t *aBlock,
OT_UNUSED_VARIABLE(aMore);
OT_UNUSED_VARIABLE(aTotalLength);
OutputLine("received block: Num %i Len %i", aPosition / aBlockLength, aBlockLength);
OutputLine("received block: Num %lu Len %u", ToUlong(aPosition / aBlockLength), aBlockLength);
for (uint16_t i = 0; i < aBlockLength / 16; i++)
{
@@ -1028,7 +1028,7 @@ otError CoapSecure::BlockwiseTransmitHook(uint8_t *aBlock, uint32_t aPosition, u
// Send a random payload
otRandomNonCryptoFillBuffer(aBlock, *aBlockLength);
OutputLine("send block: Num %i Len %i", blockCount, *aBlockLength);
OutputLine("send block: Num %lu Len %u", ToUlong(blockCount), *aBlockLength);
for (uint16_t i = 0; i < *aBlockLength / 16; i++)
{