diff options
author | Bin Lan <bin.lan@windriver.com> | 2021-07-21 10:23:05 +0800 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2021-07-30 16:06:37 +0200 |
commit | 5b9fedb4618a973a303fed3406499383cb27957f (patch) | |
tree | ee23d880c9d8e19fd412a5044cea62852147377c | |
parent | 94bd01310b4a55b8d9cf0821fed4eb70a7e7aca4 (diff) | |
download | curl-5b9fedb4618a973a303fed3406499383cb27957f.tar.gz |
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
-rw-r--r-- | src/tool_util.c | 4 | ||||
-rw-r--r-- | tests/libtest/testutil.c | 4 | ||||
-rw-r--r-- | tests/server/util.c | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/src/tool_util.c b/src/tool_util.c index a7535dbef..27c95685a 100644 --- a/src/tool_util.c +++ b/src/tool_util.c @@ -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; } diff --git a/tests/libtest/testutil.c b/tests/libtest/testutil.c index 5c0dd9ef4..5bf6a9304 100644 --- a/tests/libtest/testutil.c +++ b/tests/libtest/testutil.c @@ -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; } diff --git a/tests/server/util.c b/tests/server/util.c index 284f347cf..81e705c15 100644 --- a/tests/server/util.c +++ b/tests/server/util.c @@ -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; } |