Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NsKsf-0007Th-K0 for qemu-devel@nongnu.org; Thu, 18 Mar 2010 14:55:41 -0400 Received: from [199.232.76.173] (port=37535 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NsKse-0007T5-UO for qemu-devel@nongnu.org; Thu, 18 Mar 2010 14:55:40 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NsKsd-0005OB-JG for qemu-devel@nongnu.org; Thu, 18 Mar 2010 14:55:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9159) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NsKsd-0005O7-6c for qemu-devel@nongnu.org; Thu, 18 Mar 2010 14:55:39 -0400 From: Markus Armbruster Subject: Re: [Qemu-devel] [PATCH 5/6] error: Link qemu-img, qemu-nbd, qemu-io with qemu-error.o References: <1268848614-6844-1-git-send-email-armbru@redhat.com> <1268848614-6844-6-git-send-email-armbru@redhat.com> Date: Thu, 18 Mar 2010 19:55:34 +0100 In-Reply-To: (Blue Swirl's message of "Thu, 18 Mar 2010 20:20:49 +0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: qemu-devel@nongnu.org, lcapitulino@redhat.com Blue Swirl writes: > On 3/18/10, Markus Armbruster wrote: >> Blue Swirl writes: >> >> > On 3/17/10, Markus Armbruster wrote: >> >> Blue Swirl writes: >> >> >> >> > On 3/17/10, Markus Armbruster wrote: >> >> [...] >> >> >> >> +void monitor_set_error(Monitor *mon, QError *qerror) >> >> >> +{ >> >> >> + assert(0); >> >> > >> >> > Please use abort(). >> >> >> >> >> >> Why? >> > >> > Because assert(0) does not abort when compiled with -DNDEBUG. >> >> >> Why is that a problem? And why isn't it a problem for the 300+ other >> assertions in the code? > > We didn't support -DNDEBUG build until recently. Therefore it's safe > to assume that also on production builds assert(0) was equal to > abort(). If the default for production builds changes to -DNDEBUG, we > want to retain the same abort() behaviour. > > The assertions which perform debugging checks aren't a problem. But > assert(0) clearly isn't a debugging check, if you ever reach this line > of code, it's abort() time. I *know* that this line cannot be reached. That's why I asserted it cannot be reached. If you want "this can't ever happen" assertions to be checked, then you shouldn't define NDEBUG. Do you still want me to use abort() here? By the way, a quick grep shows >50 uses of assert(0).