diff mbox series

[for-7.1,2/4] target/loongarch: Trim type name suffix in -cpu help output

Message ID 20220814145522.1474927-3-i.qemu@xen0n.name
State New
Headers show
Series Last-minute LoongArch CPU model naming tweaks | expand

Commit Message

WANG Xuerui Aug. 14, 2022, 2:55 p.m. UTC
From: WANG Xuerui <git@xen0n.name>

Also add a header and indentation for each entry, while at it.

Signed-off-by: WANG Xuerui <git@xen0n.name>
---
 target/loongarch/cpu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Richard Henderson Aug. 14, 2022, 8:45 p.m. UTC | #1
On 8/14/22 09:55, WANG Xuerui wrote:
> From: WANG Xuerui <git@xen0n.name>
> 
> Also add a header and indentation for each entry, while at it.
> 
> Signed-off-by: WANG Xuerui <git@xen0n.name>
> ---
>   target/loongarch/cpu.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
> index dc233ee209..4663539443 100644
> --- a/target/loongarch/cpu.c
> +++ b/target/loongarch/cpu.c
> @@ -416,13 +416,15 @@ static void loongarch_la464_initfn(Object *obj)
>   static void loongarch_cpu_list_entry(gpointer data, gpointer user_data)
>   {
>       const char *typename = object_class_get_name(OBJECT_CLASS(data));
> +    int len = strlen(typename) - strlen(LOONGARCH_CPU_TYPE_SUFFIX);
>   
> -    qemu_printf("%s\n", typename);
> +    qemu_printf("  %.*s\n", len, typename);
>   }
>   
>   void loongarch_cpu_list(void)
>   {
>       GSList *list;
> +    qemu_printf("Available CPUs:\n");
>       list = object_class_get_list_sorted(TYPE_LOONGARCH_CPU, false);
>       g_slist_foreach(list, loongarch_cpu_list_entry, NULL);
>       g_slist_free(list);

This should be merged with the previous patch, so that we don't have an intermediate state 
where help and loongarch_cpu_class_by_name disagree.


r~
diff mbox series

Patch

diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index dc233ee209..4663539443 100644
--- a/target/loongarch/cpu.c
+++ b/target/loongarch/cpu.c
@@ -416,13 +416,15 @@  static void loongarch_la464_initfn(Object *obj)
 static void loongarch_cpu_list_entry(gpointer data, gpointer user_data)
 {
     const char *typename = object_class_get_name(OBJECT_CLASS(data));
+    int len = strlen(typename) - strlen(LOONGARCH_CPU_TYPE_SUFFIX);
 
-    qemu_printf("%s\n", typename);
+    qemu_printf("  %.*s\n", len, typename);
 }
 
 void loongarch_cpu_list(void)
 {
     GSList *list;
+    qemu_printf("Available CPUs:\n");
     list = object_class_get_list_sorted(TYPE_LOONGARCH_CPU, false);
     g_slist_foreach(list, loongarch_cpu_list_entry, NULL);
     g_slist_free(list);