mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-04 05:25:07 -05:00
util: fix printing of timestamps when time_t is longer than long
This commit is contained in:
6
util.c
6
util.c
@@ -210,9 +210,13 @@ UTI_TimevalToString(struct timeval *tv)
|
||||
char *result;
|
||||
|
||||
result = NEXT_BUFFER;
|
||||
/* TODO: time_t may be wider than long, switch to int64_t before 2038 */
|
||||
#ifdef HAVE_LONG_TIME_T
|
||||
snprintf(result, BUFFER_LENGTH, "%"PRId64".%06lu",
|
||||
(int64_t)tv->tv_sec, (unsigned long)tv->tv_usec);
|
||||
#else
|
||||
snprintf(result, BUFFER_LENGTH, "%ld.%06lu",
|
||||
(long)tv->tv_sec, (unsigned long)tv->tv_usec);
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user