diff options
author | Victor Stinner <vstinner@python.org> | 2022-11-28 16:42:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-28 16:42:22 (GMT) |
commit | 7bae15cf37239d4d345e09cc318bd82d03ec30cd (patch) | |
tree | 578f5942b8a43b9720cf02bb5d35e7cd4d3926c6 /Include/internal | |
parent | 65417988a589e6edfeada83227a8b0884a64af4f (diff) | |
download | cpython-7bae15cf37239d4d345e09cc318bd82d03ec30cd.zip cpython-7bae15cf37239d4d345e09cc318bd82d03ec30cd.tar.gz cpython-7bae15cf37239d4d345e09cc318bd82d03ec30cd.tar.bz2 |
Use _Py_RVALUE() in macros (#99844)
The following macros are modified to use _Py_RVALUE(), so they can no
longer be used as l-value:
* DK_LOG_SIZE()
* _PyCode_CODE()
* _PyList_ITEMS()
* _PyTuple_ITEMS()
* _Py_SLIST_HEAD()
* _Py_SLIST_ITEM_NEXT()
_PyCode_CODE() is private and other macros are part of the internal
C API.
Diffstat (limited to 'Include/internal')
-rw-r--r-- | Include/internal/pycore_dict.h | 2 | ||||
-rw-r--r-- | Include/internal/pycore_hashtable.h | 4 | ||||
-rw-r--r-- | Include/internal/pycore_list.h | 2 | ||||
-rw-r--r-- | Include/internal/pycore_tuple.h | 2 |
4 files changed, 5 insertions, 5 deletions
diff --git a/Include/internal/pycore_dict.h b/Include/internal/pycore_dict.h index 04b7084..2b3b56b 100644 --- a/Include/internal/pycore_dict.h +++ b/Include/internal/pycore_dict.h @@ -122,7 +122,7 @@ struct _dictvalues { PyObject *values[1]; }; -#define DK_LOG_SIZE(dk) ((dk)->dk_log2_size) +#define DK_LOG_SIZE(dk) _Py_RVALUE((dk)->dk_log2_size) #if SIZEOF_VOID_P > 4 #define DK_SIZE(dk) (((int64_t)1)<<DK_LOG_SIZE(dk)) #else diff --git a/Include/internal/pycore_hashtable.h b/Include/internal/pycore_hashtable.h index 2aa23a2..6501ab1 100644 --- a/Include/internal/pycore_hashtable.h +++ b/Include/internal/pycore_hashtable.h @@ -18,9 +18,9 @@ typedef struct { _Py_slist_item_t *head; } _Py_slist_t; -#define _Py_SLIST_ITEM_NEXT(ITEM) (((_Py_slist_item_t *)(ITEM))->next) +#define _Py_SLIST_ITEM_NEXT(ITEM) _Py_RVALUE(((_Py_slist_item_t *)(ITEM))->next) -#define _Py_SLIST_HEAD(SLIST) (((_Py_slist_t *)(SLIST))->head) +#define _Py_SLIST_HEAD(SLIST) _Py_RVALUE(((_Py_slist_t *)(SLIST))->head) /* _Py_hashtable: table entry */ diff --git a/Include/internal/pycore_list.h b/Include/internal/pycore_list.h index 691d13b..628267c 100644 --- a/Include/internal/pycore_list.h +++ b/Include/internal/pycore_list.h @@ -35,7 +35,7 @@ struct _Py_list_state { #endif }; -#define _PyList_ITEMS(op) (_PyList_CAST(op)->ob_item) +#define _PyList_ITEMS(op) _Py_RVALUE(_PyList_CAST(op)->ob_item) extern int _PyList_AppendTakeRefListResize(PyListObject *self, PyObject *newitem); diff --git a/Include/internal/pycore_tuple.h b/Include/internal/pycore_tuple.h index 1efe4fa..504c363 100644 --- a/Include/internal/pycore_tuple.h +++ b/Include/internal/pycore_tuple.h @@ -62,7 +62,7 @@ struct _Py_tuple_state { #endif }; -#define _PyTuple_ITEMS(op) (_PyTuple_CAST(op)->ob_item) +#define _PyTuple_ITEMS(op) _Py_RVALUE(_PyTuple_CAST(op)->ob_item) extern PyObject *_PyTuple_FromArray(PyObject *const *, Py_ssize_t); extern PyObject *_PyTuple_FromArraySteal(PyObject *const *, Py_ssize_t); |