]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool/tests: fix potential year 2038 issues
authorBin Lan <bin.lan@windriver.com>
Wed, 21 Jul 2021 02:23:05 +0000 (10:23 +0800)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 30 Jul 2021 14:06:37 +0000 (16:06 +0200)
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

src/tool_util.c
tests/libtest/testutil.c
tests/server/util.c

index a7535dbefdeb62e800ff280c0fc1074f70cc22d4..27c95685a4fa3948902d9acaa1226b9a16f76faa 100644 (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;
 }
index 5c0dd9ef41a90b22e17a5cbbe034fd215124fd1f..5bf6a9304109e189f309c2bd0f355b91cf9387a6 100644 (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;
 }
index 284f347cfd858c5963dcd023def884813fee9340..81e705c1525d2e91d11c27cc4f2f0bf9ec99f6b8 100644 (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;
 }