Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nte4Z-0003WE-T4 for qemu-devel@nongnu.org; Mon, 22 Mar 2010 05:37:23 -0400 Received: from [199.232.76.173] (port=41473 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nte4Z-0003Vs-9h for qemu-devel@nongnu.org; Mon, 22 Mar 2010 05:37:23 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nte4X-00071G-M7 for qemu-devel@nongnu.org; Mon, 22 Mar 2010 05:37:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9346) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nte4X-000718-9m for qemu-devel@nongnu.org; Mon, 22 Mar 2010 05:37:21 -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: Mon, 22 Mar 2010 10:37:17 +0100 In-Reply-To: (Blue Swirl's message of "Thu, 18 Mar 2010 21:32:24 +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/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. > > If you know for sure that this line can't be reached, why bother with > any code at all? > >> Do you still want me to use abort() here? > > abort() or nothing at all, as you wish. Okay, nothing it is. >> By the way, a quick grep shows >50 uses of assert(0). > > Not anymore since 43dc2a645e00e6761a741e3d16c27c5b5a373b66. I doubt the wisdom of such a wholesale conversion, but I it's hardly worth arguing now.