Patchwork [ppc-next,v2,41/52] target-ppc: Get model name from type name

login
register
mail settings
Submitter Andreas Färber
Date Feb. 18, 2013, 9:16 a.m.
Message ID <1361179011-7226-42-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/221231/
State New
Headers show

Comments

Andreas Färber - Feb. 18, 2013, 9:16 a.m.
We are about to drop the redundant name field along with ppc_def_t.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 target-ppc/translate_init.c |   13 ++++++++++---
 1 Datei geändert, 10 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-)

Patch

diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 868de5d..62391cf 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -9982,9 +9982,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)
@@ -10017,12 +10022,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;