From owner-freebsd-hackers Mon Jul 29 06:43:05 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id GAA25657 for hackers-outgoing; Mon, 29 Jul 1996 06:43:05 -0700 (PDT) Received: from critter.tfs.com ([140.145.230.177]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id GAA25649; Mon, 29 Jul 1996 06:43:00 -0700 (PDT) Received: from critter.tfs.com (localhost.tfs.com [127.0.0.1]) by critter.tfs.com (8.7.5/8.7.3) with ESMTP id PAA00534; Mon, 29 Jul 1996 15:43:16 +0200 (MET DST) To: Michael Hancock cc: hackers@FreeBSD.ORG Subject: Re: kernel assertions In-reply-to: Your message of "Mon, 29 Jul 1996 20:59:27 +0900." Date: Mon, 29 Jul 1996 15:43:16 +0200 Message-ID: <532.838647796@critter.tfs.com> From: Poul-Henning Kamp Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >Any comments on introducing an assertion macro for kernel code that panics >if the expression is false and does nothing otherwise. It would also be >very cool to preprocess it out with something like a -NDEBUG flag. It >could be called KASSERT or KERN_ASSERT. I like this idea. How about: in we put: #if defined(DIAGNOSTIC) || defined(WITH_ASSERTS) #define ASSERT(cond, expl) if (cond) panic expl ; else ; #else #define ASSERT(cond, expl) /* nothing */ #endif In our code: void foo(char *buf, int i { ASSERT(buf,("foo(%p, %d): buf is zero",buf,i)); ... } -- Poul-Henning Kamp | phk@FreeBSD.ORG FreeBSD Core-team. http://www.freebsd.org/~phk | phk@login.dknet.dk Private mailbox. whois: [PHK] | phk@ref.tfs.com TRW Financial Systems, Inc. Future will arrive by its own means, progress not so.