[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 84/87] hw/ppc/spapr_numa.c: simplify spapr_numa_write_assoc_lookup
From: |
Cédric Le Goater |
Subject: |
[PULL 84/87] hw/ppc/spapr_numa.c: simplify spapr_numa_write_assoc_lookup_arrays() |
Date: |
Wed, 2 Mar 2022 12:08:00 +0100 |
From: Daniel Henrique Barboza <danielhb413@gmail.com>
We can get the job done in spapr_numa_write_assoc_lookup_arrays() a bit
cleaner:
- 'cur_index = int_buf = g_malloc0(..)' is doing a g_malloc0() in the
'int_buf' pointer and making 'cur_index' point to 'int_buf' all in a
single line. No problem with that, but splitting into 2 lines is clearer
to follow
- use g_autofree in 'int_buf' to avoid a g_free() call later on
- 'buf_len' is only being used to store the size of 'int_buf' malloc.
Remove the var and just use the value in g_malloc0() directly
- remove the 'ret' var and just return the result of fdt_setprop()
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20220228175004.8862-12-danielhb413@gmail.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/ppc/spapr_numa.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/hw/ppc/spapr_numa.c b/hw/ppc/spapr_numa.c
index e9ef7e764696..4f93bdefec64 100644
--- a/hw/ppc/spapr_numa.c
+++ b/hw/ppc/spapr_numa.c
@@ -431,12 +431,14 @@ int
spapr_numa_write_assoc_lookup_arrays(SpaprMachineState *spapr, void *fdt,
int max_distance_ref_points = get_max_dist_ref_points(spapr);
int nb_numa_nodes = machine->numa_state->num_nodes;
int nr_nodes = nb_numa_nodes ? nb_numa_nodes : 1;
- uint32_t *int_buf, *cur_index, buf_len;
- int ret, i;
+ g_autofree uint32_t *int_buf = NULL;
+ uint32_t *cur_index;
+ int i;
/* ibm,associativity-lookup-arrays */
- buf_len = (nr_nodes * max_distance_ref_points + 2) * sizeof(uint32_t);
- cur_index = int_buf = g_malloc0(buf_len);
+ int_buf = g_malloc0((nr_nodes * max_distance_ref_points + 2) *
+ sizeof(uint32_t));
+ cur_index = int_buf;
int_buf[0] = cpu_to_be32(nr_nodes);
/* Number of entries per associativity list */
int_buf[1] = cpu_to_be32(max_distance_ref_points);
@@ -451,11 +453,9 @@ int spapr_numa_write_assoc_lookup_arrays(SpaprMachineState
*spapr, void *fdt,
sizeof(uint32_t) * max_distance_ref_points);
cur_index += max_distance_ref_points;
}
- ret = fdt_setprop(fdt, offset, "ibm,associativity-lookup-arrays", int_buf,
- (cur_index - int_buf) * sizeof(uint32_t));
- g_free(int_buf);
- return ret;
+ return fdt_setprop(fdt, offset, "ibm,associativity-lookup-arrays",
+ int_buf, (cur_index - int_buf) * sizeof(uint32_t));
}
static void spapr_numa_FORM1_write_rtas_dt(SpaprMachineState *spapr,
--
2.34.1
- [PULL 35/87] target/ppc: Move xxsel to decodetree, (continued)
- [PULL 35/87] target/ppc: Move xxsel to decodetree, Cédric Le Goater, 2022/03/02
- [PULL 42/87] target/ppc: move xs[n]madd[am][ds]p/xs[n]msub[am][ds]p to decodetree, Cédric Le Goater, 2022/03/02
- [PULL 48/87] target/ppc: Move xscmp{eq,ge,gt}dp to decodetree, Cédric Le Goater, 2022/03/02
- [PULL 63/87] ppc/psi: Add support for StoreEOI and 64k ESB pages (POWER10), Cédric Le Goater, 2022/03/02
- [PULL 69/87] ppc/pnv: add XIVE Gen2 TIMA support, Cédric Le Goater, 2022/03/02
- [PULL 70/87] pnv/xive2: Add support XIVE2 P9-compat mode (or Gen1), Cédric Le Goater, 2022/03/02
- [PULL 67/87] ppc/pnv: Add support for PHB5 "Address-based trigger" mode, Cédric Le Goater, 2022/03/02
- [PULL 66/87] ppc/pnv: Add support for PQ offload on PHB5, Cédric Le Goater, 2022/03/02
- [PULL 59/87] ppc/pnv: Add a OCC model for POWER10, Cédric Le Goater, 2022/03/02
- [PULL 73/87] pnv/xive2: Add support for 8bits thread id, Cédric Le Goater, 2022/03/02
- [PULL 84/87] hw/ppc/spapr_numa.c: simplify spapr_numa_write_assoc_lookup_arrays(),
Cédric Le Goater <=
- [PULL 82/87] hw/ppc/spapr_drc.c: use g_autofree in spapr_dr_connector_new(), Cédric Le Goater, 2022/03/02
- [PULL 86/87] hw/ppc/spapr_rtas.c: use g_autofree in rtas_ibm_get_system_parameter(), Cédric Le Goater, 2022/03/02
- [PULL 61/87] ppc/pnv: Add model for POWER10 PHB5 PCIe Host bridge, Cédric Le Goater, 2022/03/02
- [PULL 54/87] target/ppc: implement plxssp/pstxssp, Cédric Le Goater, 2022/03/02
- [PULL 64/87] ppc/xive2: Add support for notification injection on ESB pages, Cédric Le Goater, 2022/03/02
- [PULL 72/87] pnv/xive2: Add support for automatic save&restore, Cédric Le Goater, 2022/03/02
- [PULL 71/87] xive2: Add a get_config() handler for the router configuration, Cédric Le Goater, 2022/03/02
- [PULL 78/87] hw/ppc/spapr_caps.c: use g_autofree in spapr_caps_add_properties(), Cédric Le Goater, 2022/03/02
- [PULL 75/87] hw/ppc/spapr.c: fail early if no firmware found in machine_init(), Cédric Le Goater, 2022/03/02
- [PULL 77/87] hw/ppc/spapr_caps.c: use g_autofree in spapr_cap_get_string(), Cédric Le Goater, 2022/03/02