2023-05-04 21:02:38

by Mathieu Desnoyers

[permalink] [raw]
Subject: [RFC PATCH 06/13] list_nulls.h: Fix parentheses around macro pointer parameter use

Add missing parentheses around use of macro argument "pos" in those
patterns to ensure operator precedence behaves as expected:

- typeof(*tpos)
- pos->next

The typeof(*tpos) lack of parentheses around "tpos" is not an issue per se
in the specific macros modified here because "tpos" is used as an lvalue,
which should prevent use of any operator causing issue. Still add the
extra parentheses for consistency.

Signed-off-by: Mathieu Desnoyers <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Eric Dumazet <[email protected]>
---
include/linux/list_nulls.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/list_nulls.h b/include/linux/list_nulls.h
index fa6e8471bd22..74ffde881e44 100644
--- a/include/linux/list_nulls.h
+++ b/include/linux/list_nulls.h
@@ -127,8 +127,8 @@ static inline void hlist_nulls_del(struct hlist_nulls_node *n)
#define hlist_nulls_for_each_entry(tpos, pos, head, member) \
for (pos = (head)->first; \
(!is_a_nulls(pos)) && \
- ({ tpos = hlist_nulls_entry(pos, typeof(*tpos), member); 1;}); \
- pos = pos->next)
+ ({ tpos = hlist_nulls_entry(pos, typeof(*(tpos)), member); 1;}); \
+ pos = (pos)->next)

/**
* hlist_nulls_for_each_entry_from - iterate over a hlist continuing from current point
@@ -139,7 +139,7 @@ static inline void hlist_nulls_del(struct hlist_nulls_node *n)
*/
#define hlist_nulls_for_each_entry_from(tpos, pos, member) \
for (; (!is_a_nulls(pos)) && \
- ({ tpos = hlist_nulls_entry(pos, typeof(*tpos), member); 1;}); \
- pos = pos->next)
+ ({ tpos = hlist_nulls_entry(pos, typeof(*(tpos)), member); 1;}); \
+ pos = (pos)->next)

#endif
--
2.25.1