From 8cc74270405bbca5afa989b61c76b554c5b4f5a6 Mon Sep 17 00:00:00 2001 From: Thierry Escande Date: Wed, 30 Apr 2014 02:15:15 +0200 Subject: [PATCH] Fix list_for_each_safe macro The second macro parameter is named 'next' like listnode structure 'next' field. Since the precompiler will expand all 'next' occurrences in the macro definition with what is passed by the caller, it is not possible to call this macro with something else than 'next' as second parameter. This patch replaces the 'next' parameter with 'n' allowing use of a next node not named 'next'. Change-Id: I78c859caf8193f21fe0bedaeaa8342d6e89ad14b Signed-off-by: Thierry Escande Signed-off-by: Samuel Ortiz --- include/cutils/list.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/cutils/list.h b/include/cutils/list.h index 945729ab2..6a6891b83 100644 --- a/include/cutils/list.h +++ b/include/cutils/list.h @@ -44,10 +44,10 @@ struct listnode #define list_for_each_reverse(node, list) \ for (node = (list)->prev; node != (list); node = node->prev) -#define list_for_each_safe(node, next, list) \ - for (node = (list)->next, next = node->next; \ +#define list_for_each_safe(node, n, list) \ + for (node = (list)->next, n = node->next; \ node != (list); \ - node = next, next = node->next) + node = n, n = node->next) static inline void list_init(struct listnode *node) {