Browse Source

list: rename debug_list to list_debug, use list_check_node in list_del

When CCAN_LIST_DEBUG was defined, we were previously calling
list_check() in list_del instead of list_check_node(), which caused a
warning.

We also should stick within the "list_" prefix namespace, so rename
"debug_list" to "list_debug".
Rusty Russell 15 years ago
parent
commit
f940ee9ccd
1 changed files with 10 additions and 8 deletions
  1. 10 8
      ccan/list/list.h

+ 10 - 8
ccan/list/list.h

@@ -86,9 +86,11 @@ struct list_node *list_check_node(const struct list_node *n,
 				  const char *abortstr);
 				  const char *abortstr);
 
 
 #ifdef CCAN_LIST_DEBUG
 #ifdef CCAN_LIST_DEBUG
-#define debug_list(h) list_check((h), __func__)
+#define list_debug(h) list_check((h), __func__)
+#define list_debug_node(n) list_check_node((n), __func__)
 #else
 #else
-#define debug_list(h) (h)
+#define list_debug(h) (h)
+#define list_debug_node(n) (n)
 #endif
 #endif
 
 
 /**
 /**
@@ -139,7 +141,7 @@ static inline void list_add(struct list_head *h, struct list_node *n)
 	n->prev = &h->n;
 	n->prev = &h->n;
 	h->n.next->prev = n;
 	h->n.next->prev = n;
 	h->n.next = n;
 	h->n.next = n;
-	(void)debug_list(h);
+	(void)list_debug(h);
 }
 }
 
 
 /**
 /**
@@ -158,7 +160,7 @@ static inline void list_add_tail(struct list_head *h, struct list_node *n)
 	n->prev = h->n.prev;
 	n->prev = h->n.prev;
 	h->n.prev->next = n;
 	h->n.prev->next = n;
 	h->n.prev = n;
 	h->n.prev = n;
-	(void)debug_list(h);
+	(void)list_debug(h);
 }
 }
 
 
 /**
 /**
@@ -171,9 +173,9 @@ static inline void list_add_tail(struct list_head *h, struct list_node *n)
  */
  */
 static inline void list_del(struct list_node *n)
 static inline void list_del(struct list_node *n)
 {
 {
+	(void)list_debug_node(n);
 	n->next->prev = n->prev;
 	n->next->prev = n->prev;
 	n->prev->next = n->next;
 	n->prev->next = n->next;
-	(void)debug_list(n->next);
 #ifdef CCAN_LIST_DEBUG
 #ifdef CCAN_LIST_DEBUG
 	/* Catch use-after-del. */
 	/* Catch use-after-del. */
 	n->next = n->prev = NULL;
 	n->next = n->prev = NULL;
@@ -191,7 +193,7 @@ static inline void list_del(struct list_node *n)
  */
  */
 static inline bool list_empty(const struct list_head *h)
 static inline bool list_empty(const struct list_head *h)
 {
 {
-	(void)debug_list(h);
+	(void)list_debug(h);
 	return h->n.next == &h->n;
 	return h->n.next == &h->n;
 }
 }
 
 
@@ -254,7 +256,7 @@ static inline bool list_empty(const struct list_head *h)
  *		printf("Name: %s\n", child->name);
  *		printf("Name: %s\n", child->name);
  */
  */
 #define list_for_each(h, i, member)					\
 #define list_for_each(h, i, member)					\
-	for (i = container_of_var(debug_list(h)->n.next, i, member);	\
+	for (i = container_of_var(list_debug(h)->n.next, i, member);	\
 	     &i->member != &(h)->n;					\
 	     &i->member != &(h)->n;					\
 	     i = container_of_var(i->member.next, i, member))
 	     i = container_of_var(i->member.next, i, member))
 
 
@@ -277,7 +279,7 @@ static inline bool list_empty(const struct list_head *h)
  *	}
  *	}
  */
  */
 #define list_for_each_safe(h, i, nxt, member)				\
 #define list_for_each_safe(h, i, nxt, member)				\
-	for (i = container_of_var(debug_list(h)->n.next, i, member),	\
+	for (i = container_of_var(list_debug(h)->n.next, i, member),	\
 		nxt = container_of_var(i->member.next, i, member);	\
 		nxt = container_of_var(i->member.next, i, member);	\
 	     &i->member != &(h)->n;					\
 	     &i->member != &(h)->n;					\
 	     i = nxt, nxt = container_of_var(i->member.next, i, member))
 	     i = nxt, nxt = container_of_var(i->member.next, i, member))