diff mbox

[v2] spar: remove extra type variable

Message ID 1470741305-20799-1-git-send-email-clg@kaod.org
State New
Headers show

Commit Message

Cédric Le Goater Aug. 9, 2016, 11:15 a.m. UTC
The sPAPR CPU core typename is already available in the upper
block. Let's use it and move the check upward also.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/ppc/spapr.c |   15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

Comments

Thomas Huth Aug. 9, 2016, 11:32 a.m. UTC | #1
On 09.08.2016 13:15, Cédric Le Goater wrote:
> The sPAPR CPU core typename is already available in the upper
> block. Let's use it and move the check upward also.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  hw/ppc/spapr.c |   15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)
> 
> Index: qemu-dgibson-for-2.8.git/hw/ppc/spapr.c
> ===================================================================
> --- qemu-dgibson-for-2.8.git.orig/hw/ppc/spapr.c
> +++ qemu-dgibson-for-2.8.git/hw/ppc/spapr.c
> @@ -1772,6 +1772,11 @@ static void ppc_spapr_init(MachineState
>      if (mc->query_hotpluggable_cpus) {
>          char *type = spapr_get_cpu_core_type(machine->cpu_model);
>  
> +        if (!object_class_by_name(type)) {
> +            error_report("Unable to find sPAPR CPU Core definition");
> +            exit(1);
> +        }
> +
>          spapr->cores = g_new0(Object *, spapr_max_cores);
>          for (i = 0; i < spapr_max_cores; i++) {
>              int core_id = i * smp_threads;
> @@ -1783,15 +1788,7 @@ static void ppc_spapr_init(MachineState
>              qemu_register_reset(spapr_drc_reset, drc);
>  
>              if (i < spapr_cores) {
> -                char *type = spapr_get_cpu_core_type(machine->cpu_model);
> -                Object *core;
> -
> -                if (!object_class_by_name(type)) {
> -                    error_report("Unable to find sPAPR CPU Core definition");
> -                    exit(1);
> -                }
> -
> -                core  = object_new(type);
> +                Object *core  = object_new(type);
>                  object_property_set_int(core, smp_threads, "nr-threads",
>                                          &error_fatal);
>                  object_property_set_int(core, core_id, CPU_CORE_PROP_CORE_ID,
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>
David Gibson Aug. 10, 2016, 4:47 a.m. UTC | #2
On Tue, Aug 09, 2016 at 01:15:05PM +0200, Cédric Le Goater wrote:
> The sPAPR CPU core typename is already available in the upper
> block. Let's use it and move the check upward also.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

I already merged this as part of Thomas' series.

> ---
>  hw/ppc/spapr.c |   15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)
> 
> Index: qemu-dgibson-for-2.8.git/hw/ppc/spapr.c
> ===================================================================
> --- qemu-dgibson-for-2.8.git.orig/hw/ppc/spapr.c
> +++ qemu-dgibson-for-2.8.git/hw/ppc/spapr.c
> @@ -1772,6 +1772,11 @@ static void ppc_spapr_init(MachineState
>      if (mc->query_hotpluggable_cpus) {
>          char *type = spapr_get_cpu_core_type(machine->cpu_model);
>  
> +        if (!object_class_by_name(type)) {
> +            error_report("Unable to find sPAPR CPU Core definition");
> +            exit(1);
> +        }
> +
>          spapr->cores = g_new0(Object *, spapr_max_cores);
>          for (i = 0; i < spapr_max_cores; i++) {
>              int core_id = i * smp_threads;
> @@ -1783,15 +1788,7 @@ static void ppc_spapr_init(MachineState
>              qemu_register_reset(spapr_drc_reset, drc);
>  
>              if (i < spapr_cores) {
> -                char *type = spapr_get_cpu_core_type(machine->cpu_model);
> -                Object *core;
> -
> -                if (!object_class_by_name(type)) {
> -                    error_report("Unable to find sPAPR CPU Core definition");
> -                    exit(1);
> -                }
> -
> -                core  = object_new(type);
> +                Object *core  = object_new(type);
>                  object_property_set_int(core, smp_threads, "nr-threads",
>                                          &error_fatal);
>                  object_property_set_int(core, core_id, CPU_CORE_PROP_CORE_ID,
>
diff mbox

Patch

Index: qemu-dgibson-for-2.8.git/hw/ppc/spapr.c
===================================================================
--- qemu-dgibson-for-2.8.git.orig/hw/ppc/spapr.c
+++ qemu-dgibson-for-2.8.git/hw/ppc/spapr.c
@@ -1772,6 +1772,11 @@  static void ppc_spapr_init(MachineState
     if (mc->query_hotpluggable_cpus) {
         char *type = spapr_get_cpu_core_type(machine->cpu_model);
 
+        if (!object_class_by_name(type)) {
+            error_report("Unable to find sPAPR CPU Core definition");
+            exit(1);
+        }
+
         spapr->cores = g_new0(Object *, spapr_max_cores);
         for (i = 0; i < spapr_max_cores; i++) {
             int core_id = i * smp_threads;
@@ -1783,15 +1788,7 @@  static void ppc_spapr_init(MachineState
             qemu_register_reset(spapr_drc_reset, drc);
 
             if (i < spapr_cores) {
-                char *type = spapr_get_cpu_core_type(machine->cpu_model);
-                Object *core;
-
-                if (!object_class_by_name(type)) {
-                    error_report("Unable to find sPAPR CPU Core definition");
-                    exit(1);
-                }
-
-                core  = object_new(type);
+                Object *core  = object_new(type);
                 object_property_set_int(core, smp_threads, "nr-threads",
                                         &error_fatal);
                 object_property_set_int(core, core_id, CPU_CORE_PROP_CORE_ID,