summaryrefslogtreecommitdiffstats
path: root/Include/internal
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2021-10-15 17:44:35 (GMT)
committerGitHub <noreply@github.com>2021-10-15 17:44:35 (GMT)
commit51f8196d05f0e271358eee0f90fe044b20449fb5 (patch)
treefe8cca5dca4f3ed8534701b958933b0aec1afcf4 /Include/internal
parent547d26aa08aa5e4ec6e4f8a5587b30b39064a5ba (diff)
downloadcpython-51f8196d05f0e271358eee0f90fe044b20449fb5.zip
cpython-51f8196d05f0e271358eee0f90fe044b20449fb5.tar.gz
cpython-51f8196d05f0e271358eee0f90fe044b20449fb5.tar.bz2
bpo-30459: Use (void) in macros setting variables (GH-28982)
Convert the result of macros setting variables to void to avoid risks of misusing them: * _PyGCHead_SET_NEXT() * asdl_seq_SET() * asdl_seq_SET_UNTYPED()
Diffstat (limited to 'Include/internal')
-rw-r--r--Include/internal/pycore_asdl.h4
-rw-r--r--Include/internal/pycore_gc.h4
2 files changed, 4 insertions, 4 deletions
diff --git a/Include/internal/pycore_asdl.h b/Include/internal/pycore_asdl.h
index c0b07c3..2929e03 100644
--- a/Include/internal/pycore_asdl.h
+++ b/Include/internal/pycore_asdl.h
@@ -91,7 +91,7 @@ asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *a
(S)->typed_elements[_asdl_i] = (V); \
} while (0)
#else
-# define asdl_seq_SET(S, I, V) (S)->typed_elements[I] = (V)
+# define asdl_seq_SET(S, I, V) ((void)((S)->typed_elements[I] = (V)))
#endif
#ifdef Py_DEBUG
@@ -103,7 +103,7 @@ asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *a
(S)->elements[_asdl_i] = (V); \
} while (0)
#else
-# define asdl_seq_SET_UNTYPED(S, I, V) (S)->elements[I] = (V)
+# define asdl_seq_SET_UNTYPED(S, I, V) ((void)((S)->elements[I] = (V)))
#endif
#ifdef __cplusplus
diff --git a/Include/internal/pycore_gc.h b/Include/internal/pycore_gc.h
index 9db4a47..45e85b5 100644
--- a/Include/internal/pycore_gc.h
+++ b/Include/internal/pycore_gc.h
@@ -43,7 +43,7 @@ typedef struct {
// Lowest bit of _gc_next is used for flags only in GC.
// But it is always 0 for normal code.
#define _PyGCHead_NEXT(g) ((PyGC_Head*)(g)->_gc_next)
-#define _PyGCHead_SET_NEXT(g, p) ((g)->_gc_next = (uintptr_t)(p))
+#define _PyGCHead_SET_NEXT(g, p) ((void)((g)->_gc_next = (uintptr_t)(p)))
// Lowest two bits of _gc_prev is used for _PyGC_PREV_MASK_* flags.
#define _PyGCHead_PREV(g) ((PyGC_Head*)((g)->_gc_prev & _PyGC_PREV_MASK))
@@ -56,7 +56,7 @@ typedef struct {
#define _PyGCHead_FINALIZED(g) \
(((g)->_gc_prev & _PyGC_PREV_MASK_FINALIZED) != 0)
#define _PyGCHead_SET_FINALIZED(g) \
- ((g)->_gc_prev |= _PyGC_PREV_MASK_FINALIZED)
+ ((void)((g)->_gc_prev |= _PyGC_PREV_MASK_FINALIZED))
#define _PyGC_FINALIZED(o) \
_PyGCHead_FINALIZED(_Py_AS_GC(o))