[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 01/19] spapr.c: use g_auto* with 'nodename' in CPU DT functions
From: |
David Gibson |
Subject: |
[PULL 01/19] spapr.c: use g_auto* with 'nodename' in CPU DT functions |
Date: |
Wed, 10 Feb 2021 17:17:17 +1100 |
From: Daniel Henrique Barboza <danielhb413@gmail.com>
Next patch will use the 'nodename' string in spapr_core_dt_populate()
after the point it's being freed today.
Instead of moving 'g_free(nodename)' around, let's do a QoL change in
both CPU DT functions where 'nodename' is being freed, and use
g_autofree to avoid the 'g_free()' call altogether.
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20210120232305.241521-2-danielhb413@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/ppc/spapr.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 612356e9ec..e7992c0422 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -791,7 +791,6 @@ static void spapr_dt_cpus(void *fdt, SpaprMachineState
*spapr)
CPUState *cs;
int n_cpus;
int cpus_offset;
- char *nodename;
int i;
cpus_offset = fdt_add_subnode(fdt, 0, "cpus");
@@ -819,6 +818,7 @@ static void spapr_dt_cpus(void *fdt, SpaprMachineState
*spapr)
PowerPCCPU *cpu = POWERPC_CPU(cs);
int index = spapr_get_vcpu_id(cpu);
DeviceClass *dc = DEVICE_GET_CLASS(cs);
+ g_autofree char *nodename = NULL;
int offset;
if (!spapr_is_thread0_in_vcore(spapr, cpu)) {
@@ -827,7 +827,6 @@ static void spapr_dt_cpus(void *fdt, SpaprMachineState
*spapr)
nodename = g_strdup_printf("%s@%x", dc->fw_name, index);
offset = fdt_add_subnode(fdt, cpus_offset, nodename);
- g_free(nodename);
_FDT(offset);
spapr_dt_cpu(cs, fdt, offset, spapr);
}
@@ -3749,12 +3748,11 @@ int spapr_core_dt_populate(SpaprDrc *drc,
SpaprMachineState *spapr,
PowerPCCPU *cpu = POWERPC_CPU(cs);
DeviceClass *dc = DEVICE_GET_CLASS(cs);
int id = spapr_get_vcpu_id(cpu);
- char *nodename;
+ g_autofree char *nodename = NULL;
int offset;
nodename = g_strdup_printf("%s@%x", dc->fw_name, id);
offset = fdt_add_subnode(fdt, 0, nodename);
- g_free(nodename);
spapr_dt_cpu(cs, fdt, offset, spapr);
--
2.29.2
- [PULL 00/19] ppc-for-6.0 queue 20210210, David Gibson, 2021/02/10
- [PULL 04/19] target/ppc: Remove unused MMU definitions, David Gibson, 2021/02/10
- [PULL 01/19] spapr.c: use g_auto* with 'nodename' in CPU DT functions,
David Gibson <=
- [PULL 02/19] spapr.c: add 'name' property for hotplugged CPUs nodes, David Gibson, 2021/02/10
- [PULL 06/19] ppc/xive: Add firmware bit when dumping the ENDs, David Gibson, 2021/02/10
- [PULL 08/19] ppc/pnv: Simplify pnv_bmc_create(), David Gibson, 2021/02/10
- [PULL 05/19] ppc/pnv: Add trace events for PCI event notification, David Gibson, 2021/02/10
- [PULL 09/19] ppc/pnv: Discard internal BMC initialization when BMC is external, David Gibson, 2021/02/10
- [PULL 03/19] spapr: Adjust firmware path of PCI devices, David Gibson, 2021/02/10
- [PULL 14/19] spapr_numa.c: fix ibm, max-associativity-domains calculation, David Gibson, 2021/02/10
- [PULL 19/19] target/ppc: Add E500 L2CSR0 write helper, David Gibson, 2021/02/10
- [PULL 07/19] ppc/pnv: Use skiboot addresses to load kernel and ramfs, David Gibson, 2021/02/10
- [PULL 10/19] ppc/pnv: Remove default disablement of the PNOR contents, David Gibson, 2021/02/10