[Sheepdog] [PATCH 4/4] sheep: prefix print_node_list macro's local variable

Liu Yuan namei.unix at gmail.com
Sun Sep 18 05:33:30 CEST 2011


From: Liu Yuan <tailai.ly at taobao.com>

The code are very likey to use 'name' and 'node' as its own local variable.
We need to avoid possible name collision in general macro.

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/group.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/sheep/group.c b/sheep/group.c
index cd8dd7b..bd10e39 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -99,14 +99,14 @@ struct work_confchg {
 
 #define print_node_list(node_list)				\
 ({								\
-	struct node *node;					\
-	char name[128];						\
-	list_for_each_entry(node, node_list, list) {		\
+	struct node *__node;					\
+	char __name[128];						\
+	list_for_each_entry(__node, node_list, list) {		\
 		dprintf("%c nodeid: %x, pid: %d, ip: %s\n",	\
-			is_myself(node->ent.addr, node->ent.port) ? 'l' : ' ',	\
-			node->nodeid, node->pid,		\
-			addr_to_str(name, sizeof(name),		\
-			node->ent.addr, node->ent.port));	\
+			is_myself(__node->ent.addr, __node->ent.port) ? 'l' : ' ',	\
+			__node->nodeid, __node->pid,		\
+			addr_to_str(__name, sizeof(__name),	\
+			__node->ent.addr, __node->ent.port));	\
 	}							\
 })
 
-- 
1.7.5.1




More information about the sheepdog mailing list