mirror of https://github.com/xemu-project/xemu.git
hw/ppc/spapr_numa.c: simplify spapr_numa_write_assoc_lookup_arrays()
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>
This commit is contained in:
parent
5436eee1ac
commit
1628293727
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue