]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
tst-timespec.c: Explicitly cast TIME_T_MAX to double
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 16 Dec 2024 21:52:43 +0000 (05:52 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 17 Dec 2024 17:26:52 +0000 (01:26 +0800)
Explicitly cast TIME_T_MAX to double in tst-timespec.c to silence Clang
error:

tst-timespec.c:290:19: error: implicit conversion from 'time_t' (aka 'long') to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Werror,-Wimplicit-const-int-float-conversion]
  287 |   {.expected = {.tv_sec = 0, .tv_nsec = 1},
      |   ~
  288 |    .observed = {.tv_sec = TIME_T_MAX / TIMESPEC_HZ,
  289 |                 .tv_nsec = TIMESPEC_HZ - 1},
  290 |    .upper_bound = TIME_T_MAX, .lower_bound = 1, .result = 1,
      |                   ^~~~~~~~~~

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
support/tst-timespec.c

index 66fc42c03dc8bd9b97ae9f9daa2663acaade15cf..22669f86118ce279c89c96fb1a19606b87fc39fc 100644 (file)
@@ -287,7 +287,7 @@ struct timespec_test_case check_cases[] = {
   {.expected = {.tv_sec = 0, .tv_nsec = 1},
    .observed = {.tv_sec = TIME_T_MAX / TIMESPEC_HZ,
                .tv_nsec = TIMESPEC_HZ - 1},
-   .upper_bound = TIME_T_MAX, .lower_bound = 1, .result = 1,
+   .upper_bound = (double) TIME_T_MAX, .lower_bound = 1, .result = 1,
   },
 };