From owner-cvs-all@FreeBSD.ORG Wed Feb 18 06:36:35 2004 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EB4A216A4D1 for ; Wed, 18 Feb 2004 06:36:34 -0800 (PST) Received: from mail1.speakeasy.net (mail1.speakeasy.net [216.254.0.201]) by mx1.FreeBSD.org (Postfix) with ESMTP id B008D43D2F for ; Wed, 18 Feb 2004 06:36:34 -0800 (PST) (envelope-from jhb@FreeBSD.org) Received: (qmail 8433 invoked from network); 18 Feb 2004 14:36:34 -0000 Received: from dsl027-160-063.atl1.dsl.speakeasy.net (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) encrypted SMTP for ; 18 Feb 2004 14:36:34 -0000 Received: from slimer.baldwin.cx (slimer.baldwin.cx [192.168.0.16]) by server.baldwin.cx (8.12.10/8.12.10) with ESMTP id i1IEaU2K096129; Wed, 18 Feb 2004 09:36:31 -0500 (EST) (envelope-from jhb@FreeBSD.org) From: John Baldwin To: Marcel Moolenaar Date: Wed, 18 Feb 2004 08:39:09 -0500 User-Agent: KMail/1.6 References: <200401192127.i0JLRBL3041817@repoman.freebsd.org> <20040218093149.A19121@gamplex.bde.org> <20040218010034.GA64412@ns1.xcllnt.net> In-Reply-To: <20040218010034.GA64412@ns1.xcllnt.net> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200402180839.09285.jhb@FreeBSD.org> X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on server.baldwin.cx cc: src-committers@FreeBSD.org cc: Bruce Evans cc: cvs-src@FreeBSD.org cc: cvs-all@FreeBSD.org cc: Poul-Henning Kamp cc: Jun Kuriyama Subject: Re: cvs commit: src/sys/alpha/alpha support.s src/sys/i386/i386 swtch.s src/sys/kern kern_shutdown.c src/sys/sys systm.h X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Feb 2004 14:36:35 -0000 On Tuesday 17 February 2004 08:00 pm, Marcel Moolenaar wrote: > On Wed, Feb 18, 2004 at 09:43:16AM +1100, Bruce Evans wrote: > > > Alternatively, we could extend KASSERT to emit a file and line > > > number like assert(3) and instead of panic(). Seems very logical > > > to me. > > > > That feature was intentionally left out when KASSERT() was designed. > > For some reason, we decided to give the invoker of KASSERT() complete > > control over the message contents (unlike in userland where the message > > is the condition stingized and followed by __FILE__ and __LINE__. > > Presumably this was partly to permit use of existing panic messages > > verbatim. I'm not completely happy with the results of this at any > > level, especially at the source level. It requires and ugly syntax > > (another layer of parentheses around the message), and is harder to > > write and can be harder to read (writers have to think about what to > > put in the message; it's normal to invert the sense of the assertion > > and not unknown to make logic errors doing so; then readers don't > > see the original condition in the panic message). > > I tend to agree. Most of the KASSERTs I put in have the bogus message > "foo", simply because I cannot explain in a single sentence what's > wrong and I don't want to break my flow of thinking while coding to > come up with something. Hence, I either use a bogus "foo" or forget > about the KASSERT altogether. The former is less bad than the latter, > but not good at all. > I prefer to put a comprehensive comment in front of the KASSERT and > have people look there by having the KASSERT emit the file and line. > The panic message that's the result of the failed assertion can be > constant and should inform that the panic is the result of KASSERT. > Alternatively, it can print the condition that failed. > > phk's change gave me the file and line, so it gave me something I > liked. If that's going to be reverted, maybe people won't object to > having KASSERT emit the file and line and no specific panic message > at all? Use MPASS() (macros that came in with SMPng from BSD/OS). MPASS(foo) will work much like assert() in userland including file/line number info. I use it a lot for simple != NULL tests and the like. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org