qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 03/26] hw/ppc: Avoid using Monitor in xive_tctx_pic_print_inf


From: Harsh Prateek Bora
Subject: Re: [PATCH 03/26] hw/ppc: Avoid using Monitor in xive_tctx_pic_print_info()
Date: Mon, 17 Jun 2024 15:49:53 +0530
User-agent: Mozilla Thunderbird

Hi Phillipe,

On 6/10/24 11:50, Philippe Mathieu-Daudé wrote:
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index fa23b27a2b..5854358f65 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -1223,7 +1223,13 @@ static void pnv_chip_power9_intc_destroy(PnvChip *chip, 
PowerPCCPU *cpu)
  static void pnv_chip_power9_intc_print_info(PnvChip *chip, PowerPCCPU *cpu,
                                              Monitor *mon)
  {
-    xive_tctx_pic_print_info(XIVE_TCTX(pnv_cpu_state(cpu)->intc), mon);
+    g_autoptr(GString) buf = g_string_new("");
+    g_autoptr(HumanReadableText) info = NULL;
+
+    xive_tctx_pic_print_info(XIVE_TCTX(pnv_cpu_state(cpu)->intc), buf);
+
+    info = human_readable_text_from_str(buf);
+    monitor_puts(mon, info->human_readable_text);
  }
static void pnv_chip_power10_intc_create(PnvChip *chip, PowerPCCPU *cpu,
@@ -1267,7 +1273,13 @@ static void pnv_chip_power10_intc_destroy(PnvChip *chip, 
PowerPCCPU *cpu)
  static void pnv_chip_power10_intc_print_info(PnvChip *chip, PowerPCCPU *cpu,
                                               Monitor *mon)
  {
-    xive_tctx_pic_print_info(XIVE_TCTX(pnv_cpu_state(cpu)->intc), mon);
+    g_autoptr(GString) buf = g_string_new("");
+    g_autoptr(HumanReadableText) info = NULL;
+
+    xive_tctx_pic_print_info(XIVE_TCTX(pnv_cpu_state(cpu)->intc), buf);
+
+    info = human_readable_text_from_str(buf);
+    monitor_puts(mon, info->human_readable_text);
  }

We have an existing code duplication in above two routines which is getting worse with these multi-lines getting duplicated. Could _power9_ be changed to inline and called from _power10_ as well?

Thanks
Harsh



reply via email to

[Prev in Thread] Current Thread [Next in Thread]