On 7/25/23 17:31, Gavin Shan wrote:
The logic of checking if the specified CPU type is supported in
machine_run_board_init() is independent enough. Factor it out into
helper is_cpu_type_supported(). With this, machine_run_board_init()
looks a bit clean. Since we're here, @machine_class is renamed to
@mc to avoid multiple line spanning of code. The comments are tweaked
a bit either.

No functional change intended.

Signed-off-by: Gavin Shan <gs...@redhat.com>
---
  hw/core/machine.c | 82 +++++++++++++++++++++++++----------------------
  1 file changed, 44 insertions(+), 38 deletions(-)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index d7e7f8f120..fe110e9b0a 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -1349,12 +1349,50 @@ out:
      return r;
  }
+static void is_cpu_type_supported(MachineState *machine, Error **errp)

Return type bool, false on failure.

+    /* Check if the CPU type is supported */
+    is_cpu_type_supported(machine, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);

Fold call into if, and no need for local_error.


r~

Reply via email to