From nobody Sat Feb 7 04:31:59 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504969814211298.8179132630412; Sat, 9 Sep 2017 08:10:14 -0700 (PDT) Received: from localhost ([::1]:49888 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqhOf-00024r-D8 for importer@patchew.org; Sat, 09 Sep 2017 11:10:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqhLG-00082t-Ou for qemu-devel@nongnu.org; Sat, 09 Sep 2017 11:06:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqhLC-0006OS-6q for qemu-devel@nongnu.org; Sat, 09 Sep 2017 11:06:42 -0400 Received: from 9.mo177.mail-out.ovh.net ([46.105.72.238]:35964) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dqhLC-0006MW-0m for qemu-devel@nongnu.org; Sat, 09 Sep 2017 11:06:38 -0400 Received: from player714.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo177.mail-out.ovh.net (Postfix) with ESMTP id 677EB76A4D for ; Sat, 9 Sep 2017 17:06:36 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player714.ha.ovh.net (Postfix) with ESMTPA id 311B03C0073; Sat, 9 Sep 2017 17:06:34 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Sat, 09 Sep 2017 17:06:33 +0200 Message-ID: <150496959359.9654.1986960584525021648.stgit@bahia> In-Reply-To: <150496954641.9654.1998704077006846521.stgit@bahia> References: <150496954641.9654.1998704077006846521.stgit@bahia> User-Agent: StGit/0.17.1-46-g6855-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 251075682732513619 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelledrfeeigdekjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.72.238 Subject: [Qemu-devel] [PATCH 5/5] spapr_pci: handle FDT creation errors with _FDT() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 libfdt failures when creating the FDT should cause QEMU to terminate. Let's use the _FDT() macro which does just that instead of propagating the error to the caller. spapr_populate_pci_child_dt() no longer needs to return a value in this case. Note that, on the way, this get rids of the following nonsensical lines: g_assert(!ret); if (ret) { Signed-off-by: Greg Kurz --- hw/ppc/spapr_pci.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index abb9f05e7b75..75cd9392233e 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1204,12 +1204,12 @@ static gchar *pci_get_node_name(PCIDevice *dev) static uint32_t spapr_phb_get_pci_drc_index(sPAPRPHBState *phb, PCIDevice *pdev); =20 -static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offs= et, +static void spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int off= set, sPAPRPHBState *sphb) { ResourceProps rp; bool is_bridge =3D false; - int pci_status, err; + int pci_status; char *buf =3D NULL; uint32_t drc_index =3D spapr_phb_get_pci_drc_index(sphb, dev); uint32_t ccode =3D pci_default_read_config(dev, PCI_CLASS_PROG, 3); @@ -1274,11 +1274,8 @@ static int spapr_populate_pci_child_dt(PCIDevice *de= v, void *fdt, int offset, ccode & 0xff))); =20 buf =3D spapr_phb_get_loc_code(sphb, dev); - err =3D fdt_setprop_string(fdt, offset, "ibm,loc-code", buf); + _FDT(fdt_setprop_string(fdt, offset, "ibm,loc-code", buf)); g_free(buf); - if (err < 0) { - return err; - } =20 if (drc_index) { _FDT(fdt_setprop_cell(fdt, offset, "ibm,my-drc-index", drc_index)); @@ -1306,27 +1303,21 @@ static int spapr_populate_pci_child_dt(PCIDevice *d= ev, void *fdt, int offset, if (sphb->pcie_ecs && pci_is_express(dev)) { _FDT(fdt_setprop_cell(fdt, offset, "ibm,pci-config-space-type", 0x= 1)); } - - return 0; } =20 /* create OF node for pci device and required OF DT properties */ static int spapr_create_pci_child_dt(sPAPRPHBState *phb, PCIDevice *dev, void *fdt, int node_offset) { - int offset, ret; + int offset; gchar *nodename; =20 nodename =3D pci_get_node_name(dev); - offset =3D fdt_add_subnode(fdt, node_offset, nodename); + _FDT(offset =3D fdt_add_subnode(fdt, node_offset, nodename)); g_free(nodename); =20 - ret =3D spapr_populate_pci_child_dt(dev, fdt, offset, phb); + spapr_populate_pci_child_dt(dev, fdt, offset, phb); =20 - g_assert(!ret); - if (ret) { - return 0; - } return offset; } =20 @@ -1416,10 +1407,6 @@ static void spapr_pci_plug(HotplugHandler *plug_hand= ler, =20 fdt =3D create_device_tree(&fdt_size); fdt_start_offset =3D spapr_create_pci_child_dt(phb, pdev, fdt, 0); - if (!fdt_start_offset) { - error_setg(&local_err, "Failed to create pci child device tree nod= e"); - goto out; - } =20 spapr_drc_attach(drc, DEVICE(pdev), fdt, fdt_start_offset, &local_err); if (local_err) { @@ -2114,11 +2101,8 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb, =20 /* Start populating the FDT */ nodename =3D g_strdup_printf("pci@%" PRIx64, phb->buid); - bus_off =3D fdt_add_subnode(fdt, 0, nodename); + _FDT(bus_off =3D fdt_add_subnode(fdt, 0, nodename)); g_free(nodename); - if (bus_off < 0) { - return bus_off; - } =20 /* Write PHB properties */ _FDT(fdt_setprop_string(fdt, bus_off, "device_type", "pci"));