From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQi6e-0000v6-Bh for qemu-devel@nongnu.org; Wed, 25 Feb 2015 14:58:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQi6d-0000Fg-MF for qemu-devel@nongnu.org; Wed, 25 Feb 2015 14:58:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56975) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQi6d-0000Fc-FP for qemu-devel@nongnu.org; Wed, 25 Feb 2015 14:58:51 -0500 From: Eduardo Habkost Date: Wed, 25 Feb 2015 16:58:21 -0300 Message-Id: <1424894306-26740-7-git-send-email-ehabkost@redhat.com> In-Reply-To: <1424894306-26740-1-git-send-email-ehabkost@redhat.com> References: <1424894306-26740-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PULL 06/11] target-i386: Simplify error handling on cpu_x86_init_user() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , qemu-devel@nongnu.org Isolate error handling path from the "if (error)" checks. Reviewed-by: Paolo Bonzini Signed-off-by: Eduardo Habkost --- target-i386/cpu.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index aee4d3e..f6a7671 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -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) -- 2.1.0