Skip to content

Commit 98f93a3

Browse files
authored
gh-124064: Fix -Wconversion warnings in pycore_{gc,list,stackref}.h (#124174)
1 parent 33eeccf commit 98f93a3

File tree

5 files changed

+4
-9
lines changed

5 files changed

+4
-9
lines changed

Include/internal/pycore_gc.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ static inline void _PyGC_CLEAR_FINALIZED(PyObject *op) {
227227
_PyObject_CLEAR_GC_BITS(op, _PyGC_BITS_FINALIZED);
228228
#else
229229
PyGC_Head *gc = _Py_AS_GC(op);
230-
gc->_gc_prev &= ~_PyGC_PREV_MASK_FINALIZED;
230+
gc->_gc_prev &= ~(uintptr_t)_PyGC_PREV_MASK_FINALIZED;
231231
#endif
232232
}
233233

Include/internal/pycore_list.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ _Py_memory_repeat(char* dest, Py_ssize_t len_dest, Py_ssize_t len_src)
4545
Py_ssize_t copied = len_src;
4646
while (copied < len_dest) {
4747
Py_ssize_t bytes_to_copy = Py_MIN(copied, len_dest - copied);
48-
memcpy(dest + copied, dest, bytes_to_copy);
48+
memcpy(dest + copied, dest, (size_t)bytes_to_copy);
4949
copied += bytes_to_copy;
5050
}
5151
}

Include/internal/pycore_stackref.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ typedef union _PyStackRef {
9898
static inline PyObject *
9999
PyStackRef_AsPyObjectBorrow(_PyStackRef stackref)
100100
{
101-
PyObject *cleared = ((PyObject *)((stackref).bits & (~Py_TAG_BITS)));
101+
PyObject *cleared = ((PyObject *)((stackref).bits & (~(uintptr_t)Py_TAG_BITS)));
102102
return cleared;
103103
}
104104
#else
@@ -133,7 +133,7 @@ _PyStackRef_FromPyObjectSteal(PyObject *obj)
133133
{
134134
// Make sure we don't take an already tagged value.
135135
assert(((uintptr_t)obj & Py_TAG_BITS) == 0);
136-
int tag = (obj == NULL || _Py_IsImmortal(obj)) ? (Py_TAG_DEFERRED) : Py_TAG_PTR;
136+
unsigned int tag = (obj == NULL || _Py_IsImmortal(obj)) ? (Py_TAG_DEFERRED) : Py_TAG_PTR;
137137
return ((_PyStackRef){.bits = ((uintptr_t)(obj)) | tag});
138138
}
139139
# define PyStackRef_FromPyObjectSteal(obj) _PyStackRef_FromPyObjectSteal(_PyObject_CAST(obj))

Tools/build/.warningignore_macos

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
Include/internal/mimalloc/mimalloc/internal.h 4
77
Include/internal/pycore_backoff.h 1
88
Include/internal/pycore_dict.h 2
9-
Include/internal/pycore_gc.h 1
109
Include/internal/pycore_long.h 2
1110
Include/internal/pycore_object.h 4
1211
Modules/_asynciomodule.c 3

Tools/build/.warningignore_ubuntu

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ Include/internal/pycore_asdl.h 1
1919
Include/internal/pycore_backoff.h 3
2020
Include/internal/pycore_blocks_output_buffer.h 1
2121
Include/internal/pycore_dict.h 2
22-
Include/internal/pycore_gc.h 1
23-
Include/internal/pycore_gc.h 1
2422
Include/internal/pycore_interp.h 1
25-
Include/internal/pycore_list.h 1
2623
Include/internal/pycore_long.h 3
2724
Include/internal/pycore_object.h 4
2825
Include/internal/pycore_obmalloc.h 1
@@ -233,7 +230,6 @@ Python/generated_cases.c.h 27
233230
Python/generated_cases.c.h 27
234231
Python/getargs.c 7
235232
Python/hashtable.c 1
236-
Python/import.c 6
237233
Python/import.c 7
238234
Python/initconfig.c 11
239235
Python/instrumentation.c 43

0 commit comments

Comments
 (0)