Received: from eggs.gnu.org ([2001:4830:134:3::10]:34547) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a70y5-0002wL-AG for qemu-devel@nongnu.org; Thu, 10 Dec 2015 08:09:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a70y1-0004LG-46 for qemu-devel@nongnu.org; Thu, 10 Dec 2015 08:09:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47128) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a70y0-0004LA-Vd for qemu-devel@nongnu.org; Thu, 10 Dec 2015 08:09:05 -0500 From: Markus Armbruster References: <1449743372-17169-1-git-send-email-armbru@redhat.com> <1449743372-17169-11-git-send-email-armbru@redhat.com> <5669691D.8040403@gmail.com> Date: Thu, 10 Dec 2015 14:09:00 +0100 In-Reply-To: <5669691D.8040403@gmail.com> (Marcel Apfelbaum's message of "Thu, 10 Dec 2015 13:59:25 +0200") Message-ID: <87poyee9hv.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 10/12] isa: Clean up inappropriate hw_error() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marcel Apfelbaum Cc: "Michael S. Tsirkin" , Mark Cave-Ayland , qemu-devel@nongnu.org, =?utf-8?Q?Herv=C3=A9?= Poussineau , marcel@redhat.com, Aurelien Jarno , Richard Henderson Marcel Apfelbaum writes: > On 12/10/2015 12:29 PM, Markus Armbruster wrote: >> isa_bus_irqs(), isa_create() and isa_try_create() call hw_error() when >> passed a null bus. Use of hw_error() has always been questionable, >> because these are used only during machine initialization, and >> printing CPU registers isn't useful there. >> >> Since the previous commit, passing a null bus is a programming error. >> Drop the hw_error() and simply let it crash. > > Maybe we can be a little nicer add an assert ? :) assert(p) before dereferencing p only converts one kind of crash into another one. I tend to do it only when the assert(p) does double-duty as useful documentation. Or perhaps when I think there's a real risk of running into !p in an environment where core dumps are off[*] and reproducing the failure with a debugger attached could be hard. To use these three functions, you need an ISABus *. How could you end up with a bad one? * You forget to create the ISA bus, and the compiler is too confused to notice. You'll pass an unitialized ISABus, and asserting it's not null is unlikely to help. * You create multiple ISA buses (that's the only way creating one can fail) *and* forget to check for errors. If you pull that off, I'd expect it to explode even in light testing. * Your pointer gets corrupted between correct initialization and use. Asserting it's not null is unlikely to help. [*] Switching them off on a development machine forfeits your developer's license, as far as I'm concerned :)