From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45358) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aihOl-0000Nh-7T for qemu-devel@nongnu.org; Wed, 23 Mar 2016 07:56:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aihOf-00028N-BJ for qemu-devel@nongnu.org; Wed, 23 Mar 2016 07:56:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32805) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aihOf-00027l-5Y for qemu-devel@nongnu.org; Wed, 23 Mar 2016 07:56:21 -0400 From: Markus Armbruster References: <1458717980-26686-1-git-send-email-weijg.fnst@cn.fujitsu.com> <1458717980-26686-3-git-send-email-weijg.fnst@cn.fujitsu.com> <56F24B2A.6000407@cn.fujitsu.com> Date: Wed, 23 Mar 2016 12:56:18 +0100 In-Reply-To: <56F24B2A.6000407@cn.fujitsu.com> (Cao jin's message of "Wed, 23 Mar 2016 15:52:10 +0800") Message-ID: <87vb4d9zml.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v2 2/2] hw/pci-bridge: Convert pxb initialization functions to Error List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cao jin Cc: marcel@redhat.com, Wei Jiangang , qemu-devel@nongnu.org Cao jin writes: > On 03/23/2016 03:26 PM, Wei Jiangang wrote: > >> >> -static int pxb_dev_init_common(PCIDevice *dev, bool pcie) >> +static void pxb_dev_realize_common(PCIDevice *dev, bool pcie, Error **errp) >> { >> PXBDev *pxb = convert_to_pxb(dev); >> DeviceState *ds, *bds = NULL; >> PCIBus *bus; >> const char *dev_name = NULL; >> + Error *local_err = NULL; >> > > the preferred style I think, is /*err/ Both styles are in use. I use err myself, but local_err is okay, too. >> if (pxb->numa_node != NUMA_NODE_UNASSIGNED && >> pxb->numa_node >= nb_numa_nodes) { >> - error_report("Illegal numa node %d.", pxb->numa_node); >> - return -EINVAL; >> + error_setg(errp, "Illegal numa node %d", pxb->numa_node); >> + return; > > since we have local /*err/ to avoid null /**errp/ venture, I guess it > should be used here too. No, this is just fine. If errp is null, error_setg() does nothing, which is exactly what we want. However: >> } >> >> if (dev->qdev.id && *dev->qdev.id) { >> @@ -248,7 +244,9 @@ static int pxb_dev_init_common(PCIDevice *dev, bool pcie) >> >> PCI_HOST_BRIDGE(ds)->bus = bus; >> >> - if (pxb_register_bus(dev, bus)) { >> + pxb_register_bus(dev, bus, &local_err); >> + if (local_err) { >> + error_propagate(errp, local_err); >> goto err_register_bus; >> } >> When we need to find out whether the callee set an error, we can't use (possibly null) errp, because *errp isn't safe. [...]