Skip to content

Commit

Permalink
target-i386: Simplify error handling on cpu_x86_init_user()
Browse files Browse the repository at this point in the history
Isolate error handling path from the "if (error)" checks.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
  • Loading branch information
ehabkost committed Feb 25, 2015
1 parent 15258d4 commit 18b0e4e
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions target-i386/cpu.c
Expand Up @@ -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)
Expand Down

0 comments on commit 18b0e4e

Please sign in to comment.