Skip to content

Commit 51f8196

Browse files
authored
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()
1 parent 547d26a commit 51f8196

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Include/internal/pycore_asdl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *a
9191
(S)->typed_elements[_asdl_i] = (V); \
9292
} while (0)
9393
#else
94-
# define asdl_seq_SET(S, I, V) (S)->typed_elements[I] = (V)
94+
# define asdl_seq_SET(S, I, V) ((void)((S)->typed_elements[I] = (V)))
9595
#endif
9696

9797
#ifdef Py_DEBUG
@@ -103,7 +103,7 @@ asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *a
103103
(S)->elements[_asdl_i] = (V); \
104104
} while (0)
105105
#else
106-
# define asdl_seq_SET_UNTYPED(S, I, V) (S)->elements[I] = (V)
106+
# define asdl_seq_SET_UNTYPED(S, I, V) ((void)((S)->elements[I] = (V)))
107107
#endif
108108

109109
#ifdef __cplusplus

Include/internal/pycore_gc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ typedef struct {
4343
// Lowest bit of _gc_next is used for flags only in GC.
4444
// But it is always 0 for normal code.
4545
#define _PyGCHead_NEXT(g) ((PyGC_Head*)(g)->_gc_next)
46-
#define _PyGCHead_SET_NEXT(g, p) ((g)->_gc_next = (uintptr_t)(p))
46+
#define _PyGCHead_SET_NEXT(g, p) ((void)((g)->_gc_next = (uintptr_t)(p)))
4747

4848
// Lowest two bits of _gc_prev is used for _PyGC_PREV_MASK_* flags.
4949
#define _PyGCHead_PREV(g) ((PyGC_Head*)((g)->_gc_prev & _PyGC_PREV_MASK))
@@ -56,7 +56,7 @@ typedef struct {
5656
#define _PyGCHead_FINALIZED(g) \
5757
(((g)->_gc_prev & _PyGC_PREV_MASK_FINALIZED) != 0)
5858
#define _PyGCHead_SET_FINALIZED(g) \
59-
((g)->_gc_prev |= _PyGC_PREV_MASK_FINALIZED)
59+
((void)((g)->_gc_prev |= _PyGC_PREV_MASK_FINALIZED))
6060

6161
#define _PyGC_FINALIZED(o) \
6262
_PyGCHead_FINALIZED(_Py_AS_GC(o))

0 commit comments

Comments
 (0)