]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix compilation warnings on Windows (GH-8627)
authorVictor Stinner <vstinner@redhat.com>
Thu, 2 Aug 2018 16:02:59 +0000 (18:02 +0200)
committerGitHub <noreply@github.com>
Thu, 2 Aug 2018 16:02:59 +0000 (18:02 +0200)
* Fix compilation warning in _ctypes module on Window

(cherry picked from commit 20f11fe43c47b68c8b9dd6539d2d40b66c9957f9)

* Fix compilation warnings on Windows 64-bit

(cherry picked from commit 725e4212229bf68f87d4f66c1815d444ddfc7aa5)

* Fix compiler warning in unicodeobject.c

Explicitly case to Py_UNICODE to fix the warning:

Objects\unicodeobject.c(4225): warning C4244: '=' :
conversion from 'long' to 'Py_UNICODE', possible loss of data

The downcast cannot overflow since we check that value <= 0x10ffff.

Modules/_ctypes/libffi_msvc/ffi.c
Modules/_sqlite/util.c
Objects/unicodeobject.c

index f28c3e0a385984ea150f59a327d261b0a415b69d..587c94b7e61f41777e5e73474eb3f3d9899567a2 100644 (file)
@@ -119,7 +119,7 @@ void ffi_prep_args(char *stack, extended_cif *ecif)
       argp += z;
     }
 
-  if (argp - stack > ecif->cif->bytes) 
+  if (argp >= stack && (unsigned)(argp - stack) > ecif->cif->bytes)
     {
       Py_FatalError("FFI BUG: not enough stack space for arguments");
     }
index a24dd8c634732e7a4b277b8c23ea2b21eb0b28ec..73772250f914a9540c65505e7a1069bafd78533c 100644 (file)
@@ -132,7 +132,7 @@ _pysqlite_long_from_int64(sqlite_int64 value)
     }
 # endif
 #endif
-    return PyInt_FromLong(value);
+    return PyInt_FromLong(Py_SAFE_DOWNCAST(value, sqlite_int64, long));
 }
 
 sqlite_int64
index 8bf04df2c86cd0146ba7a5565cfdcd22a4091b85..b76db619ad7614e17cc745e936c6b6b6f1588dd0 100644 (file)
@@ -4222,7 +4222,7 @@ PyObject *PyUnicode_DecodeCharmap(const char *s,
                         p = PyUnicode_AS_UNICODE(v) + oldpos;
                     }
                     value -= 0x10000;
-                    *p++ = 0xD800 | (value >> 10);
+                    *p++ = 0xD800 | (Py_UNICODE)(value >> 10);
                     *p++ = 0xDC00 | (value & 0x3FF);
                     extrachars -= 2;
                 }