From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [RFC][PATCH 11/45] msi: Factor out delivery hook Date: Tue, 18 Oct 2011 14:23:29 +0200 Message-ID: <4E9D6FC1.9040504@siemens.com> References: <20111017134349.GD6406@redhat.com> <4E9C7EE3.9050603@web.de> <20111018120549.GH28776@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Avi Kivity , Marcelo Tosatti , "kvm@vger.kernel.org" , Alex Williamson , "qemu-devel@nongnu.org" To: "Michael S. Tsirkin" Return-path: Received: from david.siemens.de ([192.35.17.14]:32864 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752207Ab1JRMXg (ORCPT ); Tue, 18 Oct 2011 08:23:36 -0400 In-Reply-To: <20111018120549.GH28776@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 2011-10-18 14:05, Michael S. Tsirkin wrote: > On Mon, Oct 17, 2011 at 09:15:47PM +0200, Jan Kiszka wrote: >> On 2011-10-17 15:43, Michael S. Tsirkin wrote: >>> On Mon, Oct 17, 2011 at 11:27:45AM +0200, Jan Kiszka wrote: >>>> diff --git a/hw/msi.c b/hw/msi.c >>>> index 3c7ebc3..9055155 100644 >>>> --- a/hw/msi.c >>>> +++ b/hw/msi.c >>>> @@ -40,6 +40,14 @@ >>>> /* Flag for interrupt controller to declare MSI/MSI-X support */ >>>> bool msi_supported; >>>> >>>> +static void msi_unsupported(MSIMessage *msg) >>>> +{ >>>> + /* If we get here, the board failed to register a delivery handler. */ >>>> + abort(); >>>> +} >>>> + >>>> +void (*msi_deliver)(MSIMessage *msg) = msi_unsupported; >>>> + >>> >>> How about we set this to NULL, and check it instead of the bool >>> flag? >>> >> >> Yeah. I will introduce >> >> bool msi_supported(void) >> { >> return msi_deliver != msi_unsupported; >> } >> >> OK? >> >> Jan >> > > Looks a bit weird ... > NULL is a pretty standard value for an invalid pointer, isn't it? Save us the runtime check and is equally expressive and readable IMHO. Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux