summaryrefslogtreecommitdiffstats
path: root/src/include/gpxe/list.h
diff options
context:
space:
mode:
authorMichael Brown2007-09-17 19:38:04 +0200
committerMichael Brown2007-09-21 02:13:22 +0200
commitf09173326c3ec710764769e782859dba79afe945 (patch)
tree850f31e896ef423d4d2577ba8a4d20f70888f6cb /src/include/gpxe/list.h
parentBugfix: DHCP message type should be a one-byte option... (d'oh) (diff)
downloadipxe-f09173326c3ec710764769e782859dba79afe945.tar.gz
ipxe-f09173326c3ec710764769e782859dba79afe945.tar.xz
ipxe-f09173326c3ec710764769e782859dba79afe945.zip
Moved iobuf.h assertions outside the static inline functions, so that
the assert message's file and line number gives some clue as to the real location of the problem. Added similar assertions to list.h.
Diffstat (limited to 'src/include/gpxe/list.h')
-rw-r--r--src/include/gpxe/list.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/include/gpxe/list.h b/src/include/gpxe/list.h
index 0e65901c..602382be 100644
--- a/src/include/gpxe/list.h
+++ b/src/include/gpxe/list.h
@@ -10,6 +10,7 @@
*/
#include <stddef.h>
+#include <assert.h>
/*
* Simple doubly linked list implementation.
@@ -62,6 +63,11 @@ static inline void __list_add ( struct list_head *new,
static inline void list_add ( struct list_head *new, struct list_head *head ) {
__list_add ( new, head, head->next );
}
+#define list_add( new, head ) do { \
+ assert ( (head)->next->prev == (head) ); \
+ assert ( (head)->prev->next == (head) ); \
+ list_add ( (new), (head) ); \
+ } while ( 0 )
/**
* Add a new entry to the tail of a list
@@ -76,6 +82,11 @@ static inline void list_add_tail ( struct list_head *new,
struct list_head *head ) {
__list_add ( new, head->prev, head );
}
+#define list_add_tail( new, head ) do { \
+ assert ( (head)->next->prev == (head) ); \
+ assert ( (head)->prev->next == (head) ); \
+ list_add_tail ( (new), (head) ); \
+ } while ( 0 )
/*
* Delete a list entry by making the prev/next entries
@@ -101,6 +112,13 @@ static inline void __list_del ( struct list_head * prev,
static inline void list_del ( struct list_head *entry ) {
__list_del ( entry->prev, entry->next );
}
+#define list_del( entry ) do { \
+ assert ( (entry)->prev != NULL ); \
+ assert ( (entry)->next != NULL ); \
+ assert ( (entry)->next->prev == (entry) ); \
+ assert ( (entry)->prev->next == (entry) ); \
+ list_del ( (entry) ); \
+ } while ( 0 )
/**
* Test whether a list is empty