Re: [PATCH] Make

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Dave Jones
Date: Tuesday, May 20, 2008 - 8:20 am

On Tue, May 20, 2008 at 07:54:10AM -0700, Linus Torvalds wrote:

 > I think Arjan meant like
 > 
 > 	WARN(next->prev != prev,
 > 		"list_add corruption. next->prev should be "
 > 		"prev (%p), but was %p. (next=%p).\n",
 > 		prev, next->prev, next);
 > 
 > without any "if()" statement at all.

Nice. I like that.


diff --git a/lib/list_debug.c b/lib/list_debug.c
index 4350ba9..311ffab 100644
--- a/lib/list_debug.c
+++ b/lib/list_debug.c
@@ -20,18 +20,14 @@ void __list_add(struct list_head *new,
 			      struct list_head *prev,
 			      struct list_head *next)
 {
-	if (unlikely(next->prev != prev)) {
-		printk(KERN_ERR "list_add corruption. next->prev should be "
-			"prev (%p), but was %p. (next=%p).\n",
-			prev, next->prev, next);
-		BUG();
-	}
-	if (unlikely(prev->next != next)) {
-		printk(KERN_ERR "list_add corruption. prev->next should be "
-			"next (%p), but was %p. (prev=%p).\n",
-			next, prev->next, prev);
-		BUG();
-	}
+	WARN(next->prev != prev,
+		"list_add corruption. next->prev should be "
+		"prev (%p), but was %p. (next=%p).\n",
+		prev, next->prev, next);
+	WARN(prev->next != next,
+		"list_add corruption. prev->next should be "
+		"next (%p), but was %p. (prev=%p).\n",
+		next, prev->next, prev);
 	next->prev = new;
 	new->next = next;
 	new->prev = prev;
@@ -61,16 +57,12 @@ EXPORT_SYMBOL(list_add);
  */
 void list_del(struct list_head *entry)
 {
-	if (unlikely(entry->prev->next != entry)) {
-		printk(KERN_ERR "list_del corruption. prev->next should be %p, "
-				"but was %p\n", entry, entry->prev->next);
-		BUG();
-	}
-	if (unlikely(entry->next->prev != entry)) {
-		printk(KERN_ERR "list_del corruption. next->prev should be %p, "
-				"but was %p\n", entry, entry->next->prev);
-		BUG();
-	}
+	WARN(entry->prev->next != entry,
+		"list_del corruption. prev->next should be %p, "
+		"but was %p\n", entry, entry->prev->next);
+	WARN(entry->next->prev != entry,
+		"list_del corruption. next->prev should be %p, "
+		"but was %p\n", entry, entry->next->prev);
 	__list_del(entry->prev, entry->next);
 	entry->next = LIST_POISON1;
 	entry->prev = LIST_POISON2;

-- 
http://www.codemonkey.org.uk
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH] Extend list debugging to cover hlists, Arjan van de Ven, (Thu May 1, 1:32 pm)
[PATCH] Extend list debugging to cover hlists, Matthew Wilcox, (Fri May 2, 11:27 am)
Re: [PATCH] Extend list debugging to cover hlists, Matthew Wilcox, (Fri May 2, 11:49 am)
Re: [PATCH] Extend list debugging to cover hlists, Dave Jones, (Fri May 2, 12:05 pm)
Re: [PATCH] Extend list debugging to cover hlists, Andrew Morton, (Fri May 2, 4:14 pm)
Re: [PATCH] Extend list debugging to cover hlists, Matthew Wilcox, (Fri May 2, 4:17 pm)
Re: [PATCH] Extend list debugging to cover hlists, Andrew Morton, (Fri May 2, 4:39 pm)
[PATCH] Make, Dave Jones, (Mon May 19, 8:24 pm)
Re: [PATCH] Make, Arjan van de Ven, (Tue May 20, 7:14 am)
Re: [PATCH] Make, Dave Jones, (Tue May 20, 7:27 am)
Re: [PATCH] Make, Linus Torvalds, (Tue May 20, 7:54 am)
Re: [PATCH] Make, Alexey Dobriyan, (Tue May 20, 8:00 am)
Re: [PATCH] Make, Linus Torvalds, (Tue May 20, 8:12 am)
Re: [PATCH] Make, Dave Jones, (Tue May 20, 8:20 am)
Re: [PATCH] Make, Dave Jones, (Tue May 20, 8:22 am)
Re: [PATCH] Make, Arjan van de Ven, (Tue May 20, 9:15 am)
Re: [PATCH] Make (LIST_DEBUG WARN not BUG), Alexey Dobriyan, (Tue May 20, 2:52 pm)