Binary files gnumach-1.3.99.dfsg.1_orig/ipc/.ipc_kmsg.c.swp and gnumach-1.3.99.dfsg.1/ipc/.ipc_kmsg.c.swp differ
Binary files gnumach-1.3.99.dfsg.1_orig/ipc/.ipc_kmsg.h.swp and gnumach-1.3.99.dfsg.1/ipc/.ipc_kmsg.h.swp differ
diff -Nurp gnumach-1.3.99.dfsg.1_orig/ipc/ipc_kmsg.c gnumach-1.3.99.dfsg.1/ipc/ipc_kmsg.c
--- gnumach-1.3.99.dfsg.1_orig/ipc/ipc_kmsg.c	2006-11-14 02:58:57.000000000 +0100
+++ gnumach-1.3.99.dfsg.1/ipc/ipc_kmsg.c	2007-01-29 16:12:56.000000000 +0100
@@ -117,6 +117,9 @@ ipc_kmsg_rmqueue(
 	ipc_kmsg_t next, prev;
 
 	assert(queue->ikmq_base != IKM_NULL);
+	assert(queue->ikmq_base != IKM_BOGUS);
+	assert(kmsg != IKM_NULL);
+	assert(kmsg != IKM_BOGUS);
 
 	next = kmsg->ikm_next;
 	prev = kmsg->ikm_prev;
@@ -127,15 +130,20 @@ ipc_kmsg_rmqueue(
 
 		queue->ikmq_base = IKM_NULL;
 	} else {
+		assert(next != IKM_BOGUS);
+		assert(next != IKM_NULL);
+		assert(prev != IKM_BOGUS);
+		assert(prev != IKM_NULL);
+
 		if (queue->ikmq_base == kmsg)
 			queue->ikmq_base = next;
 
 		next->ikm_prev = prev;
 		prev->ikm_next = next;
 	}
-	/* XXX Temporary debug logic */
-	kmsg->ikm_next = IKM_BOGUS;
-	kmsg->ikm_prev = IKM_BOGUS;
+
+	/* For debugging */
+	ikm_link_init(kmsg);
 }
 
 /*
@@ -153,6 +161,9 @@ ipc_kmsg_queue_next(
 	ipc_kmsg_t next;
 
 	assert(queue->ikmq_base != IKM_NULL);
+	assert(queue->ikmq_base != IKM_BOGUS);
+	assert(kmsg != IKM_NULL);
+	assert(kmsg != IKM_BOGUS);
 
 	next = kmsg->ikm_next;
 	if (queue->ikmq_base == next)
diff -Nurp gnumach-1.3.99.dfsg.1_orig/ipc/ipc_kmsg.h gnumach-1.3.99.dfsg.1/ipc/ipc_kmsg.h
--- gnumach-1.3.99.dfsg.1_orig/ipc/ipc_kmsg.h	2006-10-15 19:39:24.000000000 +0200
+++ gnumach-1.3.99.dfsg.1/ipc/ipc_kmsg.h	2007-01-29 16:12:56.000000000 +0100
@@ -70,10 +70,20 @@ typedef struct ipc_kmsg {
 #define	ikm_less_overhead(size)	((mach_msg_size_t)((size) - IKM_OVERHEAD))
 
 /*
- * XXX	For debugging.
+ * For debugging.
  */
 #define IKM_BOGUS		((ipc_kmsg_t) 0xffffff10)
 
+#ifndef NDEBUG
+#define ikm_link_init(kmsg)						\
+MACRO_BEGIN								\
+  	(kmsg)->ikm_next = IKM_BOGUS;					\
+  	(kmsg)->ikm_prev = IKM_BOGUS;					\
+MACRO_END
+#else /* NDEBUG */
+#define ikm_link_init(kmsg)
+#endif /* NDEBUG */
+
 /*
  *	We keep a per-processor cache of kernel message buffers.
  *	The cache saves the overhead/locking of using kalloc/kfree.
@@ -106,6 +116,8 @@ MACRO_END
 MACRO_BEGIN								\
 	(kmsg)->ikm_size = (size);					\
 	(kmsg)->ikm_marequest = IMAR_NULL;				\
+	/* For debugging */						\
+	ikm_link_init(kmsg);						\
 MACRO_END
 
 #define	ikm_check_initialized(kmsg, size)				\
@@ -180,6 +192,9 @@ extern ipc_kmsg_t ipc_kmsg_queue_next(
 MACRO_BEGIN								\
 	register ipc_kmsg_t _next;					\
 									\
+	assert(kmsg != IKM_BOGUS);					\
+	assert(kmsg != IKM_NULL);					\
+									\
 	assert((queue)->ikmq_base == (kmsg));				\
 									\
 	_next = (kmsg)->ikm_next;					\
@@ -189,19 +204,28 @@ MACRO_BEGIN								\
 	} else {							\
 		register ipc_kmsg_t _prev = (kmsg)->ikm_prev;		\
 									\
+		assert(_next != IKM_BOGUS);				\
+		assert(_next != IKM_NULL);				\
+		assert(_prev != IKM_BOGUS);				\
+		assert(_prev != IKM_NULL);				\
+									\
 		(queue)->ikmq_base = _next;				\
 		_next->ikm_prev = _prev;				\
 		_prev->ikm_next = _next;				\
 	}								\
-  	/* XXX Debug paranoia */					\
-  	kmsg->ikm_next = IKM_BOGUS;					\
-  	kmsg->ikm_prev = IKM_BOGUS;					\
+									\
+	/* For debugging */						\
+	ikm_link_init(kmsg);						\
 MACRO_END
 
 #define	ipc_kmsg_enqueue_macro(queue, kmsg)				\
 MACRO_BEGIN								\
 	register ipc_kmsg_t _first = (queue)->ikmq_base;		\
 									\
+	assert(_first != IKM_BOGUS);					\
+	assert(kmsg != IKM_BOGUS);					\
+	assert(kmsg != IKM_NULL);					\
+									\
 	if (_first == IKM_NULL) {					\
 		(queue)->ikmq_base = (kmsg);				\
 		(kmsg)->ikm_next = (kmsg);				\
@@ -209,6 +233,9 @@ MACRO_BEGIN								\
 	} else {							\
 		register ipc_kmsg_t _last = _first->ikm_prev;		\
 									\
+		assert(_first->ikm_next != IKM_BOGUS);			\
+		assert(_first->ikm_prev != IKM_BOGUS);			\
+									\
 		(kmsg)->ikm_next = _first;				\
 		(kmsg)->ikm_prev = _last;				\
 		_first->ikm_prev = (kmsg);				\
