Skip to content

Commit

Permalink
tracepath: Fix print time_t problem on 32 bits musl
Browse files Browse the repository at this point in the history
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: iputils#535
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
  • Loading branch information
pevik committed Jun 5, 2024
1 parent f2c322a commit 536d40e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tracepath.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) "));
}
Expand Down

0 comments on commit 536d40e

Please sign in to comment.