mirror of https://github.com/xemu-project/xemu.git
hw/riscv/virt.c: use g_autofree in virt_machine_init()
Move 'soc_name' to the loop, and give it g_autofree, to avoid the manual g_free(). Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20240122221529.86562-7-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
1d873c6ecf
commit
c70dc31f30
|
@ -1356,7 +1356,6 @@ static void virt_machine_init(MachineState *machine)
|
||||||
RISCVVirtState *s = RISCV_VIRT_MACHINE(machine);
|
RISCVVirtState *s = RISCV_VIRT_MACHINE(machine);
|
||||||
MemoryRegion *system_memory = get_system_memory();
|
MemoryRegion *system_memory = get_system_memory();
|
||||||
MemoryRegion *mask_rom = g_new(MemoryRegion, 1);
|
MemoryRegion *mask_rom = g_new(MemoryRegion, 1);
|
||||||
char *soc_name;
|
|
||||||
DeviceState *mmio_irqchip, *virtio_irqchip, *pcie_irqchip;
|
DeviceState *mmio_irqchip, *virtio_irqchip, *pcie_irqchip;
|
||||||
int i, base_hartid, hart_count;
|
int i, base_hartid, hart_count;
|
||||||
int socket_count = riscv_socket_count(machine);
|
int socket_count = riscv_socket_count(machine);
|
||||||
|
@ -1376,6 +1375,8 @@ static void virt_machine_init(MachineState *machine)
|
||||||
/* Initialize sockets */
|
/* Initialize sockets */
|
||||||
mmio_irqchip = virtio_irqchip = pcie_irqchip = NULL;
|
mmio_irqchip = virtio_irqchip = pcie_irqchip = NULL;
|
||||||
for (i = 0; i < socket_count; i++) {
|
for (i = 0; i < socket_count; i++) {
|
||||||
|
g_autofree char *soc_name = g_strdup_printf("soc%d", i);
|
||||||
|
|
||||||
if (!riscv_socket_check_hartids(machine, i)) {
|
if (!riscv_socket_check_hartids(machine, i)) {
|
||||||
error_report("discontinuous hartids in socket%d", i);
|
error_report("discontinuous hartids in socket%d", i);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -1393,10 +1394,8 @@ static void virt_machine_init(MachineState *machine)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
soc_name = g_strdup_printf("soc%d", i);
|
|
||||||
object_initialize_child(OBJECT(machine), soc_name, &s->soc[i],
|
object_initialize_child(OBJECT(machine), soc_name, &s->soc[i],
|
||||||
TYPE_RISCV_HART_ARRAY);
|
TYPE_RISCV_HART_ARRAY);
|
||||||
g_free(soc_name);
|
|
||||||
object_property_set_str(OBJECT(&s->soc[i]), "cpu-type",
|
object_property_set_str(OBJECT(&s->soc[i]), "cpu-type",
|
||||||
machine->cpu_type, &error_abort);
|
machine->cpu_type, &error_abort);
|
||||||
object_property_set_int(OBJECT(&s->soc[i]), "hartid-base",
|
object_property_set_int(OBJECT(&s->soc[i]), "hartid-base",
|
||||||
|
|
Loading…
Reference in New Issue