target-i386:cpu_x86_init():do clean up work
PATCH 1/1 target-i386:cpu_x86_init():do clean up work
1.remove unused variable env
2.remove redundant error handling
--- target-i386/helper.c | 17 ++++++++--------- 1 files changed, 8 insertions(+), 9 deletions(-)
target-i386/helper.c +8 -9
@@ -1243,25 +1243,24 @@ int cpu_x86_get_descr_debug(CPUX86State *env, unsigned int selector,X86CPU *cpu_x86_init (const char *cpu_model) {X86CPU *cpu; -CPUX86State *env;Error *error =NULL ; cpu =X86_CPU (object_new (TYPE_X86_CPU )); - env = &cpu->env; - env->cpu_model_str = cpu_model; -if (cpu_x86_register (cpu, cpu_model) <0 ) { -object_delete (OBJECT (cpu)); -return NULL ; - } +if (cpu_x86_register (cpu, cpu_model) <0 ) + goto error_out;x86_cpu_realize (OBJECT (cpu), &error);if (error) {error_free (error); -object_delete (OBJECT (cpu)); -return NULL ; + goto error_out; } +return cpu; + + error_out: +object_delete (OBJECT (cpu)); +return NULL ; }#if !defined(CONFIG_USER_ONLY )
Signature · 1 line
1.7.2.5
Quoted 1 line · liguang
1.remove unused variable env
It's not unused. You are removing the line that sets env->cpu_model_str.
Quoted 12 lines
2.remove redundant error handling
Signed-off-by liguang <[email protected]>--- target-i386/helper.c | 17 ++++++++--------- 1 files changed, 8 insertions(+), 9 deletions(-)target-i386/helper.c +0
-0
target-i386/helper.c int cpu_x86_get_descr_debug(CPUX86State *env, unsigned int selector, · line 1251
Quoted 9 lines
target-i386/helper.c +0
-3@@ -1243,25 +1243,24 @@ int cpu_x86_get_descr_debug(CPUX86State *env, unsigned int selector,X86CPU *cpu_x86_init (const char *cpu_model) {X86CPU *cpu; -CPUX86State *env;Error *error =NULL ; cpu =X86_CPU (object_new (TYPE_X86_CPU )); - env = &cpu->env; - env->cpu_model_str = cpu_model;
Why did you remove this line?
target-i386/helper.c int cpu_x86_get_descr_debug(CPUX86State *env, unsigned int selector, · line 1251
Quoted 7 lines
target-i386/helper.c +2
-4-if (cpu_x86_register (cpu, cpu_model) <0 ) { -object_delete (OBJECT (cpu)); -return NULL ; - } +if (cpu_x86_register (cpu, cpu_model) <0 ) + goto error_out;
You are mixing tabs and spaces here, and below:
target-i386/helper.c int cpu_x86_get_descr_debug(CPUX86State *env, unsigned int selector, · line 1256
Quoted 7 lines
target-i386/helper.c +1
-2x86_cpu_realize (OBJECT (cpu), &error);if (error) {error_free (error); -object_delete (OBJECT (cpu)); -return NULL ; + goto error_out;
(here)
target-i386/helper.c int cpu_x86_get_descr_debug(CPUX86State *env, unsigned int selector, · line 1263
Quoted 7 lines
target-i386/helper.c +5
-0} +return cpu; + + error_out: +object_delete (OBJECT (cpu)); +return NULL ;
(and here)
Quoted 6 lines
target-i386/helper.c +0
-0}#if !defined(CONFIG_USER_ONLY )Signature · 1 line
1.7.2.5
Signature · 1 line
Eduardo
Quoted 23 lines · 在 2012-11-29四的 16:34 -0200,Eduardo Habkost写道:
Quoted 1 line · liguang
1.remove unused variable env
It's not unused. You are removing the line that sets
env->cpu_model_str.Quoted 18 lines
2.remove redundant error handling
Signed-off-by liguang <[email protected]>--- target-i386/helper.c | 17 ++++++++--------- 1 files changed, 8 insertions(+), 9 deletions(-)target-i386/helper.c +0
-1@@ -1243,25 +1243,24 @@ int cpu_x86_get_descr_debug(CPUX86State *env, unsigned int selector,X86CPU *cpu_x86_init (const char *cpu_model) {X86CPU *cpu; -CPUX86State *env;Error *error =NULL ;
Quoted 5 lines
target-i386/helper.c int cpu_x86_get_descr_debug(CPUX86State *env, unsigned int selector, · line 1251
Quoted 3 lines
target-i386/helper.c +0
-2cpu =X86_CPU (object_new (TYPE_X86_CPU )); - env = &cpu->env; - env->cpu_model_str = cpu_model;Why did you remove this line?
OK, I drop this change,
or change like this
'cpu->env->cpu_model_str = cpu_model;'
seems a little ugly.
Quoted 38 lines
target-i386/helper.c int cpu_x86_get_descr_debug(CPUX86State *env, unsigned int selector, · line 1251
Quoted 8 lines
target-i386/helper.c +2
-4-if (cpu_x86_register (cpu, cpu_model) <0 ) { -object_delete (OBJECT (cpu)); -return NULL ; - } +if (cpu_x86_register (cpu, cpu_model) <0 ) + goto error_out;You are mixing tabs and spaces here, and below:
target-i386/helper.c int cpu_x86_get_descr_debug(CPUX86State *env, unsigned int selector, · line 1256
Quoted 7 lines
target-i386/helper.c +1
-2x86_cpu_realize (OBJECT (cpu), &error);if (error) {error_free (error); -object_delete (OBJECT (cpu)); -return NULL ; + goto error_out;(here)
target-i386/helper.c int cpu_x86_get_descr_debug(CPUX86State *env, unsigned int selector, · line 1263
Quoted 7 lines
target-i386/helper.c +5
-0} +return cpu; + + error_out: +object_delete (OBJECT (cpu)); +return NULL ;(and here)
Quoted 6 lines
target-i386/helper.c +0
-0}#if !defined(CONFIG_USER_ONLY )Signature · 1 line
1.7.2.5
Signature · 6 lines
regards! li guang linux kernel team at FNST, china thinking with brain but heart living with heart but brain