Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Jul 1996 15:43:16 +0200
From:      Poul-Henning Kamp <phk@critter.tfs.com>
To:        Michael Hancock <michaelh@cet.co.jp>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: kernel assertions 
Message-ID:  <532.838647796@critter.tfs.com>
In-Reply-To: Your message of "Mon, 29 Jul 1996 20:59:27 %2B0900." <Pine.SV4.3.93.960729203716.28611B-100000@parkplace.cet.co.jp> 

next in thread | previous in thread | raw e-mail | index | archive | help
>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 <sys/cdefs.h> 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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?532.838647796>