mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
gh-124064: Fix -Wconversion warnings in pycore_{long,object}.h (#124177)
Change also the fix for pycore_gc.h and pycore_stackref.h: declare constants as uintptr_t, rather than casting constants.
This commit is contained in:
parent
ab80c6b402
commit
ec08aa1fe4
6 changed files with 19 additions and 24 deletions
|
|
@ -228,7 +228,7 @@ static inline Py_ssize_t
|
|||
_PyLong_DigitCount(const PyLongObject *op)
|
||||
{
|
||||
assert(PyLong_Check(op));
|
||||
return op->long_value.lv_tag >> NON_SIZE_BITS;
|
||||
return (Py_ssize_t)(op->long_value.lv_tag >> NON_SIZE_BITS);
|
||||
}
|
||||
|
||||
/* Equivalent to _PyLong_DigitCount(op) * _PyLong_NonCompactSign(op) */
|
||||
|
|
@ -263,7 +263,8 @@ _PyLong_SameSign(const PyLongObject *a, const PyLongObject *b)
|
|||
return (a->long_value.lv_tag & SIGN_MASK) == (b->long_value.lv_tag & SIGN_MASK);
|
||||
}
|
||||
|
||||
#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS))
|
||||
#define TAG_FROM_SIGN_AND_SIZE(sign, size) \
|
||||
((uintptr_t)(1 - (sign)) | ((uintptr_t)(size) << NON_SIZE_BITS))
|
||||
|
||||
static inline void
|
||||
_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
|
||||
|
|
@ -271,7 +272,7 @@ _PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
|
|||
assert(size >= 0);
|
||||
assert(-1 <= sign && sign <= 1);
|
||||
assert(sign != 0 || size == 0);
|
||||
op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, (size_t)size);
|
||||
op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, size);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
@ -281,7 +282,7 @@ _PyLong_SetDigitCount(PyLongObject *op, Py_ssize_t size)
|
|||
op->long_value.lv_tag = (((size_t)size) << NON_SIZE_BITS) | (op->long_value.lv_tag & SIGN_MASK);
|
||||
}
|
||||
|
||||
#define NON_SIZE_MASK ~((1 << NON_SIZE_BITS) - 1)
|
||||
#define NON_SIZE_MASK ~(uintptr_t)((1 << NON_SIZE_BITS) - 1)
|
||||
|
||||
static inline void
|
||||
_PyLong_FlipSign(PyLongObject *op) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue