File tree Expand file tree Collapse file tree 15 files changed +28
-37
lines changed
Expand file tree Collapse file tree 15 files changed +28
-37
lines changed Original file line number Diff line number Diff line change @@ -146,10 +146,18 @@ static bool cpu_common_has_work(CPUState *cs)
146146
147147ObjectClass * cpu_class_by_name (const char * typename , const char * cpu_model )
148148{
149- CPUClass * cc = CPU_CLASS (object_class_by_name (typename ));
150-
151- assert (cpu_model && cc -> class_by_name );
152- return cc -> class_by_name (cpu_model );
149+ ObjectClass * oc ;
150+ CPUClass * cc ;
151+
152+ oc = object_class_by_name (typename );
153+ cc = CPU_CLASS (oc );
154+ assert (cc -> class_by_name );
155+ assert (cpu_model );
156+ oc = cc -> class_by_name (cpu_model );
157+ if (oc == NULL || object_class_is_abstract (oc )) {
158+ return NULL ;
159+ }
160+ return oc ;
153161}
154162
155163static void cpu_common_parse_features (const char * typename , char * features ,
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ struct SysemuCPUOps;
102102/**
103103 * CPUClass:
104104 * @class_by_name: Callback to map -cpu command line model name to an
105- * instantiatable CPU type.
105+ * instantiatable CPU type.
106106 * @parse_features: Callback to parse command line arguments.
107107 * @reset_dump_flags: #CPUDumpFlags to use for reset logging.
108108 * @has_work: Callback for checking if there is work to do.
@@ -772,9 +772,10 @@ void cpu_reset(CPUState *cpu);
772772 * @typename: The CPU base type.
773773 * @cpu_model: The model string without any parameters.
774774 *
775- * Looks up a CPU #ObjectClass matching name @cpu_model.
775+ * Looks up a concrete CPU #ObjectClass matching name @cpu_model.
776776 *
777- * Returns: A #CPUClass or %NULL if not matching class is found.
777+ * Returns: A concrete #CPUClass or %NULL if no matching class is found
778+ * or if the matching class is abstract.
778779 */
779780ObjectClass * cpu_class_by_name (const char * typename , const char * cpu_model );
780781
Original file line number Diff line number Diff line change @@ -126,8 +126,7 @@ static ObjectClass *alpha_cpu_class_by_name(const char *cpu_model)
126126 int i ;
127127
128128 oc = object_class_by_name (cpu_model );
129- if (oc != NULL && object_class_dynamic_cast (oc , TYPE_ALPHA_CPU ) != NULL &&
130- !object_class_is_abstract (oc )) {
129+ if (oc != NULL && object_class_dynamic_cast (oc , TYPE_ALPHA_CPU ) != NULL ) {
131130 return oc ;
132131 }
133132
Original file line number Diff line number Diff line change @@ -2401,8 +2401,7 @@ static ObjectClass *arm_cpu_class_by_name(const char *cpu_model)
24012401 oc = object_class_by_name (typename );
24022402 g_strfreev (cpuname );
24032403 g_free (typename );
2404- if (!oc || !object_class_dynamic_cast (oc , TYPE_ARM_CPU ) ||
2405- object_class_is_abstract (oc )) {
2404+ if (!oc || !object_class_dynamic_cast (oc , TYPE_ARM_CPU )) {
24062405 return NULL ;
24072406 }
24082407 return oc ;
Original file line number Diff line number Diff line change @@ -157,8 +157,7 @@ static ObjectClass *avr_cpu_class_by_name(const char *cpu_model)
157157 ObjectClass * oc ;
158158
159159 oc = object_class_by_name (cpu_model );
160- if (object_class_dynamic_cast (oc , TYPE_AVR_CPU ) == NULL ||
161- object_class_is_abstract (oc )) {
160+ if (object_class_dynamic_cast (oc , TYPE_AVR_CPU ) == NULL ) {
162161 oc = NULL ;
163162 }
164163 return oc ;
Original file line number Diff line number Diff line change @@ -95,8 +95,7 @@ static ObjectClass *cris_cpu_class_by_name(const char *cpu_model)
9595 typename = g_strdup_printf (CRIS_CPU_TYPE_NAME ("%s" ), cpu_model );
9696 oc = object_class_by_name (typename );
9797 g_free (typename );
98- if (oc != NULL && (!object_class_dynamic_cast (oc , TYPE_CRIS_CPU ) ||
99- object_class_is_abstract (oc ))) {
98+ if (oc != NULL && !object_class_dynamic_cast (oc , TYPE_CRIS_CPU )) {
10099 oc = NULL ;
101100 }
102101 return oc ;
Original file line number Diff line number Diff line change @@ -63,8 +63,7 @@ static ObjectClass *hexagon_cpu_class_by_name(const char *cpu_model)
6363 oc = object_class_by_name (typename );
6464 g_strfreev (cpuname );
6565 g_free (typename );
66- if (!oc || !object_class_dynamic_cast (oc , TYPE_HEXAGON_CPU ) ||
67- object_class_is_abstract (oc )) {
66+ if (!oc || !object_class_dynamic_cast (oc , TYPE_HEXAGON_CPU )) {
6867 return NULL ;
6968 }
7069 return oc ;
Original file line number Diff line number Diff line change @@ -721,8 +721,7 @@ static ObjectClass *loongarch_cpu_class_by_name(const char *cpu_model)
721721 }
722722 }
723723
724- if (object_class_dynamic_cast (oc , TYPE_LOONGARCH_CPU )
725- && !object_class_is_abstract (oc )) {
724+ if (object_class_dynamic_cast (oc , TYPE_LOONGARCH_CPU )) {
726725 return oc ;
727726 }
728727 return NULL ;
Original file line number Diff line number Diff line change @@ -111,8 +111,7 @@ static ObjectClass *m68k_cpu_class_by_name(const char *cpu_model)
111111 typename = g_strdup_printf (M68K_CPU_TYPE_NAME ("%s" ), cpu_model );
112112 oc = object_class_by_name (typename );
113113 g_free (typename );
114- if (oc != NULL && (object_class_dynamic_cast (oc , TYPE_M68K_CPU ) == NULL ||
115- object_class_is_abstract (oc ))) {
114+ if (oc != NULL && object_class_dynamic_cast (oc , TYPE_M68K_CPU ) == NULL ) {
116115 return NULL ;
117116 }
118117 return oc ;
Original file line number Diff line number Diff line change @@ -164,8 +164,7 @@ static ObjectClass *openrisc_cpu_class_by_name(const char *cpu_model)
164164 typename = g_strdup_printf (OPENRISC_CPU_TYPE_NAME ("%s" ), cpu_model );
165165 oc = object_class_by_name (typename );
166166 g_free (typename );
167- if (oc != NULL && (!object_class_dynamic_cast (oc , TYPE_OPENRISC_CPU ) ||
168- object_class_is_abstract (oc ))) {
167+ if (oc != NULL && !object_class_dynamic_cast (oc , TYPE_OPENRISC_CPU )) {
169168 return NULL ;
170169 }
171170 return oc ;
You can’t perform that action at this time.
0 commit comments