From 6899ab18eb5b50d3691af805a21556b325d05e99 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 17 Sep 2024 15:52:35 +0200 Subject: [PATCH 1/4] gh-124064: Fix some -Wconversion warnings --- Include/internal/pycore_gc.h | 2 +- Include/internal/pycore_list.h | 2 +- Include/internal/pycore_stackref.h | 4 ++-- Parser/pegen.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Include/internal/pycore_gc.h b/Include/internal/pycore_gc.h index b674313d97ff82..0d6b292b9f3530 100644 --- a/Include/internal/pycore_gc.h +++ b/Include/internal/pycore_gc.h @@ -227,7 +227,7 @@ static inline void _PyGC_CLEAR_FINALIZED(PyObject *op) { _PyObject_CLEAR_GC_BITS(op, _PyGC_BITS_FINALIZED); #else PyGC_Head *gc = _Py_AS_GC(op); - gc->_gc_prev &= ~_PyGC_PREV_MASK_FINALIZED; + gc->_gc_prev &= ~(uintptr_t)_PyGC_PREV_MASK_FINALIZED; #endif } diff --git a/Include/internal/pycore_list.h b/Include/internal/pycore_list.h index 12b42c1b788607..2c666f9be4bd79 100644 --- a/Include/internal/pycore_list.h +++ b/Include/internal/pycore_list.h @@ -45,7 +45,7 @@ _Py_memory_repeat(char* dest, Py_ssize_t len_dest, Py_ssize_t len_src) Py_ssize_t copied = len_src; while (copied < len_dest) { Py_ssize_t bytes_to_copy = Py_MIN(copied, len_dest - copied); - memcpy(dest + copied, dest, bytes_to_copy); + memcpy(dest + copied, dest, (size_t)bytes_to_copy); copied += bytes_to_copy; } } diff --git a/Include/internal/pycore_stackref.h b/Include/internal/pycore_stackref.h index f23f641a47e25f..7035f9545703c4 100644 --- a/Include/internal/pycore_stackref.h +++ b/Include/internal/pycore_stackref.h @@ -98,7 +98,7 @@ typedef union _PyStackRef { static inline PyObject * PyStackRef_AsPyObjectBorrow(_PyStackRef stackref) { - PyObject *cleared = ((PyObject *)((stackref).bits & (~Py_TAG_BITS))); + PyObject *cleared = ((PyObject *)((stackref).bits & (~(uintptr_t)Py_TAG_BITS))); return cleared; } #else @@ -133,7 +133,7 @@ _PyStackRef_FromPyObjectSteal(PyObject *obj) { // Make sure we don't take an already tagged value. assert(((uintptr_t)obj & Py_TAG_BITS) == 0); - int tag = (obj == NULL || _Py_IsImmortal(obj)) ? (Py_TAG_DEFERRED) : Py_TAG_PTR; + unsigned int tag = (obj == NULL || _Py_IsImmortal(obj)) ? (Py_TAG_DEFERRED) : Py_TAG_PTR; return ((_PyStackRef){.bits = ((uintptr_t)(obj)) | tag}); } # define PyStackRef_FromPyObjectSteal(obj) _PyStackRef_FromPyObjectSteal(_PyObject_CAST(obj)) diff --git a/Parser/pegen.c b/Parser/pegen.c index 0c3c4689dd7ce6..b0eb2e2189d25e 100644 --- a/Parser/pegen.c +++ b/Parser/pegen.c @@ -26,7 +26,7 @@ _PyPegen_byte_offset_to_character_offset_line(PyObject *line, Py_ssize_t col_off Py_ssize_t len = 0; while (col_offset < end_col_offset) { - Py_UCS4 ch = data[col_offset]; + Py_UCS4 ch = (unsigned char)data[col_offset]; if (ch < 0x80) { col_offset += 1; } else if ((ch & 0xe0) == 0xc0) { From 622cc5cae50e7c7bd635b5d6589e8fff495a5f0b Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 17 Sep 2024 16:05:22 +0200 Subject: [PATCH 2/4] Update warnings ignore files --- Tools/build/.warningignore_macos | 2 -- Tools/build/.warningignore_ubuntu | 4 ---- 2 files changed, 6 deletions(-) diff --git a/Tools/build/.warningignore_macos b/Tools/build/.warningignore_macos index 3034638595353a..7a8fb25c8ce0f6 100644 --- a/Tools/build/.warningignore_macos +++ b/Tools/build/.warningignore_macos @@ -6,7 +6,6 @@ Include/internal/mimalloc/mimalloc/internal.h 4 Include/internal/pycore_backoff.h 1 Include/internal/pycore_dict.h 2 -Include/internal/pycore_gc.h 1 Include/internal/pycore_long.h 2 Include/internal/pycore_object.h 4 Modules/_asynciomodule.c 3 @@ -176,7 +175,6 @@ Parser/action_helpers.c 4 Parser/lexer/buffer.c 1 Parser/lexer/lexer.c 12 Parser/parser.c 116 -Parser/pegen.c 7 Parser/string_parser.c 7 Parser/tokenizer/file_tokenizer.c 8 Parser/tokenizer/helpers.c 7 diff --git a/Tools/build/.warningignore_ubuntu b/Tools/build/.warningignore_ubuntu index e98305e81808d6..afc06683e61a4c 100644 --- a/Tools/build/.warningignore_ubuntu +++ b/Tools/build/.warningignore_ubuntu @@ -19,10 +19,7 @@ Include/internal/pycore_asdl.h 1 Include/internal/pycore_backoff.h 3 Include/internal/pycore_blocks_output_buffer.h 1 Include/internal/pycore_dict.h 2 -Include/internal/pycore_gc.h 1 -Include/internal/pycore_gc.h 1 Include/internal/pycore_interp.h 1 -Include/internal/pycore_list.h 1 Include/internal/pycore_long.h 3 Include/internal/pycore_object.h 4 Include/internal/pycore_obmalloc.h 1 @@ -204,7 +201,6 @@ Parser/action_helpers.c 3 Parser/lexer/buffer.c 1 Parser/lexer/lexer.c 14 Parser/parser.c 116 -Parser/pegen.c 8 Parser/string_parser.c 7 Parser/tokenizer/file_tokenizer.c 9 Parser/tokenizer/helpers.c 7 From ee637e698a9094a3c1bb79dc01408b580c85ec5c Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 17 Sep 2024 16:14:32 +0200 Subject: [PATCH 3/4] revert pegen --- Parser/pegen.c | 2 +- Tools/build/.warningignore_macos | 1 + Tools/build/.warningignore_ubuntu | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Parser/pegen.c b/Parser/pegen.c index b0eb2e2189d25e..0c3c4689dd7ce6 100644 --- a/Parser/pegen.c +++ b/Parser/pegen.c @@ -26,7 +26,7 @@ _PyPegen_byte_offset_to_character_offset_line(PyObject *line, Py_ssize_t col_off Py_ssize_t len = 0; while (col_offset < end_col_offset) { - Py_UCS4 ch = (unsigned char)data[col_offset]; + Py_UCS4 ch = data[col_offset]; if (ch < 0x80) { col_offset += 1; } else if ((ch & 0xe0) == 0xc0) { diff --git a/Tools/build/.warningignore_macos b/Tools/build/.warningignore_macos index 7a8fb25c8ce0f6..b5b1661b4c11e8 100644 --- a/Tools/build/.warningignore_macos +++ b/Tools/build/.warningignore_macos @@ -175,6 +175,7 @@ Parser/action_helpers.c 4 Parser/lexer/buffer.c 1 Parser/lexer/lexer.c 12 Parser/parser.c 116 +Parser/pegen.c 7 Parser/string_parser.c 7 Parser/tokenizer/file_tokenizer.c 8 Parser/tokenizer/helpers.c 7 diff --git a/Tools/build/.warningignore_ubuntu b/Tools/build/.warningignore_ubuntu index afc06683e61a4c..56123edc0423fd 100644 --- a/Tools/build/.warningignore_ubuntu +++ b/Tools/build/.warningignore_ubuntu @@ -201,6 +201,7 @@ Parser/action_helpers.c 3 Parser/lexer/buffer.c 1 Parser/lexer/lexer.c 14 Parser/parser.c 116 +Parser/pegen.c 8 Parser/string_parser.c 7 Parser/tokenizer/file_tokenizer.c 9 Parser/tokenizer/helpers.c 7 From ae8406c4a677cbcc01504582635f5d699a574380 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 17 Sep 2024 16:18:48 +0200 Subject: [PATCH 4/4] update import.c warnings count --- Tools/build/.warningignore_ubuntu | 1 - 1 file changed, 1 deletion(-) diff --git a/Tools/build/.warningignore_ubuntu b/Tools/build/.warningignore_ubuntu index 56123edc0423fd..ff7038f42d6c2d 100644 --- a/Tools/build/.warningignore_ubuntu +++ b/Tools/build/.warningignore_ubuntu @@ -230,7 +230,6 @@ Python/generated_cases.c.h 27 Python/generated_cases.c.h 27 Python/getargs.c 7 Python/hashtable.c 1 -Python/import.c 6 Python/import.c 7 Python/initconfig.c 11 Python/instrumentation.c 43