From 00e4e42c579189263a0d45dd472517e20a11c019 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Mon, 16 Jun 2025 21:45:49 -0700 Subject: [PATCH] [cli] fix output of fractional part of ping average round-trip time (#11587) This commit addresses an issue where the fractional part of the ping average round-trip time (RTT) was not consistently formatted. Previously, it used ".%u" with `(avgRoundTripTime % 1000)` which could omit leading zeros for fractional values. It now uses ".%03u" to ensure three digits are always displayed, padding with leading zeros when necessary. --- src/cli/cli_ping.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/cli_ping.cpp b/src/cli/cli_ping.cpp index 021b45861..c11166ccd 100644 --- a/src/cli/cli_ping.cpp +++ b/src/cli/cli_ping.cpp @@ -236,7 +236,7 @@ void PingSender::HandlePingStatistics(const otPingSenderStatistics *aStatistics) uint32_t avgRoundTripTime = 1000 * static_cast(aStatistics->mTotalRoundTripTime) / aStatistics->mReceivedCount; - OutputFormat(" Round-trip min/avg/max = %u/%u.%u/%u ms.", aStatistics->mMinRoundTripTime, + OutputFormat(" Round-trip min/avg/max = %u/%u.%03u/%u ms.", aStatistics->mMinRoundTripTime, static_cast(avgRoundTripTime / 1000), static_cast(avgRoundTripTime % 1000), aStatistics->mMaxRoundTripTime); }