From 4c96151c0e11b14622d1598abe4411226c818335 Mon Sep 17 00:00:00 2001 From: Suvesh Pratapa <66088488+suveshpratapa@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:49:38 -0400 Subject: [PATCH] [logging] fix print format when enabling csl debug (#10045) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix -Wformat trigger on some platforms as an int32_t is printed using %d ``` src/core/mac/sub_mac.cpp:336:73: warning: format '%d' expects argument of type 'int', but argument 5 has type 'int32_t' {aka 'long int'} [-Wformat=] 336 | logString.Append("Expected sample time %lu, margin ±%lu, deviation %d", ToUlong(sampleTime), ToUlong(ahead), | ~^ | | | int | %ld 337 | deviation); | ~~~~~~~~~ | | | int32_t {aka long int} ``` --- src/core/mac/sub_mac.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/mac/sub_mac.cpp b/src/core/mac/sub_mac.cpp index 2884d86735a..edeba2e8b81 100644 --- a/src/core/mac/sub_mac.cpp +++ b/src/core/mac/sub_mac.cpp @@ -333,8 +333,8 @@ void SubMac::LogReceived(RxFrame *aFrame) // be due to clocks drift and/or CSL Phase rounding error. // This means that a deviation absolute value greater than the margin would result in the frame // not being received out of the debug mode. - logString.Append("Expected sample time %lu, margin ±%lu, deviation %d", ToUlong(sampleTime), ToUlong(ahead), - deviation); + logString.Append("Expected sample time %lu, margin ±%lu, deviation %ld", ToUlong(sampleTime), ToUlong(ahead), + static_cast(deviation)); // Treat as a warning when the deviation is not within the margins. Neither kCslReceiveTimeAhead // or kMinReceiveOnAhead/kMinReceiveOnAfter are considered for the margin since they have no