diff mbox series

[BlueZ,2/3] monitor: fix printf format strings

Message ID 20220923105141.20176-2-ceggers@arri.de
State New
Headers show
Series [BlueZ,1/3] client/player: fix printf format string | expand

Commit Message

Christian Eggers Sept. 23, 2022, 10:51 a.m. UTC
time_t is 64 bit (long long) on many 32 bit platforms (e.g. ARM) now
---
 monitor/analyze.c | 21 ++++++++++++---------
 monitor/packet.c  | 10 ++++++----
 2 files changed, 18 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/monitor/analyze.c b/monitor/analyze.c
index ac23e13bbd42..50e7e5542793 100644
--- a/monitor/analyze.c
+++ b/monitor/analyze.c
@@ -172,15 +172,18 @@  static void conn_destroy(void *data)
 	print_field("%lu RX packets", conn->rx_num);
 	print_field("%lu TX packets", conn->tx_num);
 	print_field("%lu TX completed packets", conn->tx_num_comp);
-	print_field("%ld msec min latency",
-			conn->tx_lat_min.tv_sec * 1000 +
-			conn->tx_lat_min.tv_usec / 1000);
-	print_field("%ld msec max latency",
-			conn->tx_lat_max.tv_sec * 1000 +
-			conn->tx_lat_max.tv_usec / 1000);
-	print_field("%ld msec median latency",
-			conn->tx_lat_med.tv_sec * 1000 +
-			conn->tx_lat_med.tv_usec / 1000);
+	print_field("%lld msec min latency",
+			(long long)
+			(conn->tx_lat_min.tv_sec * 1000 +
+			conn->tx_lat_min.tv_usec / 1000));
+	print_field("%lld msec max latency",
+			(long long)
+			(conn->tx_lat_max.tv_sec * 1000 +
+			conn->tx_lat_max.tv_usec / 1000));
+	print_field("%lld msec median latency",
+			(long long)
+			(conn->tx_lat_med.tv_sec * 1000 +
+			conn->tx_lat_med.tv_usec / 1000));
 	print_field("%u octets TX min packet size", conn->tx_pkt_min);
 	print_field("%u octets TX max packet size", conn->tx_pkt_max);
 	print_field("%u octets TX median packet size", conn->tx_pkt_med);
diff --git a/monitor/packet.c b/monitor/packet.c
index 1344fd5b2503..1a41498e9c52 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -384,8 +384,9 @@  static void print_packet(struct timeval *tv, struct ucred *cred, char ident,
 		}
 
 		if (filter_mask & PACKET_FILTER_SHOW_TIME) {
-			n = sprintf(ts_str + ts_pos, " %02d:%02d:%02d.%06lu",
-				tm.tm_hour, tm.tm_min, tm.tm_sec, tv->tv_usec);
+			n = sprintf(ts_str + ts_pos, " %02d:%02d:%02d.%06llu",
+				tm.tm_hour, tm.tm_min, tm.tm_sec,
+				(long long)tv->tv_usec);
 			if (n > 0) {
 				ts_pos += n;
 				ts_len += n;
@@ -393,8 +394,9 @@  static void print_packet(struct timeval *tv, struct ucred *cred, char ident,
 		}
 
 		if (filter_mask & PACKET_FILTER_SHOW_TIME_OFFSET) {
-			n = sprintf(ts_str + ts_pos, " %lu.%06lu",
-					tv->tv_sec - time_offset, tv->tv_usec);
+			n = sprintf(ts_str + ts_pos, " %llu.%06llu",
+				(long long)(tv->tv_sec - time_offset),
+				(long long)tv->tv_usec);
 			if (n > 0) {
 				ts_pos += n;
 				ts_len += n;