Subject: Re: switch to two-argument KASSERT?
To: None <tech-kern@netbsd.org>
From: Matt Thomas <matt@3am-software.com>
List: tech-kern
Date: 01/14/2004 00:30:10
On Jan 13, 2004, at 10:13 PM, Daniel Carosone wrote:

> On Tue, Jan 13, 2004 at 11:04:58PM -0600, David Young wrote:
>> I believe that FreeBSD defines the macro like this,
>>
>> #define KASSERT(cond, complaint) if (!(cond)) panic complaint

It's missing a wrapping do { } while (0)

> As already noted elsewhere, I support this - but I'd suggest we use
> something slightly different for the macro definition.

I'd suggest having a KASSERT2(cond, complaint) and then KASSERT could be
#define KASSERT(cond)  KASSERT2(cond, ("assertion failure: " #cond))


> Specifically, I'd like to still see the asserted condition embedded in
> the message. It saves having to dive into the source to find the
> message string, rather than dive in looking for the assertion test as
> now, just to get a basic interpretation. It also helps the message
> text be simpler and more useful it supplements rather than
> "translates" the test - otherwise you can wind up with two
> obviously-equivalent forms of the same obscure condition.

I disagree.  I often want to format the string quite different than
the condition string to more informative.

> Assertion messages are for a developer audience (and only enabled if
> DIAGNOSTIC, right?) so they don't need to be too user-friendly by
> hiding the condition code.

But they shouldn't complete obtuse either.
-- 
Matt Thomas                     email: matt@3am-software.com
3am Software Foundry              www: http://3am-software.com/bio/matt/
Cupertino, CA              disclaimer: I avow all knowledge of this 
message.