[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 05/18] spapr_pci: use g_strdup_printf()
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 05/18] spapr_pci: use g_strdup_printf() |
Date: |
Fri, 15 Sep 2017 13:51:17 +1000 |
From: Greg Kurz <address@hidden>
Building strings with g_strdup_printf() instead of snprintf() is
a QEMU common practice.
Signed-off-by: Greg Kurz <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
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 cd8efb1812..6da73fe6bc 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
-#define FDT_NAME_MAX 128
-
#define _FDT(exp) \
do { \
int ret = (exp); \
@@ -1194,7 +1192,7 @@ static const char *pci_find_device_name(uint8_t class,
uint8_t subclass,
return name;
}
-static void pci_get_node_name(char *nodename, int len, PCIDevice *dev)
+static gchar *pci_get_node_name(PCIDevice *dev)
{
int slot = PCI_SLOT(dev->devfn);
int func = PCI_FUNC(dev->devfn);
@@ -1205,9 +1203,9 @@ static void pci_get_node_name(char *nodename, int len,
PCIDevice *dev)
ccode & 0xff);
if (func != 0) {
- snprintf(nodename, len, "address@hidden,%x", name, slot, func);
+ return g_strdup_printf("address@hidden,%x", name, slot, func);
} else {
- snprintf(nodename, len, "address@hidden", name, slot);
+ return g_strdup_printf("address@hidden", name, slot);
}
}
@@ -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;
- pci_get_node_name(nodename, FDT_NAME_MAX, dev);
+ nodename = pci_get_node_name(dev);
offset = fdt_add_subnode(fdt, node_offset, nodename);
+ g_free(nodename);
+
ret = spapr_populate_pci_child_dt(dev, fdt, offset, phb);
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[] = { 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;
/* Start populating the FDT */
- snprintf(nodename, FDT_NAME_MAX, "address@hidden" PRIx64, phb->buid);
+ nodename = g_strdup_printf("address@hidden" PRIx64, phb->buid);
bus_off = fdt_add_subnode(fdt, 0, nodename);
+ g_free(nodename);
if (bus_off < 0) {
return bus_off;
}
--
2.13.5
- [Qemu-ppc] [PULL 00/18] ppc-for-2.11 queue 20170915, David Gibson, 2017/09/14
- [Qemu-ppc] [PULL 03/18] spapr_pci: drop useless check in spapr_phb_vfio_get_loc_code(), David Gibson, 2017/09/14
- [Qemu-ppc] [PULL 09/18] spapr_pci: use the common _FDT() helper, David Gibson, 2017/09/14
- [Qemu-ppc] [PULL 08/18] spapr: fix CAS-generated reset, David Gibson, 2017/09/14
- [Qemu-ppc] [PULL 17/18] spapr_events: use QTAILQ_FOREACH_SAFE() in spapr_clear_pending_events(), David Gibson, 2017/09/14
- [Qemu-ppc] [PULL 13/18] spapr_cpu_core: fail gracefully with non-pseries machine types, David Gibson, 2017/09/14
- [Qemu-ppc] [PULL 10/18] spapr_pci: handle FDT creation errors with _FDT(), David Gibson, 2017/09/14
- [Qemu-ppc] [PULL 11/18] vfio, spapr: Fix levels calculation, David Gibson, 2017/09/14
- [Qemu-ppc] [PULL 02/18] hw/ppc/spapr.c: cleaning up qdev_get_machine() calls, David Gibson, 2017/09/14
- [Qemu-ppc] [PULL 05/18] spapr_pci: use g_strdup_printf(),
David Gibson <=
- [Qemu-ppc] [PULL 14/18] spapr_pci: convert sprintf() to g_strdup_printf(), David Gibson, 2017/09/14
- [Qemu-ppc] [PULL 04/18] spapr_pci: drop useless check in spapr_populate_pci_child_dt(), David Gibson, 2017/09/14
- [Qemu-ppc] [PULL 07/18] ppc/xive: fix OV5_XIVE_EXPLOIT bits, David Gibson, 2017/09/14
- [Qemu-ppc] [PULL 15/18] spapr_pci: don't create 64-bit MMIO window if we don't need to, David Gibson, 2017/09/14
- [Qemu-ppc] [PULL 06/18] spapr: only update SDR1 once per-cpu during CAS, David Gibson, 2017/09/14
- [Qemu-ppc] [PULL 12/18] xics: fix several error leaks, David Gibson, 2017/09/14
- [Qemu-ppc] [PULL 16/18] spapr_cpu_core: cleaning up qdev_get_machine() calls, David Gibson, 2017/09/14
- [Qemu-ppc] [PULL 18/18] ppc/kvm: use kvm_vm_check_extension() in kvmppc_is_pr(), David Gibson, 2017/09/14
- [Qemu-ppc] [PULL 01/18] net: Add SunGEM device emulation as found on Apple UniNorth, David Gibson, 2017/09/14
- Re: [Qemu-ppc] [Qemu-devel] [PULL 00/18] ppc-for-2.11 queue 20170915, no-reply, 2017/09/15