[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] cpu: drop unnecessary NULL check and cpu_common_cla
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH] cpu: drop unnecessary NULL check and cpu_common_class_by_name() |
Date: |
Wed, 7 Feb 2018 15:30:57 +0100 |
both do nothing as for the first all callers
parse_cpu_model() and qmp_query_cpu_model_()
should provide non NULL value, so just abort if it's not so.
While at it drop cpu_common_class_by_name() which is not need
any more as every target has CPUClass::class_by_name callback
by now, though abort in case a new arch will forget to define one.
Signed-off-by: Igor Mammedov <address@hidden>
---
isn't really tested but it compiles and passes make check
qom/cpu.c | 14 ++------------
target/i386/cpu.c | 8 +-------
2 files changed, 3 insertions(+), 19 deletions(-)
diff --git a/qom/cpu.c b/qom/cpu.c
index 60292df..92599f3 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -286,21 +286,12 @@ static bool cpu_common_has_work(CPUState *cs)
ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model)
{
- CPUClass *cc;
-
- if (!cpu_model) {
- return NULL;
- }
- cc = CPU_CLASS(object_class_by_name(typename));
+ CPUClass *cc = CPU_CLASS(object_class_by_name(typename));
+ assert(cpu_model && cc->class_by_name);
return cc->class_by_name(cpu_model);
}
-static ObjectClass *cpu_common_class_by_name(const char *cpu_model)
-{
- return NULL;
-}
-
static void cpu_common_parse_features(const char *typename, char *features,
Error **errp)
{
@@ -418,7 +409,6 @@ static void cpu_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
CPUClass *k = CPU_CLASS(klass);
- k->class_by_name = cpu_common_class_by_name;
k->parse_features = cpu_common_parse_features;
k->reset = cpu_common_reset;
k->get_arch_id = cpu_common_get_arch_id;
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index a49d222..61d915b 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -740,13 +740,7 @@ static char *x86_cpu_type_name(const char *model_name)
static ObjectClass *x86_cpu_class_by_name(const char *cpu_model)
{
ObjectClass *oc;
- char *typename;
-
- if (cpu_model == NULL) {
- return NULL;
- }
-
- typename = x86_cpu_type_name(cpu_model);
+ char *typename = x86_cpu_type_name(cpu_model);
oc = object_class_by_name(typename);
g_free(typename);
return oc;
--
2.7.4
- [Qemu-devel] [PATCH v4 0/5] generalize parsing of cpu_model (part 4), Igor Mammedov, 2018/02/07
- [Qemu-devel] [PATCH v4 2/5] tests: add machine 'none' with -cpu test, Igor Mammedov, 2018/02/07
- [Qemu-devel] [PATCH v4 4/5] Use cpu_create(type) instead of cpu_init(cpu_model), Igor Mammedov, 2018/02/07
- [Qemu-devel] [PATCH v4 5/5] cpu: get rid of unused cpu_init() defines, Igor Mammedov, 2018/02/07
- [Qemu-devel] [PATCH v4 1/5] nios2: 10m50_devboard: replace cpu_model with cpu_type, Igor Mammedov, 2018/02/07
- [Qemu-devel] [PATCH v4 3/5] cpu: add CPU_RESOLVING_TYPE macro, Igor Mammedov, 2018/02/07
- Re: [Qemu-devel] [PATCH v4 0/5] generalize parsing of cpu_model (part 4), Eduardo Habkost, 2018/02/07