Patchwork [RFC,11/13] check for NULL cpu_model outside cpu_x86_find_by_name

login
register
mail settings
Submitter Eduardo Habkost
Date Aug. 16, 2012, 4:59 p.m.
Message ID <1345136352-10756-12-git-send-email-ehabkost@redhat.com>
Download mbox | patch
Permalink /patch/178060/
State New
Headers show

Comments

Eduardo Habkost - Aug. 16, 2012, 4:59 p.m.
cpu_x86_find_by_name() will go away when we move to CPU model classes.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 target-i386/cpu.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Patch

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 2e24e00..9209bb1 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1402,11 +1402,6 @@  static int cpu_x86_find_by_name(X86CPU *cpu, X86CPUDefinition *x86_cpu_def,
 {
     X86CPUModelTableEntry *def;
 
-    if (!cpu_model) {
-        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cpu_model", "NULL");
-        return -1;
-    }
-
     for (def = x86_defs; def; def = def->next) {
         if (!strcmp(cpu_model, def->name)) {
             break;
@@ -1521,6 +1516,11 @@  X86CPU *cpu_x86_create(const char *cpu_model)
     env = &cpu->env;
     env->cpu_model_str = cpu_model;
 
+    if (!cpu_model) {
+        error_set(&error, QERR_INVALID_PARAMETER_VALUE, "cpu_model", "NULL");
+        goto error;
+    }
+
     if (cpu_x86_find_by_name(cpu, def, name, &error) < 0) {
         goto error;
     }