timestamp formatting: always use 64-bit for timesstamp formatting.

Using C99 `unsigned long long` to format `struct timeval`'s `tv_sec`
and `tv_usec`, fix incorrect print under some 32bit platform which
 using time64.
This commit is contained in:
TyK
2023-11-28 08:30:27 +08:00
parent 97c8ccdbbf
commit ceda93bd5c
11 changed files with 58 additions and 42 deletions
+2 -2
View File
@@ -363,8 +363,8 @@ int can2pty(int pty, int socket, int *tstamp)
if (ioctl(socket, SIOCGSTAMP, &tv) < 0)
perror("SIOCGSTAMP");
sprintf(&buf[ptr + 2*frame.can_dlc], "%04lX",
(tv.tv_sec%60)*1000 + tv.tv_usec/1000);
sprintf(&buf[ptr + 2*frame.can_dlc], "%04llX",
(unsigned long long)(tv.tv_sec%60)*1000 + tv.tv_usec/1000);
}
strcat(buf, "\r"); /* add terminating character */