Skip to contentSkip to conversation

spar: remove extra type variable

PATCH In review Cédric Le Goater 3 participants 3 messages Aug 9, 2016 – Aug 10, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 spar: remove extra type variable

The sPAPR CPU core typename is already available in the upper block. Let's use it and move the check upward also.

---
 hw/ppc/spapr.c |   15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
hw/ppc/spapr.c +6 -9
Index: 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 on v2 1/1
#1 lore raw
Quoted 32 lines · Cédric Le Goater

The sPAPR CPU core typename is already available in the upper block. Let's use it and move the check upward also.

---
 hw/ppc/spapr.c |   15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

Index: qemu-dgibson-for-2.8.git/hw/ppc/spapr.c
===================================================================

hw/ppc/spapr.c +5 -3
@@ -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;
-

hw/ppc/spapr.c static void ppc_spapr_init(MachineState · line 1794

Quoted 10 lines
hw/ppc/spapr.c +1 -6
-                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,
#2 lore raw
In reply to Cédric Le Goater
Quoted 4 lines · Cédric Le Goater

The sPAPR CPU core typename is already available in the upper block. Let's use it and move the check upward also.

I already merged this as part of Thomas' series.

Quoted 38 lines
---
 hw/ppc/spapr.c |   15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

Index: qemu-dgibson-for-2.8.git/hw/ppc/spapr.c
===================================================================

hw/ppc/spapr.c +6 -9
@@ -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,
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson