Commit 68add7e9 authored by Mark Andrews's avatar Mark Andrews

add additional link sanity checks

parent 2384666f
Pipeline #15508 passed with stages
in 1 minute and 15 seconds
......@@ -153,29 +153,33 @@ int ident = 0;
* Doubly linked list macros.
*/
#define APPEND(list, item, link) do { \
assert(!LINKED(item, link)); \
if ((list).tail) \
(list).tail->link.next = (item); \
else \
(list).head = (item); \
(item)->link.prev = list.tail; \
(item)->link.prev = (list).tail; \
(item)->link.next = NULL; \
(list).tail = (item); \
(item)->link.linked = 1; \
(item)->link.linked = &(list); \
} while (0)
#define PREPEND(list, item, link) do { \
assert(!LINKED(item, link)); \
if ((list).head) \
(list).head->link.prev = (item); \
else \
(list).tail = (item); \
(item)->link.prev = NULL; \
(item)->link.next = list.head; \
(item)->link.next = (list).head; \
(list).head = (item); \
(item)->link.linked = 1; \
(item)->link.linked = &(list); \
} while (0)
#define INSERTBEFORE(list, before, item, link) do { \
assert(LINKED(before, link)); \
assert(!LINKED(item, link)); \
assert((before)->link.linked == &(list)); \
if ((before)->link.prev == NULL) \
PREPEND(list, item, link); \
else { \
......@@ -183,12 +187,14 @@ int ident = 0;
(before)->link.prev = (item); \
(item)->link.prev->link.next = (item); \
(item)->link.next = (before); \
(item)->link.linked = 1; \
(item)->link.linked = &(list); \
} \
} while (0)
#define INSERTAFTER(list, after, item, link) do { \
assert(LINKED(after, link)); \
assert(!LINKED(item, link)); \
assert((after)->link.linked == &(list)); \
if ((after)->link.next == NULL) \
APPEND(list, item, link); \
else { \
......@@ -196,11 +202,13 @@ int ident = 0;
(after)->link.next = (item); \
(item)->link.next->link.prev = (item); \
(item)->link.prev = (after); \
(item)->link.linked = 1; \
(item)->link.linked = &(list); \
} \
} while (0)
#define UNLINK(list, item, link) do { \
assert(LINKED(item, link)); \
assert((item)->link.linked == &(list)); \
if ((item)->link.next) \
(item)->link.next->link.prev = (item)->link.prev; \
else \
......@@ -210,7 +218,7 @@ int ident = 0;
else \
list.head = (item)->link.next; \
(item)->link.next = (item)->link.prev = NULL; \
(item)->link.linked = 0; \
(item)->link.linked = NULL; \
} while (0)
#define NEXT(item, link) (item)->link.next
......@@ -617,7 +625,7 @@ struct summary {
struct {
struct summary *prev;
struct summary *next;
int linked;
void * linked;
} link;
char zone[1024]; /* the zone's name */
char ns[1024]; /* the server's name */
......@@ -665,7 +673,7 @@ struct workitem {
struct {
struct workitem *next;
struct workitem *prev;
int linked;
void * linked;
} link, clink, plink, rlink, idlink, seqlink;
unsigned short id; /* the query id we are waiting for */
struct timeval when; /* when we will timeout */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment