]> git.proxmox.com Git - mirror_qemu.git/commit
machine: Improve is_cpu_type_supported()
authorGavin Shan <gshan@redhat.com>
Mon, 4 Dec 2023 00:47:20 +0000 (10:47 +1000)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Fri, 5 Jan 2024 15:20:15 +0000 (16:20 +0100)
commite702cbc19e6bc04685a48f9e07cbf74bf4d53042
treeab8c42ff294a887d07f4a5984a1b3b494c56756d
parentacbadc5a29b957d525dd89d668bfc939ac1f8bb8
machine: Improve is_cpu_type_supported()

It's no sense to check the CPU type when mc->valid_cpu_types[0] is
NULL, which is a program error. Raise an assert on this.

A precise hint for the error message is given when mc->valid_cpu_types[0]
is the only valid entry. Besides, enumeration on mc->valid_cpu_types[0]
when we have mutiple valid entries there is avoided to increase the code
readability, as suggested by Philippe Mathieu-Daudé.

Besides, @cc comes from machine->cpu_type or mc->default_cpu_type. For
the later case, it can be NULL and it's also a program error. We should
use assert() in this case.

Signed-off-by: Gavin Shan <gshan@redhat.com>
Message-ID: <20231204004726.483558-4-gshan@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
hw/core/machine.c