From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NrF0H-0004yz-Sq for qemu-devel@nongnu.org; Mon, 15 Mar 2010 14:27:01 -0400 Received: from [199.232.76.173] (port=50448 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NrF0H-0004yS-Hk for qemu-devel@nongnu.org; Mon, 15 Mar 2010 14:27:01 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NrF0G-00028A-SR for qemu-devel@nongnu.org; Mon, 15 Mar 2010 14:27:01 -0400 Received: from mail-px0-f176.google.com ([209.85.216.176]:44802) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NrF0G-000284-JF for qemu-devel@nongnu.org; Mon, 15 Mar 2010 14:27:00 -0400 Received: by pxi6 with SMTP id 6so1910920pxi.18 for ; Mon, 15 Mar 2010 11:26:59 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <4B9E7A29.1020902@redhat.com> References: <4B9E7A29.1020902@redhat.com> Date: Mon, 15 Mar 2010 20:26:46 +0200 Message-ID: From: Blue Swirl Content-Type: text/plain; charset=UTF-8 Subject: [Qemu-devel] Re: [PATCH, RFC] Replace assert(0) with abort() or cpu_abort() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Markus Armbruster , qemu-devel On 3/15/10, Paolo Bonzini wrote: > > > > > > > > > > > I sympathize with the general idea, but I don't like dead code > > > > > > > after abort(). What about cleaning that up? > > > > > > > > Good idea, but it should be a separate patch. This patch is "safe", > > whereas the cleanup patch could cause problems if it's not done > > carefully. > > > > This patch is "safe", however I'd consider not changing assert(0)->abort() > if there is code after the assert that looks like an attempt at recovering. > Example: > > if (!p) { > printf ("the impossible has happened!"); > assert (0); > } > > return p->q; > > should be changed to abort, while > > if (!p) { > printf ("the impossible has happened!"); > assert (0); > return 0; > } > > return p->q; > > should not. Why not? According to manual page, assert(x) is equal to if (!x) abort(). As I mentioned earlier, system emulators don't handle SIGABRT and for user emulators the level of bugginess remains constant (or rather, it no longer depends on NDEBUG). Therefore the recovery code will never be executed.