]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-131296: Avoid posixmodule.c warning (GH-133142)
authorWulian233 <1055917385@qq.com>
Mon, 5 May 2025 16:45:15 +0000 (00:45 +0800)
committerGitHub <noreply@github.com>
Mon, 5 May 2025 16:45:15 +0000 (17:45 +0100)
Clang-cl detects that on 32-bit builds the variable is always smaller than the value. But since the same code is used for other architectures, we can't just _fix_ it. This cast avoids the tautological-constant-out-of-range-compare warning.

Modules/posixmodule.c

index 964e988843110e6c60b2ec43ac105b8c4943c0c1..922694fa367ac3c8d34fcb0a9a51c45bbb8694c3 100644 (file)
@@ -4207,7 +4207,7 @@ posix_getcwd(int use_bytes)
        terminating \0. If the buffer is too small, len includes
        the space needed for the terminator. */
     if (len >= Py_ARRAY_LENGTH(wbuf)) {
-        if (len <= PY_SSIZE_T_MAX / sizeof(wchar_t)) {
+        if ((Py_ssize_t)len <= PY_SSIZE_T_MAX / sizeof(wchar_t)) {
             wbuf2 = PyMem_RawMalloc(len * sizeof(wchar_t));
         }
         else {