list: add parens to gaurd macro args in LIST_INIT
authorCody P Schafer <dev@codyps.com>
Tue, 31 May 2016 18:24:46 +0000 (14:24 -0400)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 2 Jun 2016 01:58:35 +0000 (11:28 +0930)
When other macros are emitting LIST_INIT expansions, `name` can get a
bit complicated.

Signed-off-by: Cody P Schafer <dev@codyps.com>
ccan/list/list.h

index 4faf5798829a0b9427e3b38b02aabc00f551bf99..0800a0fa144f20f1ab0985b5b3dd369fe9f39eef 100644 (file)
@@ -111,7 +111,7 @@ struct list_node *list_check_node(const struct list_node *n,
  * Example:
  *     static struct list_head my_list = LIST_HEAD_INIT(my_list);
  */
-#define LIST_HEAD_INIT(name) { { &name.n, &name.n } }
+#define LIST_HEAD_INIT(name) { { &(name).n, &(name).n } }
 
 /**
  * LIST_HEAD - define and initialize an empty list_head