aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Vorel <pvorel@suse.cz>2024-04-16 15:40:16 +0200
committerPetr Vorel <pvorel@suse.cz>2024-06-05 11:36:34 +0200
commit536d40e09e9fc929d7b28bf3d7c8ef824b6b66e7 (patch)
tree99e9ffa4cb7e70b9aae74a0fcc996ae3be6aa9d5
parentf2c322abd340c8f20d7b976187d544e60f1c9371 (diff)
downloadiputils-upstream-master.tar.gz
tracepath: Fix print time_t problem on 32 bits muslupstream-master
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 <chrubis@suse.cz> Signed-off-by: Petr Vorel <pvorel@suse.cz>
-rw-r--r--tracepath.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/tracepath.c b/tracepath.c
index 593a1d5..2a42ac8 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) "));
}