From 536d40e09e9fc929d7b28bf3d7c8ef824b6b66e7 Mon Sep 17 00:00:00 2001 From: Petr Vorel Date: Tue, 16 Apr 2024 15:40:16 +0200 Subject: [PATCH] tracepath: Fix print time_t problem on 32 bits musl Similarly to 0fd2db7 this fixes warning on 32 bit musl 1.2.0, which changed time_t as 64-bit across all archs [1]. This fixes warning: ../tracepath.c:287:26: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'time_t' {aka 'long long int'} [-Wformat=] 287 | printf(_("%3ld.%03ldms "), res.tv_sec * 1000 + res.tv_nsec / 1000000, | ^~~~~~~~~~~~~~~ ../iputils_common.h:25:27: note: in definition of macro '_' 25 | # define _(Text) gettext (Text) | ^~~~ ../tracepath.c:287:30: note: format string is defined here 287 | printf(_("%3ld.%03ldms "), res.tv_sec * 1000 + res.tv_nsec / 1000000, | ~~~^ | | | long int | %3lld [1] https://musl.libc.org/time64.html Closes: https://github.com/iputils/iputils/pull/535 Reviewed-by: Cyril Hrubis Signed-off-by: Petr Vorel --- tracepath.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tracepath.c b/tracepath.c index 593a1d5e..2a42ac83 100644 --- a/tracepath.c +++ b/tracepath.c @@ -284,8 +284,9 @@ static int recverr(struct run_state *const ctl) struct timespec res; timespecsub(&ts, retts, &res); - printf(_("%3ld.%03ldms "), res.tv_sec * 1000 + res.tv_nsec / 1000000, - (res.tv_nsec % 1000000) / 1000); + printf(_("%3lld.%03ldms "), (long long int)res.tv_sec * 1000 + + res.tv_nsec / 1000000, (res.tv_nsec % 1000000) / 1000); + if (broken_router) printf(_("(This broken router returned corrupted payload) ")); }