Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Fri, 20 Sep 2002 20:24:20 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Fri, 20 Sep 2002 20:24:20 -0400 Received: from p50887F27.dip.t-dialin.net ([80.136.127.39]:32446 "EHLO hawkeye.luckynet.adm") by vger.kernel.org with ESMTP id ; Fri, 20 Sep 2002 20:24:19 -0400 Date: Fri, 20 Sep 2002 18:29:56 -0600 (MDT) From: Thunder from the hill X-X-Sender: thunder@hawkeye.luckynet.adm To: Zach Brown cc: Linux Kernel Mailing List Subject: Re: [PATCH] list_head debugging? In-Reply-To: <20020920165304.A4588@bitchcake.off.net> Message-ID: X-Location: Dorndorf/Steudnitz; Germany MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1263 Lines: 45 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/