Patchwork [43/66] target-ppc: Get model name from type name

login
register
mail settings
Submitter Alexander Graf
Date March 8, 2013, 8:06 p.m.
Message ID <1362773228-1747-44-git-send-email-agraf@suse.de>
Download mbox | patch
Permalink /patch/226280/
State New
Headers show

Comments

Alexander Graf - March 8, 2013, 8:06 p.m.
From: Andreas Färber <afaerber@suse.de>

We are about to drop the redundant name field along with ppc_def_t.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 target-ppc/translate_init.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

Patch

diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 9d4831f..7eb565d 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -9979,9 +9979,14 @@  static void ppc_cpu_list_entry(gpointer data, gpointer user_data)
     ObjectClass *oc = data;
     CPUListState *s = user_data;
     PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
+    const char *typename = object_class_get_name(oc);
+    char *name;
 
+    name = g_strndup(typename,
+                     strlen(typename) - strlen("-" TYPE_POWERPC_CPU));
     (*s->cpu_fprintf)(s->file, "PowerPC %-16s PVR %08x\n",
-                      pcc->info->name, pcc->info->pvr);
+                      name, pcc->info->pvr);
+    g_free(name);
 }
 
 void ppc_cpu_list(FILE *f, fprintf_function cpu_fprintf)
@@ -10014,12 +10019,14 @@  static void ppc_cpu_defs_entry(gpointer data, gpointer user_data)
 {
     ObjectClass *oc = data;
     CpuDefinitionInfoList **first = user_data;
-    PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
+    const char *typename;
     CpuDefinitionInfoList *entry;
     CpuDefinitionInfo *info;
 
+    typename = object_class_get_name(oc);
     info = g_malloc0(sizeof(*info));
-    info->name = g_strdup(pcc->info->name);
+    info->name = g_strndup(typename,
+                           strlen(typename) - strlen("-" TYPE_POWERPC_CPU));
 
     entry = g_malloc0(sizeof(*entry));
     entry->value = info;