[RFC,06/13] list_nulls.h: Fix parentheses around macro pointer parameter use

Message ID 20230504200527.1935944-7-mathieu.desnoyers@efficios.com
State New
Headers
Series Fix parentheses around macro parameter use in headers |

Commit Message

Mathieu Desnoyers May 4, 2023, 8:05 p.m. UTC
  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 <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Eric Dumazet <edumazet@google.com>
---
 include/linux/list_nulls.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Patch

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