diff mbox series

[v20,05/24] target/rx: simplify rx_cpu_class_by_name

Message ID 20190616142836.10614-6-ysato@users.sourceforge.jp (mailing list archive)
State New, archived
Headers show
Series Add RX archtecture support | expand

Commit Message

Yoshinori Sato June 16, 2019, 2:28 p.m. UTC
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
---
 target/rx/cpu.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)

Comments

Igor Mammedov June 16, 2019, 6:33 p.m. UTC | #1
On Sun, 16 Jun 2019 23:28:17 +0900
Yoshinori Sato <ysato@users.sourceforge.jp> wrote:

> Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
THere is no point in sending it as separate patch,
If you'd merged this patch into 3/24 I'd ack it.
So pls merge it there.

> ---
>  target/rx/cpu.c | 20 +++-----------------
>  1 file changed, 3 insertions(+), 17 deletions(-)
> 
> diff --git a/target/rx/cpu.c b/target/rx/cpu.c
> index a6dde613ab..e3d76af55d 100644
> --- a/target/rx/cpu.c
> +++ b/target/rx/cpu.c
> @@ -72,9 +72,8 @@ static void rx_cpu_reset(CPUState *s)
>  static void rx_cpu_list_entry(gpointer data, gpointer user_data)
>  {
>      const char *typename = object_class_get_name(OBJECT_CLASS(data));
> -    int len = strlen(typename) - strlen(RX_CPU_TYPE_SUFFIX);
>  
> -    qemu_printf("%.*s\n", len, typename);
> +    qemu_printf("%s\n", typename);
>  }
>  
>  void rx_cpu_list(void)
> @@ -88,25 +87,12 @@ void rx_cpu_list(void)
>  static ObjectClass *rx_cpu_class_by_name(const char *cpu_model)
>  {
>      ObjectClass *oc;
> -    char *typename;
>  
>      oc = object_class_by_name(cpu_model);
> -    if (oc != NULL && object_class_dynamic_cast(oc, TYPE_RX_CPU) != NULL &&
> -        !object_class_is_abstract(oc)) {
> -        return oc;
> -    }
> -
> -    typename = g_strdup_printf(RX_CPU_TYPE_NAME("%s"), cpu_model);
> -    oc = object_class_by_name(typename);
> -    if (oc != NULL && object_class_is_abstract(oc)) {
> +    if (object_class_dynamic_cast(oc, TYPE_RX_CPU) == NULL ||
> +        object_class_is_abstract(oc)) {
>          oc = NULL;
>      }
> -    g_free(typename);
> -
> -    if (!oc) {
> -        /* default to rx62n */
> -        oc = object_class_by_name(TYPE_RX62N_CPU);
> -    }
>  
>      return oc;
>  }
diff mbox series

Patch

diff --git a/target/rx/cpu.c b/target/rx/cpu.c
index a6dde613ab..e3d76af55d 100644
--- a/target/rx/cpu.c
+++ b/target/rx/cpu.c
@@ -72,9 +72,8 @@  static void rx_cpu_reset(CPUState *s)
 static void rx_cpu_list_entry(gpointer data, gpointer user_data)
 {
     const char *typename = object_class_get_name(OBJECT_CLASS(data));
-    int len = strlen(typename) - strlen(RX_CPU_TYPE_SUFFIX);
 
-    qemu_printf("%.*s\n", len, typename);
+    qemu_printf("%s\n", typename);
 }
 
 void rx_cpu_list(void)
@@ -88,25 +87,12 @@  void rx_cpu_list(void)
 static ObjectClass *rx_cpu_class_by_name(const char *cpu_model)
 {
     ObjectClass *oc;
-    char *typename;
 
     oc = object_class_by_name(cpu_model);
-    if (oc != NULL && object_class_dynamic_cast(oc, TYPE_RX_CPU) != NULL &&
-        !object_class_is_abstract(oc)) {
-        return oc;
-    }
-
-    typename = g_strdup_printf(RX_CPU_TYPE_NAME("%s"), cpu_model);
-    oc = object_class_by_name(typename);
-    if (oc != NULL && object_class_is_abstract(oc)) {
+    if (object_class_dynamic_cast(oc, TYPE_RX_CPU) == NULL ||
+        object_class_is_abstract(oc)) {
         oc = NULL;
     }
-    g_free(typename);
-
-    if (!oc) {
-        /* default to rx62n */
-        oc = object_class_by_name(TYPE_RX62N_CPU);
-    }
 
     return oc;
 }