canutils/candump/candump.c: Fix printf formats

This commit is contained in:
YAMAMOTO Takashi 2020-11-24 16:09:45 +09:00 committed by Xiang Xiao
parent a875ed2be7
commit 747ca594d6

View File

@ -709,8 +709,8 @@ int main(int argc, char **argv)
/* log CAN frame with absolute timestamp & device */ /* log CAN frame with absolute timestamp & device */
sprint_canframe(buf, &frame, 0, maxdlen); sprint_canframe(buf, &frame, 0, maxdlen);
fprintf(logfile, "(%010ld.%06ld) %*s %s\n", fprintf(logfile, "(%010ju.%06ld) %*s %s\n",
tv.tv_sec, tv.tv_usec, (uintmax_t)tv.tv_sec, tv.tv_usec,
max_devname_len, devname[idx], buf); max_devname_len, devname[idx], buf);
} }
@ -719,8 +719,8 @@ int main(int argc, char **argv)
/* print CAN frame in log file style to stdout */ /* print CAN frame in log file style to stdout */
sprint_canframe(buf, &frame, 0, maxdlen); sprint_canframe(buf, &frame, 0, maxdlen);
printf("(%010ld.%06ld) %*s %s\n", printf("(%010ju.%06ld) %*s %s\n",
tv.tv_sec, tv.tv_usec, (uintmax_t)tv.tv_sec, tv.tv_usec,
max_devname_len, devname[idx], buf); max_devname_len, devname[idx], buf);
goto out_fflush; /* no other output to stdout */ goto out_fflush; /* no other output to stdout */
} }
@ -738,7 +738,8 @@ int main(int argc, char **argv)
switch (timestamp) { switch (timestamp) {
case 'a': /* absolute with timestamp */ case 'a': /* absolute with timestamp */
printf("(%010ld.%06ld) ", tv.tv_sec, tv.tv_usec); printf("(%010ju.%06ld) ",
(uintmax_t)tv.tv_sec, tv.tv_usec);
break; break;
case 'A': /* absolute with date */ case 'A': /* absolute with date */
@ -765,7 +766,8 @@ int main(int argc, char **argv)
diff.tv_sec--, diff.tv_usec += 1000000; diff.tv_sec--, diff.tv_usec += 1000000;
if (diff.tv_sec < 0) if (diff.tv_sec < 0)
diff.tv_sec = diff.tv_usec = 0; diff.tv_sec = diff.tv_usec = 0;
printf("(%03ld.%06ld) ", diff.tv_sec, diff.tv_usec); printf("(%03ju.%06ld) ",
(uintmax_t)diff.tv_sec, diff.tv_usec);
if (timestamp == 'd') if (timestamp == 'd')
last_tv = tv; /* update for delta calculation */ last_tv = tv; /* update for delta calculation */