]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #9566: Explicit downcast to fix compiler warnings on Win64
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 30 Oct 2012 23:33:57 +0000 (00:33 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 30 Oct 2012 23:33:57 +0000 (00:33 +0100)
Modules/faulthandler.c
Modules/md5module.c
Modules/sha1module.c
Modules/zlibmodule.c

index b0df93c8a1c9229c579266778e0ebaba5bac91d0..f49993d0f3974d2666d7d6bcdbbe833632a61cf7 100644 (file)
@@ -22,7 +22,9 @@
 #  define FAULTHANDLER_USER
 #endif
 
-#define PUTS(fd, str) write(fd, str, strlen(str))
+/* cast size_t to int because write() takes an int on Windows
+   (anyway, the length is smaller than 30 characters) */
+#define PUTS(fd, str) write(fd, str, (int)strlen(str))
 
 #ifdef HAVE_SIGACTION
 typedef struct sigaction _Py_sighandler_t;
@@ -445,7 +447,7 @@ faulthandler_thread(void *unused)
         /* get the thread holding the GIL, NULL if no thread hold the GIL */
         current = _Py_atomic_load_relaxed(&_PyThreadState_Current);
 
-        write(thread.fd, thread.header, thread.header_len);
+        write(thread.fd, thread.header, (int)thread.header_len);
 
         errmsg = _Py_DumpTracebackThreads(thread.fd, thread.interp, current);
         ok = (errmsg == NULL);
index e2681a8ae5a5222dd02ea2747ca56664d26cfc20..4ecbb06baf0843a9818ec20cff570182f3adcf8d 100644 (file)
@@ -246,7 +246,7 @@ md5_process(struct md5_state *md5, const unsigned char *in, Py_ssize_t inlen)
         } else {
            n = MIN(inlen, (Py_ssize_t)(MD5_BLOCKSIZE - md5->curlen));
            memcpy(md5->buf + md5->curlen, in, (size_t)n);
-           md5->curlen    += n;
+           md5->curlen    += (MD5_INT32)n;
            in             += n;
            inlen          -= n;
            if (md5->curlen == MD5_BLOCKSIZE) {
index a733c4b5bb1720690a4572901961566f5558e65f..ab93f68f0de195daeb441875e3f9cf552f156380 100644 (file)
@@ -222,7 +222,7 @@ sha1_process(struct sha1_state *sha1,
         } else {
            n = MIN(inlen, (Py_ssize_t)(SHA1_BLOCKSIZE - sha1->curlen));
            memcpy(sha1->buf + sha1->curlen, in, (size_t)n);
-           sha1->curlen   += n;
+           sha1->curlen   += (SHA1_INT32)n;
            in             += n;
            inlen          -= n;
            if (sha1->curlen == SHA1_BLOCKSIZE) {
index 6519194fb57f0a70ed64d2fdcbbc59428d7af504..a53a5f02119d8af3e7ff366df4606057e7345db3 100644 (file)
@@ -161,7 +161,7 @@ PyZlib_compress(PyObject *self, PyObject *args)
         goto error;
     }
     input = pinput.buf;
-    length = pinput.len;
+    length = (unsigned int)pinput.len;
 
     zst.avail_out = length + length/1000 + 12 + 1;
 
@@ -251,7 +251,7 @@ PyZlib_decompress(PyObject *self, PyObject *args)
         goto error;
     }
     input = pinput.buf;
-    length = pinput.len;
+    length = (unsigned int)pinput.len;
 
     if (r_strlen <= 0)
         r_strlen = 1;