Skip to contentSkip to conversation

nlmon: fix -Wformat under musl 1.2.0

PATCH Applied Rosen Penev 2 participants 2 messages Apr 2, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nlmon: fix -Wformat under musl 1.2.0

musl 1.2.0 uses 64-bit time, even under 32-bit OSes. Cast to int64_t and use the proper macro.

---
 monitor/nlmon.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
monitor/nlmon.c +3 -2
index 0aeaea31..1f269ff0 100644
@@ -216,8 +216,9 @@ static void print_packet(const struct timeval *tv, char ident,
 				ts_pos += n;
 		}
 
-		n = sprintf(ts_str + ts_pos, " %lu.%06lu",
-					tv->tv_sec - time_offset, tv->tv_usec);
+		n = sprintf(ts_str + ts_pos, " %" PRId64 ".%06" PRId64,
+					(int64_t)tv->tv_sec - time_offset,
+					(int64_t)tv->tv_usec);
 		if (n > 0) {
 			ts_pos += n;
 			ts_len += n;
Signature · 1 line
2.25.1
#1 lore raw

Hi Rosen,

Quoted 5 lines · Rosen Penev

musl 1.2.0 uses 64-bit time, even under 32-bit OSes. Cast to int64_t and use the proper macro.

---
  monitor/nlmon.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

Applied, thanks.

Regards,
-Denis