From: Eduardo Habkost <ehabkost@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: Marcel Apfelbaum <marcel@redhat.com>,
Igor Mammedov <imammedo@redhat.com>
Subject: [Qemu-devel] [PULL 7/7] cpu: drop unnecessary NULL check and cpu_common_class_by_name()
Date: Mon, 12 Feb 2018 16:53:47 -0200 [thread overview]
Message-ID: <20180212185347.8433-8-ehabkost@redhat.com> (raw)
In-Reply-To: <20180212185347.8433-1-ehabkost@redhat.com>
From: Igor Mammedov <imammedo@redhat.com>
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 <imammedo@redhat.com>
Message-Id: <1518013857-4372-1-git-send-email-imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
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 60292dfde9..92599f3541 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 b5e431e769..acc853c871 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -741,13 +741,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.14.3
next prev parent reply other threads:[~2018-02-12 18:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-12 18:53 [Qemu-devel] [PULL 0/7] machine/CPU queue, 2018-02-12 Eduardo Habkost
2018-02-12 18:53 ` [Qemu-devel] [PULL 1/7] pc: correct misspelled CPU model-id for pc 2.2 Eduardo Habkost
2018-02-12 18:53 ` [Qemu-devel] [PULL 2/7] nios2: 10m50_devboard: replace cpu_model with cpu_type Eduardo Habkost
2018-02-12 18:53 ` [Qemu-devel] [PULL 3/7] tests: add machine 'none' with -cpu test Eduardo Habkost
2018-02-12 18:53 ` [Qemu-devel] [PULL 4/7] cpu: add CPU_RESOLVING_TYPE macro Eduardo Habkost
2018-02-12 18:53 ` [Qemu-devel] [PULL 5/7] Use cpu_create(type) instead of cpu_init(cpu_model) Eduardo Habkost
2018-02-12 18:53 ` [Qemu-devel] [PULL 6/7] cpu: get rid of unused cpu_init() defines Eduardo Habkost
2018-02-12 18:53 ` Eduardo Habkost [this message]
2018-02-12 19:46 ` [Qemu-devel] [PULL 0/7] machine/CPU queue, 2018-02-12 no-reply
2018-02-12 20:58 ` Eduardo Habkost
-- strict thread matches above, loose matches on Subject: below --
2018-03-12 22:34 [Qemu-devel] [PULL 0/7] Machine queue, 2018-03-12 Eduardo Habkost
2018-03-12 22:34 ` [Qemu-devel] [PULL 7/7] cpu: drop unnecessary NULL check and cpu_common_class_by_name() Eduardo Habkost
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180212185347.8433-8-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=marcel@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).