]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-126433: Fix compiler warnings on 32-bit Windows (#126444)
authorVictor Stinner <vstinner@python.org>
Tue, 5 Nov 2024 15:05:13 +0000 (16:05 +0100)
committerGitHub <noreply@github.com>
Tue, 5 Nov 2024 15:05:13 +0000 (16:05 +0100)
Modules/_interpchannelsmodule.c
Modules/_ssl.c
Modules/_winapi.c
Modules/blake2module.c
PC/venvlauncher.c

index 8e6b21db76e01c87550158fa36682c982020d118..68ee429a9e1dfe54ace8e7101d2927fead5b86f9 100644 (file)
@@ -2061,7 +2061,7 @@ _channel_get_info(_channels *channels, int64_t cid, struct channel_info *info)
     if (interp == NULL) {
         return -1;
     }
-    Py_ssize_t interpid = PyInterpreterState_GetID(interp);
+    int64_t interpid = PyInterpreterState_GetID(interp);
 
     // Hold the global lock until we're done.
     PyThread_acquire_lock(channels->mutex, WAIT_LOCK);
index 54bac28e5beccf1b405e77e8f566d43906bf42ae..5223e21b5cdb11f99a71cd3f663a8e1ae49baa58 100644 (file)
@@ -4923,7 +4923,9 @@ static unsigned int psk_client_callback(SSL *s,
         goto error;
     }
 
-    if (identity_len_ + 1 > max_identity_len || psk_len_ > max_psk_len) {
+    if ((size_t)identity_len_ + 1 > max_identity_len
+        || (size_t)psk_len_ > max_psk_len)
+    {
         Py_DECREF(result);
         goto error;
     }
@@ -5036,7 +5038,7 @@ static unsigned int psk_server_callback(SSL *s,
         goto error;
     }
 
-    if (psk_len_ > max_psk_len) {
+    if ((size_t)psk_len_ > max_psk_len) {
         Py_DECREF(result);
         goto error;
     }
index a330b3ff68db622cbaccb565d46d21115a2feaa3..4ce689fe30e6df52bf3e954f56047bd26515eb2c 100644 (file)
@@ -2317,7 +2317,7 @@ _winapi_BatchedWaitForMultipleObjects_impl(PyObject *module,
                                            BOOL wait_all, DWORD milliseconds)
 /*[clinic end generated code: output=d21c1a4ad0a252fd input=7e196f29005dc77b]*/
 {
-    Py_ssize_t thread_count = 0, handle_count = 0, i, j;
+    Py_ssize_t thread_count = 0, handle_count = 0, i;
     Py_ssize_t nhandles;
     BatchedWaitData *thread_data[MAXIMUM_WAIT_OBJECTS];
     HANDLE handles[MAXIMUM_WAIT_OBJECTS];
@@ -2378,7 +2378,7 @@ _winapi_BatchedWaitForMultipleObjects_impl(PyObject *module,
         if (data->handle_count > MAXIMUM_WAIT_OBJECTS - 1) {
             data->handle_count = MAXIMUM_WAIT_OBJECTS - 1;
         }
-        for (j = 0; j < data->handle_count; ++i, ++j) {
+        for (DWORD j = 0; j < data->handle_count; ++i, ++j) {
             PyObject *v = PySequence_GetItem(handle_seq, i);
             if (!v || !PyArg_Parse(v, F_HANDLE, &data->handles[j])) {
                 Py_XDECREF(v);
@@ -2526,7 +2526,7 @@ _winapi_BatchedWaitForMultipleObjects_impl(PyObject *module,
         if (triggered_indices) {
             for (i = 0; i < thread_count; ++i) {
                 Py_ssize_t triggered = (Py_ssize_t)thread_data[i]->result - WAIT_OBJECT_0;
-                if (triggered >= 0 && triggered < thread_data[i]->handle_count - 1) {
+                if (triggered >= 0 && (size_t)triggered < thread_data[i]->handle_count - 1) {
                     PyObject *v = PyLong_FromSsize_t(thread_data[i]->handle_base + triggered);
                     if (!v || PyList_Append(triggered_indices, v) < 0) {
                         Py_XDECREF(v);
index 1ec676c34c6128bb0a560a2e563a52f17f027ed0..94cdfe7fd2e962d6425223d644447e3307c9b233 100644 (file)
@@ -474,7 +474,7 @@ py_blake2b_or_s_new(PyTypeObject *type, PyObject *data, int digest_size,
 
     /* Validate salt parameter. */
     if ((salt->obj != NULL) && salt->len) {
-        if (salt->len > (is_blake2b(self->impl) ? HACL_HASH_BLAKE2B_SALT_BYTES : HACL_HASH_BLAKE2S_SALT_BYTES)) {
+        if ((size_t)salt->len > (is_blake2b(self->impl) ? HACL_HASH_BLAKE2B_SALT_BYTES : HACL_HASH_BLAKE2S_SALT_BYTES)) {
             PyErr_Format(PyExc_ValueError,
                 "maximum salt length is %d bytes",
                 (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,
 
     /* Validate personalization parameter. */
     if ((person->obj != NULL) && person->len) {
-        if (person->len > (is_blake2b(self->impl) ? HACL_HASH_BLAKE2B_PERSONAL_BYTES : HACL_HASH_BLAKE2S_PERSONAL_BYTES)) {
+        if ((size_t)person->len > (is_blake2b(self->impl) ? HACL_HASH_BLAKE2B_PERSONAL_BYTES : HACL_HASH_BLAKE2S_PERSONAL_BYTES)) {
             PyErr_Format(PyExc_ValueError,
                 "maximum person length is %d bytes",
                 (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,
 
     /* Set key length. */
     if ((key->obj != NULL) && key->len) {
-        if (key->len > (is_blake2b(self->impl) ? HACL_HASH_BLAKE2B_KEY_BYTES : HACL_HASH_BLAKE2S_KEY_BYTES)) {
+        if ((size_t)key->len > (is_blake2b(self->impl) ? HACL_HASH_BLAKE2B_KEY_BYTES : HACL_HASH_BLAKE2S_KEY_BYTES)) {
             PyErr_Format(PyExc_ValueError,
                 "maximum key length is %d bytes",
                 (is_blake2b(self->impl) ? HACL_HASH_BLAKE2B_KEY_BYTES : HACL_HASH_BLAKE2S_KEY_BYTES));
index b1c8d0763d8c76aaaa29846876a1e15bfc65df38..b6bb0218236ae9ddf725fe7f74370e21c59534a8 100644 (file)
@@ -223,7 +223,7 @@ find_home_value(const char *buffer, DWORD maxlen, const char **start, DWORD *len
         return 0;
     }
     for (const char *s = strstr(buffer, "home");
-         s && ((ptrdiff_t)s - (ptrdiff_t)buffer) < maxlen;
+         s && (size_t)((ptrdiff_t)s - (ptrdiff_t)buffer) < maxlen;
          s = strstr(s + 1, "\nhome")
     ) {
         if (*s == '\n') {