Skip to content

Commit 56cb125

Browse files
committed
Issue #9566: Explicit downcast to fix compiler warnings on Win64
1 parent 4ca1cf3 commit 56cb125

4 files changed

Lines changed: 8 additions & 6 deletions

File tree

Modules/faulthandler.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
# define FAULTHANDLER_USER
2323
#endif
2424

25-
#define PUTS(fd, str) write(fd, str, strlen(str))
25+
/* cast size_t to int because write() takes an int on Windows
26+
(anyway, the length is smaller than 30 characters) */
27+
#define PUTS(fd, str) write(fd, str, (int)strlen(str))
2628

2729
#ifdef HAVE_SIGACTION
2830
typedef struct sigaction _Py_sighandler_t;
@@ -445,7 +447,7 @@ faulthandler_thread(void *unused)
445447
/* get the thread holding the GIL, NULL if no thread hold the GIL */
446448
current = _Py_atomic_load_relaxed(&_PyThreadState_Current);
447449

448-
write(thread.fd, thread.header, thread.header_len);
450+
write(thread.fd, thread.header, (int)thread.header_len);
449451

450452
errmsg = _Py_DumpTracebackThreads(thread.fd, thread.interp, current);
451453
ok = (errmsg == NULL);

Modules/md5module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ md5_process(struct md5_state *md5, const unsigned char *in, Py_ssize_t inlen)
246246
} else {
247247
n = MIN(inlen, (Py_ssize_t)(MD5_BLOCKSIZE - md5->curlen));
248248
memcpy(md5->buf + md5->curlen, in, (size_t)n);
249-
md5->curlen += n;
249+
md5->curlen += (MD5_INT32)n;
250250
in += n;
251251
inlen -= n;
252252
if (md5->curlen == MD5_BLOCKSIZE) {

Modules/sha1module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ sha1_process(struct sha1_state *sha1,
222222
} else {
223223
n = MIN(inlen, (Py_ssize_t)(SHA1_BLOCKSIZE - sha1->curlen));
224224
memcpy(sha1->buf + sha1->curlen, in, (size_t)n);
225-
sha1->curlen += n;
225+
sha1->curlen += (SHA1_INT32)n;
226226
in += n;
227227
inlen -= n;
228228
if (sha1->curlen == SHA1_BLOCKSIZE) {

Modules/zlibmodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ PyZlib_compress(PyObject *self, PyObject *args)
161161
goto error;
162162
}
163163
input = pinput.buf;
164-
length = pinput.len;
164+
length = (unsigned int)pinput.len;
165165

166166
zst.avail_out = length + length/1000 + 12 + 1;
167167

@@ -251,7 +251,7 @@ PyZlib_decompress(PyObject *self, PyObject *args)
251251
goto error;
252252
}
253253
input = pinput.buf;
254-
length = pinput.len;
254+
length = (unsigned int)pinput.len;
255255

256256
if (r_strlen <= 0)
257257
r_strlen = 1;

0 commit comments

Comments
 (0)