Re: [PATCH] list_head debugging?

Thunder from the hill (thunder@lightweight.ods.org)
Fri, 20 Sep 2002 18:29:56 -0600 (MDT)


Hi,

Before Fri, 20 Sep 2002, Zach Brown wrote:

--- ./list.h.debug Thu Sep 19 15:58:47 2002
+++ ./list.h Fri Sep 20 13:43:21 2002
@@ -21,6 +21,25 @@

typedef struct list_head list_t;

+#define LIST_HEAD_DEBUGGING
+#ifdef LIST_HEAD_DEBUGGING
+
+static inline void __list_valid(struct list_head *list)
+{
+ BUG_ON(list == NULL);
+ BUG_ON(list->next == NULL);
+ BUG_ON(list->prev == NULL);
+ BUG_ON(list->next->prev != list);
+ BUG_ON(list->prev->next != list);
+ BUG_ON((list->next == list) && (list->prev != list));
+ BUG_ON((list->prev == list) && (list->next != list));
+}
+#else

It's all cool, but I'm not entirely convinced why it must be a BUG macro.
I'd rather have something said via printk here. If whatever we did was
bad, it will show up with a BUG() just too soon.

I'd describe a macro.

#define list_assert(cond) \
if (cond) printk(KERN_ERR "%s failed!\n", #cond)

Or the like. BTW, I'd define LIST_HEAD_DEBUGGING as 1.

Thunder

-- 
assert(typeof((fool)->next) == typeof(fool));	/* wrong */

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/