Skip to content

Commit 0b67ce9

Browse files
authored
gh-126433: Fix compiler warnings on 32-bit Windows (#126444)
1 parent bbfd9c9 commit 0b67ce9

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
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
@@ -4923,7 +4923,9 @@ static unsigned int psk_client_callback(SSL *s,
49234923
goto error;
49244924
}
49254925

4926-
if (identity_len_ + 1 > max_identity_len || psk_len_ > max_psk_len) {
4926+
if ((size_t)identity_len_ + 1 > max_identity_len
4927+
|| (size_t)psk_len_ > max_psk_len)
4928+
{
49274929
Py_DECREF(result);
49284930
goto error;
49294931
}
@@ -5036,7 +5038,7 @@ static unsigned int psk_server_callback(SSL *s,
50365038
goto error;
50375039
}
50385040

5039-
if (psk_len_ > max_psk_len) {
5041+
if ((size_t)psk_len_ > max_psk_len) {
50405042
Py_DECREF(result);
50415043
goto error;
50425044
}

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);

Modules/blake2module.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ py_blake2b_or_s_new(PyTypeObject *type, PyObject *data, int digest_size,
474474

475475
/* Validate salt parameter. */
476476
if ((salt->obj != NULL) && salt->len) {
477-
if (salt->len > (is_blake2b(self->impl) ? HACL_HASH_BLAKE2B_SALT_BYTES : HACL_HASH_BLAKE2S_SALT_BYTES)) {
477+
if ((size_t)salt->len > (is_blake2b(self->impl) ? HACL_HASH_BLAKE2B_SALT_BYTES : HACL_HASH_BLAKE2S_SALT_BYTES)) {
478478
PyErr_Format(PyExc_ValueError,
479479
"maximum salt length is %d bytes",
480480
(is_blake2b(self->impl) ? HACL_HASH_BLAKE2B_SALT_BYTES : HACL_HASH_BLAKE2S_SALT_BYTES));
@@ -485,7 +485,7 @@ py_blake2b_or_s_new(PyTypeObject *type, PyObject *data, int digest_size,
485485

486486
/* Validate personalization parameter. */
487487
if ((person->obj != NULL) && person->len) {
488-
if (person->len > (is_blake2b(self->impl) ? HACL_HASH_BLAKE2B_PERSONAL_BYTES : HACL_HASH_BLAKE2S_PERSONAL_BYTES)) {
488+
if ((size_t)person->len > (is_blake2b(self->impl) ? HACL_HASH_BLAKE2B_PERSONAL_BYTES : HACL_HASH_BLAKE2S_PERSONAL_BYTES)) {
489489
PyErr_Format(PyExc_ValueError,
490490
"maximum person length is %d bytes",
491491
(is_blake2b(self->impl) ? HACL_HASH_BLAKE2B_PERSONAL_BYTES : HACL_HASH_BLAKE2S_PERSONAL_BYTES));
@@ -534,7 +534,7 @@ py_blake2b_or_s_new(PyTypeObject *type, PyObject *data, int digest_size,
534534

535535
/* Set key length. */
536536
if ((key->obj != NULL) && key->len) {
537-
if (key->len > (is_blake2b(self->impl) ? HACL_HASH_BLAKE2B_KEY_BYTES : HACL_HASH_BLAKE2S_KEY_BYTES)) {
537+
if ((size_t)key->len > (is_blake2b(self->impl) ? HACL_HASH_BLAKE2B_KEY_BYTES : HACL_HASH_BLAKE2S_KEY_BYTES)) {
538538
PyErr_Format(PyExc_ValueError,
539539
"maximum key length is %d bytes",
540540
(is_blake2b(self->impl) ? HACL_HASH_BLAKE2B_KEY_BYTES : HACL_HASH_BLAKE2S_KEY_BYTES));

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)