Message ID | 20231003082728.83496-5-philmd@linaro.org |
---|---|
State | New |
Headers | show |
Series | hw/intc/apic: QOM cleanup | expand |
On Tue, Oct 03, 2023 at 10:27:27AM +0200, Philippe Mathieu-Daudé wrote: > x86_cpu_apic_create()'s Error** parameter is unused, drop it. > > While there is no convention, QDev methods are usually named > with _new() / _realize() suffixes. Rename as appropriate. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Peter Xu <peterx@redhat.com>
On 10/3/23 10:27, Philippe Mathieu-Daudé wrote: > - x86_cpu_apic_create(cpu, &local_err); > - if (local_err != NULL) { > - goto out; > - } > + x86_cpu_apic_new(cpu); I don't like this, "*_new" is generally for functions that return what they create. Patch 2 is scary with the newly-introduced possible failure, but I suppose it's safer if you reason that any problem will occur at startup, not at hotplug time for example. Paolo
diff --git a/target/i386/cpu-internal.h b/target/i386/cpu-internal.h index 9baac5c0b4..8299b347f7 100644 --- a/target/i386/cpu-internal.h +++ b/target/i386/cpu-internal.h @@ -62,7 +62,7 @@ GuestPanicInformation *x86_cpu_get_crash_info(CPUState *cs); void x86_cpu_get_crash_info_qom(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp); -void x86_cpu_apic_create(X86CPU *cpu, Error **errp); +void x86_cpu_apic_new(X86CPU *cpu); void x86_cpu_apic_realize(X86CPU *cpu, Error **errp); void x86_cpu_machine_reset_cb(void *opaque); #endif /* !CONFIG_USER_ONLY */ diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index bccb4241c2..8a79eacdb0 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -451,7 +451,7 @@ static void apic_common_class_init(ObjectClass *klass, void *data) dc->unrealize = apic_common_unrealize; /* * Reason: APIC and CPU need to be wired up by - * x86_cpu_apic_create() + * x86_cpu_apic_new() */ dc->user_creatable = false; } diff --git a/target/i386/cpu-sysemu.c b/target/i386/cpu-sysemu.c index 9038c65267..373dc6b1c7 100644 --- a/target/i386/cpu-sysemu.c +++ b/target/i386/cpu-sysemu.c @@ -263,7 +263,7 @@ APICCommonClass *apic_get_class(void) return APIC_COMMON_CLASS(object_class_by_name(apic_type)); } -void x86_cpu_apic_create(X86CPU *cpu, Error **errp) +void x86_cpu_apic_new(X86CPU *cpu) { APICCommonState *apic; APICCommonClass *apic_class = apic_get_class(); diff --git a/target/i386/cpu.c b/target/i386/cpu.c index ed72883bf3..69d56bae91 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7418,10 +7418,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) qemu_register_reset(x86_cpu_machine_reset_cb, cpu); if (cpu->env.features[FEAT_1_EDX] & CPUID_APIC || ms->smp.cpus > 1) { - x86_cpu_apic_create(cpu, &local_err); - if (local_err != NULL) { - goto out; - } + x86_cpu_apic_new(cpu); } #endif
x86_cpu_apic_create()'s Error** parameter is unused, drop it. While there is no convention, QDev methods are usually named with _new() / _realize() suffixes. Rename as appropriate. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- target/i386/cpu-internal.h | 2 +- hw/intc/apic_common.c | 2 +- target/i386/cpu-sysemu.c | 2 +- target/i386/cpu.c | 5 +---- 4 files changed, 4 insertions(+), 7 deletions(-)