Patchwork [qom-cpu,for-1.4,08/14] target-unicore32: Detect attempt to instantiate non-CPU type in cpu_init()

login
register
mail settings
Submitter Andreas Färber
Date Jan. 27, 2013, 10:32 p.m.
Message ID <5105AB1A.3040802@suse.de>
Download mbox | patch
Permalink /patch/216073/
State New
Headers show

Comments

Andreas Färber - Jan. 27, 2013, 10:32 p.m.
Am 23.01.2013 13:07, schrieb Andreas Färber:
> diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c
> index 5359538..7ace68c 100644
> --- a/target-unicore32/helper.c
> +++ b/target-unicore32/helper.c
> @@ -29,9 +29,11 @@ CPUUniCore32State *uc32_cpu_init(const char *cpu_model)
>  {
>      UniCore32CPU *cpu;
>      CPUUniCore32State *env;
> +    ObjectClass *oc;
>      static int inited = 1;
>  
> -    if (object_class_by_name(cpu_model) == NULL) {
> +    oc = cpu_class_by_name(TYPE_UNICORE32_CPU, cpu_model);
> +    if (oc == NULL) {
>          return NULL;
>      }
>      cpu = UNICORE32_CPU(object_new(cpu_model));

Should be using object_class_get_name(oc) instead of cpu_model:


Fixed.

Andreas

Patch

diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c
index 7ace68c..183b5b3 100644
--- a/target-unicore32/helper.c
+++ b/target-unicore32/helper.c
@@ -36,7 +36,7 @@  CPUUniCore32State *uc32_cpu_init(const char *cpu_model)
     if (oc == NULL) {
         return NULL;
     }
-    cpu = UNICORE32_CPU(object_new(cpu_model));
+    cpu = UNICORE32_CPU(object_new(object_class_get_name(oc)));
     env = &cpu->env;

     if (inited) {