target-i386: Simplify error handling on cpu_x86_init_user()
authorEduardo Habkost <ehabkost@redhat.com>
Fri, 19 Dec 2014 16:51:00 +0000 (14:51 -0200)
committerEduardo Habkost <ehabkost@redhat.com>
Wed, 25 Feb 2015 18:00:07 +0000 (15:00 -0300)
Isolate error handling path from the "if (error)" checks.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
target-i386/cpu.c

index aee4d3e7ce105e8e1b0fae0618b21216d86fd8c8..f6a7671f0d552e3a59e6330f31a676f249e57bc9 100644 (file)
@@ -2142,21 +2142,23 @@ CPUX86State *cpu_x86_init_user(const char *cpu_model)
 
     cpu = cpu_x86_create(cpu_model, NULL, &error);
     if (error) {
-        goto out;
+        goto error;
     }
 
     object_property_set_bool(OBJECT(cpu), true, "realized", &error);
-
-out:
     if (error) {
-        error_report("%s", error_get_pretty(error));
-        error_free(error);
-        if (cpu != NULL) {
-            object_unref(OBJECT(cpu));
-        }
-        return NULL;
+        goto error;
     }
+
     return &cpu->env;
+
+error:
+    error_report("%s", error_get_pretty(error));
+    error_free(error);
+    if (cpu != NULL) {
+        object_unref(OBJECT(cpu));
+    }
+    return NULL;
 }
 
 static void x86_cpu_cpudef_class_init(ObjectClass *oc, void *data)