On 11/14/23 15:56, Gavin Shan wrote:
No need to have 'oc == NULL' since object_class_dynamic_cast()
covers it. Besides, we don't expect an abstrat CPU class returned
from CPUClass::cpu_class_by_name() in the middle on alpha and rx.
Signed-off-by: Gavin Shan <gs...@redhat.com>
---
target/alpha/cpu.c | 3 ++-
target/rx/cpu.c | 4 +++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c
index 83345c5c7d..c19257d765 100644
--- a/target/alpha/cpu.c
+++ b/target/alpha/cpu.c
@@ -126,7 +126,8 @@ static ObjectClass *alpha_cpu_class_by_name(const char
*cpu_model)
int i;
oc = object_class_by_name(cpu_model);
- if (oc != NULL && object_class_dynamic_cast(oc, TYPE_ALPHA_CPU) != NULL) {
+ if (object_class_dynamic_cast(oc, TYPE_ALPHA_CPU) &&
+ !object_class_is_abstract(oc)) {
return oc;
}
This appears to be a rebase error, re-introducing code removed in patch 3.
I think the entire patch should be dropped.
r~
diff --git a/target/rx/cpu.c b/target/rx/cpu.c
index 9cc9d9d15e..dd5561c8eb 100644
--- a/target/rx/cpu.c
+++ b/target/rx/cpu.c
@@ -111,9 +111,11 @@ static ObjectClass *rx_cpu_class_by_name(const char
*cpu_model)
char *typename;
oc = object_class_by_name(cpu_model);
- if (oc != NULL && object_class_dynamic_cast(oc, TYPE_RX_CPU) != NULL) {
+ if (object_class_dynamic_cast(oc, TYPE_RX_CPU) &&
+ !object_class_is_abstract(oc)) {
return oc;
}
+
typename = g_strdup_printf(RX_CPU_TYPE_NAME("%s"), cpu_model);
oc = object_class_by_name(typename);
g_free(typename);