net: ipv4 and ipv6: Convert printk(KERN_DEBUG to pr_debug
[linux-2.6/libata-dev.git] / lib / list_debug.c
blob982b850d4e7aa2aa4b60bd7b08226c07a3c7fca1
1 /*
2 * Copyright 2006, Red Hat, Inc., Dave Jones
3 * Released under the General Public License (GPL).
5 * This file contains the linked list implementations for
6 * DEBUG_LIST.
7 */
9 #include <linux/export.h>
10 #include <linux/list.h>
11 #include <linux/bug.h>
12 #include <linux/kernel.h>
15 * Insert a new entry between two known consecutive entries.
17 * This is only for internal list manipulation where we know
18 * the prev/next entries already!
21 void __list_add(struct list_head *new,
22 struct list_head *prev,
23 struct list_head *next)
25 WARN(next->prev != prev,
26 "list_add corruption. next->prev should be "
27 "prev (%p), but was %p. (next=%p).\n",
28 prev, next->prev, next);
29 WARN(prev->next != next,
30 "list_add corruption. prev->next should be "
31 "next (%p), but was %p. (prev=%p).\n",
32 next, prev->next, prev);
33 next->prev = new;
34 new->next = next;
35 new->prev = prev;
36 prev->next = new;
38 EXPORT_SYMBOL(__list_add);
40 void __list_del_entry(struct list_head *entry)
42 struct list_head *prev, *next;
44 prev = entry->prev;
45 next = entry->next;
47 if (WARN(next == LIST_POISON1,
48 "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
49 entry, LIST_POISON1) ||
50 WARN(prev == LIST_POISON2,
51 "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
52 entry, LIST_POISON2) ||
53 WARN(prev->next != entry,
54 "list_del corruption. prev->next should be %p, "
55 "but was %p\n", entry, prev->next) ||
56 WARN(next->prev != entry,
57 "list_del corruption. next->prev should be %p, "
58 "but was %p\n", entry, next->prev))
59 return;
61 __list_del(prev, next);
63 EXPORT_SYMBOL(__list_del_entry);
65 /**
66 * list_del - deletes entry from list.
67 * @entry: the element to delete from the list.
68 * Note: list_empty on entry does not return true after this, the entry is
69 * in an undefined state.
71 void list_del(struct list_head *entry)
73 __list_del_entry(entry);
74 entry->next = LIST_POISON1;
75 entry->prev = LIST_POISON2;
77 EXPORT_SYMBOL(list_del);