]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-39277: Fix PY_TIMEOUT_MAX cast in _threadmodule.c (GH-31195)
authorVictor Stinner <vstinner@python.org>
Mon, 7 Feb 2022 15:21:09 +0000 (16:21 +0100)
committerGitHub <noreply@github.com>
Mon, 7 Feb 2022 15:21:09 +0000 (16:21 +0100)
Cast PY_TIMEOUT_MAX to double, not to _PyTime_t.

Fix the clang warning:

Modules/_threadmodule.c:1648:26: warning: implicit conversion from
'_PyTime_t' (aka 'long') to 'double' changes value from
9223372036854775 to 9223372036854776
[-Wimplicit-const-int-float-conversion]
    double timeout_max = (_PyTime_t)PY_TIMEOUT_MAX * 1e-6;
                         ^~~~~~~~~~~~~~~~~~~~~~~~~ ~

Modules/_threadmodule.c

index 9e6e462b59e06c26f8f4512597e0d9af9c78b5f2..7052d4c887a66343da4fc3f0c75df1e09e35b151 100644 (file)
@@ -1645,7 +1645,7 @@ thread_module_exec(PyObject *module)
     }
 
     // TIMEOUT_MAX
-    double timeout_max = (_PyTime_t)PY_TIMEOUT_MAX * 1e-6;
+    double timeout_max = (double)PY_TIMEOUT_MAX * 1e-6;
     double time_max = _PyTime_AsSecondsDouble(_PyTime_MAX);
     timeout_max = Py_MIN(timeout_max, time_max);
     // Round towards minus infinity