From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sx8DC-0004gN-37 for qemu-devel@nongnu.org; Thu, 02 Aug 2012 23:06:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sx8DA-00066l-6v for qemu-devel@nongnu.org; Thu, 02 Aug 2012 23:06:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33462) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sx8D9-00066L-Uq for qemu-devel@nongnu.org; Thu, 02 Aug 2012 23:06:00 -0400 From: Eduardo Habkost Date: Thu, 2 Aug 2012 23:59:21 -0300 Message-Id: <1343962766-22024-15-git-send-email-ehabkost@redhat.com> In-Reply-To: <1343962766-22024-1-git-send-email-ehabkost@redhat.com> References: <1343962766-22024-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [RFC 14/19] extract CPU object field initialization from cpu_x86_register() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Igor Mammedov , =?UTF-8?q?Andreas=20F=C3=A4rber?= Signed-off-by: Eduardo Habkost --- target-i386/cpu.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 5efbe41..f30e621 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1411,17 +1411,12 @@ void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf, const char *optarg) } } -int cpu_x86_register(X86CPU *cpu, const char *cpu_model) +/* Initialize CPU object from X86CPUDefinition struct */ +static int cpu_x86_init_from_def(X86CPU *cpu, X86CPUDefinition *def) { CPUX86State *env = &cpu->env; - X86CPUDefinition def1, *def = &def1; Error *error = NULL; - memset(def, 0, sizeof(*def)); - - if (cpu_x86_build_from_name(def, cpu_model) < 0) { - return -1; - } if (def->vendor1) { env->cpuid_vendor1 = def->vendor1; env->cpuid_vendor2 = def->vendor2; @@ -1464,6 +1459,24 @@ int cpu_x86_register(X86CPU *cpu, const char *cpu_model) error_free(error); return -1; } + + return 0; +} + +int cpu_x86_register(X86CPU *cpu, const char *cpu_model) +{ + X86CPUDefinition def1, *def = &def1; + + memset(def, 0, sizeof(*def)); + + if (cpu_x86_build_from_name(def, cpu_model) < 0) { + return -1; + } + + if (cpu_x86_init_from_def(cpu, def) < 0) { + return -1; + } + return 0; } -- 1.7.11.2