From nobody Mon May 6 13:02:37 2024 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 1504969789453712.6084770828332; Sat, 9 Sep 2017 08:09:49 -0700 (PDT) Received: from localhost ([::1]:49887 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqhOG-0001nw-HP for importer@patchew.org; Sat, 09 Sep 2017 11:09:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50547) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqhKh-0007cy-5q for qemu-devel@nongnu.org; Sat, 09 Sep 2017 11:06:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqhKg-0005ut-Ce for qemu-devel@nongnu.org; Sat, 09 Sep 2017 11:06:07 -0400 Received: from 6.mo177.mail-out.ovh.net ([46.105.51.249]:49645) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dqhKg-0005td-5v for qemu-devel@nongnu.org; Sat, 09 Sep 2017 11:06:06 -0400 Received: from player714.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo177.mail-out.ovh.net (Postfix) with ESMTP id 3297274BCE for ; Sat, 9 Sep 2017 17:06:05 +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 F13E23C0073; Sat, 9 Sep 2017 17:06:02 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Sat, 09 Sep 2017 17:06:02 +0200 Message-ID: <150496956243.9654.5568893219758334324.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: 242349956608137555 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.51.249 Subject: [Qemu-devel] [PATCH 1/5] spapr_pci: drop useless check in spapr_phb_vfio_get_loc_code() 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 g_strdup_printf() either returns a non-null pointer, either aborts if it failed to allocate memory. Signed-off-by: Greg Kurz Acked-by: Philippe Mathieu-Daud=C3=A9 --- hw/ppc/spapr_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index d7880f257aa1..ef982f2ef370 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -766,7 +766,7 @@ static char *spapr_phb_vfio_get_loc_code(sPAPRPHBState = *sphb, PCIDevice *pdev) /* Construct the path of the file that will give us the DT location */ path =3D g_strdup_printf("/sys/bus/pci/devices/%s/devspec", host); g_free(host); - if (!path || !g_file_get_contents(path, &buf, NULL, NULL)) { + if (!g_file_get_contents(path, &buf, NULL, NULL)) { goto err_out; } g_free(path); @@ -774,7 +774,7 @@ static char *spapr_phb_vfio_get_loc_code(sPAPRPHBState = *sphb, PCIDevice *pdev) /* Construct and read from host device tree the loc-code */ path =3D g_strdup_printf("/proc/device-tree%s/ibm,loc-code", buf); g_free(buf); - if (!path || !g_file_get_contents(path, &buf, NULL, NULL)) { + if (!g_file_get_contents(path, &buf, NULL, NULL)) { goto err_out; } return buf; From nobody Mon May 6 13:02:37 2024 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 150496967865234.47095013944238; Sat, 9 Sep 2017 08:07:58 -0700 (PDT) Received: from localhost ([::1]:49881 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqhMT-0000FD-ET for importer@patchew.org; Sat, 09 Sep 2017 11:07:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqhKt-0007kp-AU for qemu-devel@nongnu.org; Sat, 09 Sep 2017 11:06:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqhKo-00062T-KF for qemu-devel@nongnu.org; Sat, 09 Sep 2017 11:06:19 -0400 Received: from 6.mo177.mail-out.ovh.net ([46.105.51.249]:60202) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dqhKo-00061G-A1 for qemu-devel@nongnu.org; Sat, 09 Sep 2017 11:06:14 -0400 Received: from player714.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo177.mail-out.ovh.net (Postfix) with ESMTP id 02768716A6 for ; Sat, 9 Sep 2017 17:06:12 +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 C64FB3C0073; Sat, 9 Sep 2017 17:06:10 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Sat, 09 Sep 2017 17:06:10 +0200 Message-ID: <150496957019.9654.12729412560336508445.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: 244320282850466131 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.51.249 Subject: [Qemu-devel] [PATCH 2/5] spapr_pci: drop useless check in spapr_populate_pci_child_dt() 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 spapr_phb_get_loc_code() either returns a non-null pointer, either aborts if g_strdup_printf() failed to allocate memory. Signed-off-by: Greg Kurz Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/ppc/spapr_pci.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index ef982f2ef370..cd8efb181223 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1282,12 +1282,8 @@ static int spapr_populate_pci_child_dt(PCIDevice *de= v, void *fdt, int offset, pci_find_device_name((ccode >> 16) & 0xff, (ccode >> 8) & 0xff, ccode & 0xff))); - buf =3D spapr_phb_get_loc_code(sphb, dev); - if (!buf) { - error_report("Failed setting the ibm,loc-code"); - return -1; - } =20 + buf =3D spapr_phb_get_loc_code(sphb, dev); err =3D fdt_setprop_string(fdt, offset, "ibm,loc-code", buf); g_free(buf); if (err < 0) { From nobody Mon May 6 13:02:37 2024 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 150496997469149.77146514994229; Sat, 9 Sep 2017 08:12:54 -0700 (PDT) Received: from localhost ([::1]:49904 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqhRE-0004BW-Dx for importer@patchew.org; Sat, 09 Sep 2017 11:12:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50969) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqhL1-0007ps-Lw for qemu-devel@nongnu.org; Sat, 09 Sep 2017 11:06:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqhKw-00069q-Of for qemu-devel@nongnu.org; Sat, 09 Sep 2017 11:06:27 -0400 Received: from 6.mo177.mail-out.ovh.net ([46.105.51.249]:53098) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dqhKw-000687-3Z for qemu-devel@nongnu.org; Sat, 09 Sep 2017 11:06:22 -0400 Received: from player714.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo177.mail-out.ovh.net (Postfix) with ESMTP id CDAE871BB4 for ; Sat, 9 Sep 2017 17:06:20 +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 955683C0073; Sat, 9 Sep 2017 17:06:18 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Sat, 09 Sep 2017 17:06:18 +0200 Message-ID: <150496957801.9654.17692506571556698840.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: 246572081182185811 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.51.249 Subject: [Qemu-devel] [PATCH 3/5] spapr_pci: use g_strdup_printf() 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 Building strings with g_strdup_printf() instead of snprintf() is a QEMU common practice. Signed-off-by: Greg Kurz --- hw/ppc/spapr_pci.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index cd8efb181223..6da73fe6bc29 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -61,8 +61,6 @@ #define RTAS_TYPE_MSI 1 #define RTAS_TYPE_MSIX 2 =20 -#define FDT_NAME_MAX 128 - #define _FDT(exp) \ do { \ int ret =3D (exp); \ @@ -1194,7 +1192,7 @@ static const char *pci_find_device_name(uint8_t class= , uint8_t subclass, return name; } =20 -static void pci_get_node_name(char *nodename, int len, PCIDevice *dev) +static gchar *pci_get_node_name(PCIDevice *dev) { int slot =3D PCI_SLOT(dev->devfn); int func =3D PCI_FUNC(dev->devfn); @@ -1205,9 +1203,9 @@ static void pci_get_node_name(char *nodename, int len= , PCIDevice *dev) ccode & 0xff); =20 if (func !=3D 0) { - snprintf(nodename, len, "%s@%x,%x", name, slot, func); + return g_strdup_printf("%s@%x,%x", name, slot, func); } else { - snprintf(nodename, len, "%s@%x", name, slot); + return g_strdup_printf("%s@%x", name, slot); } } =20 @@ -1325,10 +1323,12 @@ static int spapr_create_pci_child_dt(sPAPRPHBState = *phb, PCIDevice *dev, void *fdt, int node_offset) { int offset, ret; - char nodename[FDT_NAME_MAX]; + gchar *nodename; =20 - pci_get_node_name(nodename, FDT_NAME_MAX, dev); + nodename =3D pci_get_node_name(dev); offset =3D fdt_add_subnode(fdt, node_offset, nodename); + g_free(nodename); + ret =3D spapr_populate_pci_child_dt(dev, fdt, offset, phb); =20 g_assert(!ret); @@ -2072,7 +2072,7 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb, void *fdt) { int bus_off, i, j, ret; - char nodename[FDT_NAME_MAX]; + gchar *nodename; uint32_t bus_range[] =3D { cpu_to_be32(0), cpu_to_be32(0xff) }; struct { uint32_t hi; @@ -2121,8 +2121,9 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb, sPAPRFDT s_fdt; =20 /* Start populating the FDT */ - snprintf(nodename, FDT_NAME_MAX, "pci@%" PRIx64, phb->buid); + nodename =3D g_strdup_printf("pci@%" PRIx64, phb->buid); bus_off =3D fdt_add_subnode(fdt, 0, nodename); + g_free(nodename); if (bus_off < 0) { return bus_off; } From nobody Mon May 6 13:02:37 2024 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 1504969701199298.98070756808045; Sat, 9 Sep 2017 08:08:21 -0700 (PDT) Received: from localhost ([::1]:49882 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqhMq-0000Yu-F2 for importer@patchew.org; Sat, 09 Sep 2017 11:08:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51077) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqhL8-0007v5-LK for qemu-devel@nongnu.org; Sat, 09 Sep 2017 11:06:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqhL4-0006Hd-5u for qemu-devel@nongnu.org; Sat, 09 Sep 2017 11:06:34 -0400 Received: from 10.mo177.mail-out.ovh.net ([46.105.73.133]:41248) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dqhL3-0006FX-VJ for qemu-devel@nongnu.org; Sat, 09 Sep 2017 11:06:30 -0400 Received: from player714.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo177.mail-out.ovh.net (Postfix) with ESMTP id 8F0BC751FF for ; Sat, 9 Sep 2017 17:06:28 +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 5CCB33C0073; Sat, 9 Sep 2017 17:06:26 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Sat, 09 Sep 2017 17:06:25 +0200 Message-ID: <150496958584.9654.9736122740323515191.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: 248823881333578067 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.73.133 Subject: [Qemu-devel] [PATCH 4/5] spapr_pci: use the common _FDT() helper 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 All other users in hw/ppc already consider an error when building the FDT to be fatal, even on hotplug paths. There's no valid reason for spapr_pci to behave differently. So let's used the common _FDT() helper which terminates QEMU when libfdt fails. Signed-off-by: Greg Kurz --- hw/ppc/spapr_pci.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 6da73fe6bc29..abb9f05e7b75 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -40,7 +40,7 @@ #include "trace.h" #include "qemu/error-report.h" #include "qapi/qmp/qerror.h" - +#include "hw/ppc/fdt.h" #include "hw/pci/pci_bridge.h" #include "hw/pci/pci_bus.h" #include "hw/pci/pci_ids.h" @@ -61,14 +61,6 @@ #define RTAS_TYPE_MSI 1 #define RTAS_TYPE_MSIX 2 =20 -#define _FDT(exp) \ - do { \ - int ret =3D (exp); \ - if (ret < 0) { \ - return ret; \ - } \ - } while (0) - sPAPRPHBState *spapr_pci_find_phb(sPAPRMachineState *spapr, uint64_t buid) { sPAPRPHBState *sphb; From nobody Mon May 6 13:02:37 2024 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"));