]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
util: silence conversion warnings
authorMarcel Raad <Marcel.Raad@teamviewer.com>
Thu, 16 Jul 2020 16:52:03 +0000 (18:52 +0200)
committerMarcel Raad <Marcel.Raad@teamviewer.com>
Sun, 19 Jul 2020 08:34:58 +0000 (10:34 +0200)
timeval::tv_usec might be a 32-bit integer and timespec::tv_nsec might
be a 64-bit integer. This is the case when building for recent macOS
versions, for example. Just treat tv_usec as an int, which should
hopefully always be sufficient on systems with
`HAVE_CLOCK_GETTIME_MONOTONIC`.

Closes https://github.com/curl/curl/pull/5695

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

index 3ca13e7cbfa817c9fc39522273bd35aae9824306..de98b82823c5eb8aadeb9eaa3eefc1c565b8d51e 100644 (file)
@@ -74,7 +74,7 @@ struct timeval tvnow(void)
   struct timespec tsnow;
   if(0 == clock_gettime(CLOCK_MONOTONIC, &tsnow)) {
     now.tv_sec = tsnow.tv_sec;
-    now.tv_usec = tsnow.tv_nsec / 1000;
+    now.tv_usec = (int)(tsnow.tv_nsec / 1000);
   }
   /*
   ** Even when the configure process has truly detected monotonic clock
index 94a0b46be4a36b31542b2d69dd9a02376ba02ab3..d40603d91c5e7252b7e7e340f249d38e30e4d759 100644 (file)
@@ -55,7 +55,7 @@ struct timeval tutil_tvnow(void)
   struct timespec tsnow;
   if(0 == clock_gettime(CLOCK_MONOTONIC, &tsnow)) {
     now.tv_sec = tsnow.tv_sec;
-    now.tv_usec = tsnow.tv_nsec / 1000;
+    now.tv_usec = (int)(tsnow.tv_nsec / 1000);
   }
   /*
   ** Even when the configure process has truly detected monotonic clock
index 577a56cb2a93819410cf82932d1bf54c85ba3858..8e76f0c9bea19c0347299de44191817c485617ec 100644 (file)
@@ -475,7 +475,7 @@ static struct timeval tvnow(void)
   struct timespec tsnow;
   if(0 == clock_gettime(CLOCK_MONOTONIC, &tsnow)) {
     now.tv_sec = tsnow.tv_sec;
-    now.tv_usec = tsnow.tv_nsec / 1000;
+    now.tv_usec = (int)(tsnow.tv_nsec / 1000);
   }
   /*
   ** Even when the configure process has truly detected monotonic clock