Skip to content

Commit bf6fa21

Browse files
authored
[3.13] gh-126433: Fix compiler warnings on 32-bit Windows (#126444) (#126827)
gh-126433: Fix compiler warnings on 32-bit Windows (#126444) (cherry picked from commit 0b67ce9)
1 parent effedb5 commit bf6fa21

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

Modules/_interpchannelsmodule.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2061,7 +2061,7 @@ _channel_get_info(_channels *channels, int64_t cid, struct channel_info *info)
20612061
if (interp == NULL) {
20622062
return -1;
20632063
}
2064-
Py_ssize_t interpid = PyInterpreterState_GetID(interp);
2064+
int64_t interpid = PyInterpreterState_GetID(interp);
20652065

20662066
// Hold the global lock until we're done.
20672067
PyThread_acquire_lock(channels->mutex, WAIT_LOCK);

Modules/_ssl.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -4707,7 +4707,9 @@ static unsigned int psk_client_callback(SSL *s,
47074707
goto error;
47084708
}
47094709

4710-
if (identity_len_ + 1 > max_identity_len || psk_len_ > max_psk_len) {
4710+
if ((size_t)identity_len_ + 1 > max_identity_len
4711+
|| (size_t)psk_len_ > max_psk_len)
4712+
{
47114713
Py_DECREF(result);
47124714
goto error;
47134715
}
@@ -4819,7 +4821,7 @@ static unsigned int psk_server_callback(SSL *s,
48194821
goto error;
48204822
}
48214823

4822-
if (psk_len_ > max_psk_len) {
4824+
if ((size_t)psk_len_ > max_psk_len) {
48234825
Py_DECREF(result);
48244826
goto error;
48254827
}

Modules/_winapi.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -2317,7 +2317,7 @@ _winapi_BatchedWaitForMultipleObjects_impl(PyObject *module,
23172317
BOOL wait_all, DWORD milliseconds)
23182318
/*[clinic end generated code: output=d21c1a4ad0a252fd input=7e196f29005dc77b]*/
23192319
{
2320-
Py_ssize_t thread_count = 0, handle_count = 0, i, j;
2320+
Py_ssize_t thread_count = 0, handle_count = 0, i;
23212321
Py_ssize_t nhandles;
23222322
BatchedWaitData *thread_data[MAXIMUM_WAIT_OBJECTS];
23232323
HANDLE handles[MAXIMUM_WAIT_OBJECTS];
@@ -2378,7 +2378,7 @@ _winapi_BatchedWaitForMultipleObjects_impl(PyObject *module,
23782378
if (data->handle_count > MAXIMUM_WAIT_OBJECTS - 1) {
23792379
data->handle_count = MAXIMUM_WAIT_OBJECTS - 1;
23802380
}
2381-
for (j = 0; j < data->handle_count; ++i, ++j) {
2381+
for (DWORD j = 0; j < data->handle_count; ++i, ++j) {
23822382
PyObject *v = PySequence_GetItem(handle_seq, i);
23832383
if (!v || !PyArg_Parse(v, F_HANDLE, &data->handles[j])) {
23842384
Py_XDECREF(v);
@@ -2526,7 +2526,7 @@ _winapi_BatchedWaitForMultipleObjects_impl(PyObject *module,
25262526
if (triggered_indices) {
25272527
for (i = 0; i < thread_count; ++i) {
25282528
Py_ssize_t triggered = (Py_ssize_t)thread_data[i]->result - WAIT_OBJECT_0;
2529-
if (triggered >= 0 && triggered < thread_data[i]->handle_count - 1) {
2529+
if (triggered >= 0 && (size_t)triggered < thread_data[i]->handle_count - 1) {
25302530
PyObject *v = PyLong_FromSsize_t(thread_data[i]->handle_base + triggered);
25312531
if (!v || PyList_Append(triggered_indices, v) < 0) {
25322532
Py_XDECREF(v);

PC/venvlauncher.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ find_home_value(const char *buffer, DWORD maxlen, const char **start, DWORD *len
223223
return 0;
224224
}
225225
for (const char *s = strstr(buffer, "home");
226-
s && ((ptrdiff_t)s - (ptrdiff_t)buffer) < maxlen;
226+
s && (size_t)((ptrdiff_t)s - (ptrdiff_t)buffer) < maxlen;
227227
s = strstr(s + 1, "\nhome")
228228
) {
229229
if (*s == '\n') {

0 commit comments

Comments
 (0)