From 7e3deb891eb34ffe9b30033273f93ec93b741ab4 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 10 Oct 2025 23:32:03 +0200 Subject: [PATCH] [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` --- src/cli/cli_coap.cpp | 4 ++-- src/cli/cli_coap_secure.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cli/cli_coap.cpp b/src/cli/cli_coap.cpp index f724def0a..7a1bba4c2 100644 --- a/src/cli/cli_coap.cpp +++ b/src/cli/cli_coap.cpp @@ -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++) { diff --git a/src/cli/cli_coap_secure.cpp b/src/cli/cli_coap_secure.cpp index 0cb7a0765..8b32c83c7 100644 --- a/src/cli/cli_coap_secure.cpp +++ b/src/cli/cli_coap_secure.cpp @@ -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++) {