tool/tests: fix potential year 2038 issues

The length of 'long' in a 32-bit system is 32 bits, which cannot be used
to save timestamps after 2038. Most operating systems have extended
time_t to 64 bits.

Remove the castings to long.

Closes #7466
This commit is contained in:
Bin Lan 2021-07-21 10:23:05 +08:00 committed by Daniel Stenberg
parent 94bd01310b
commit 5b9fedb461
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 6 additions and 6 deletions

View file

@ -86,7 +86,7 @@ struct timeval tvnow(void)
(void)gettimeofday(&now, NULL);
#else
else {
now.tv_sec = (long)time(NULL);
now.tv_sec = time(NULL);
now.tv_usec = 0;
}
#endif
@ -115,7 +115,7 @@ struct timeval tvnow(void)
** time() returns the value of time in seconds since the Epoch.
*/
struct timeval now;
now.tv_sec = (long)time(NULL);
now.tv_sec = time(NULL);
now.tv_usec = 0;
return now;
}

View file

@ -67,7 +67,7 @@ struct timeval tutil_tvnow(void)
(void)gettimeofday(&now, NULL);
#else
else {
now.tv_sec = (long)time(NULL);
now.tv_sec = time(NULL);
now.tv_usec = 0;
}
#endif
@ -96,7 +96,7 @@ struct timeval tutil_tvnow(void)
** time() returns the value of time in seconds since the Epoch.
*/
struct timeval now;
now.tv_sec = (long)time(NULL);
now.tv_sec = time(NULL);
now.tv_usec = 0;
return now;
}

View file

@ -496,7 +496,7 @@ static struct timeval tvnow(void)
(void)gettimeofday(&now, NULL);
#else
else {
now.tv_sec = (long)time(NULL);
now.tv_sec = time(NULL);
now.tv_usec = 0;
}
#endif
@ -525,7 +525,7 @@ static struct timeval tvnow(void)
** time() returns the value of time in seconds since the Epoch.
*/
struct timeval now;
now.tv_sec = (long)time(NULL);
now.tv_sec = time(NULL);
now.tv_usec = 0;
return now;
}