[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 05/11] vl: Simplify machine_parse()
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PULL 05/11] vl: Simplify machine_parse() |
Date: |
Thu, 25 Apr 2019 14:56:53 -0300 |
From: Markus Armbruster <address@hidden>
Exploit that argument @name is nerver null. Check is_help_option()
first, because that's what we do elsewhere. If we (foolishly!)
defined a machine named "help", -machine help would now print help
instead of selecting the machine named "help".
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Wei Yang <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>
---
vl.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/vl.c b/vl.c
index 69c530a920..4c794f2bf6 100644
--- a/vl.c
+++ b/vl.c
@@ -2576,19 +2576,10 @@ static gint machine_class_cmp(gconstpointer a,
gconstpointer b)
static MachineClass *machine_parse(const char *name, GSList *machines)
{
- MachineClass *mc = NULL;
+ MachineClass *mc;
GSList *el;
- if (name) {
- mc = find_machine(name, machines);
- }
- if (mc) {
- return mc;
- }
- if (name && !is_help_option(name)) {
- error_report("unsupported machine type");
- error_printf("Use -machine help to list supported machines\n");
- } else {
+ if (is_help_option(name)) {
printf("Supported machines are:\n");
machines = g_slist_sort(machines, machine_class_cmp);
for (el = machines; el; el = el->next) {
@@ -2600,9 +2591,16 @@ static MachineClass *machine_parse(const char *name,
GSList *machines)
mc->is_default ? " (default)" : "",
mc->deprecation_reason ? " (deprecated)" : "");
}
+ exit(0);
}
- exit(!name || !is_help_option(name));
+ mc = find_machine(name, machines);
+ if (!mc) {
+ error_report("unsupported machine type");
+ error_printf("Use -machine help to list supported machines\n");
+ exit(1);
+ }
+ return mc;
}
void qemu_add_exit_notifier(Notifier *notify)
--
2.18.0.rc1.1.g3f1ff2140
- [Qemu-devel] [PULL 00/11] Machine queue, 2019-04-25, Eduardo Habkost, 2019/04/25
- [Qemu-devel] [PULL 01/11] hw: add compat machines for 4.1, Eduardo Habkost, 2019/04/25
- [Qemu-devel] [PULL 02/11] vl.c: make find_default_machine() local, Eduardo Habkost, 2019/04/25
- [Qemu-devel] [PULL 03/11] vl.c: allocate TYPE_MACHINE list once during bootup, Eduardo Habkost, 2019/04/25
- [Qemu-devel] [PULL 04/11] vl: Clean up after previous commit, Eduardo Habkost, 2019/04/25
- [Qemu-devel] [PULL 05/11] vl: Simplify machine_parse(),
Eduardo Habkost <=
- [Qemu-devel] [PULL 06/11] cpu: Rename parse_cpu_model() to parse_cpu_option(), Eduardo Habkost, 2019/04/25
- [Qemu-devel] [PULL 07/11] cpu: Fix crash with empty -cpu option, Eduardo Habkost, 2019/04/25
- [Qemu-devel] [PULL 08/11] util/mmap-alloc: Add a 'is_pmem' parameter to qemu_ram_mmap, Eduardo Habkost, 2019/04/25
- [Qemu-devel] [PULL 09/11] scripts/update-linux-headers: add linux/mman.h, Eduardo Habkost, 2019/04/25
- [Qemu-devel] [PULL 10/11] linux-headers: add linux/mman.h., Eduardo Habkost, 2019/04/25
- [Qemu-devel] [PULL 11/11] util/mmap-alloc: support MAP_SYNC in qemu_ram_mmap(), Eduardo Habkost, 2019/04/25
- Re: [Qemu-devel] [PULL 00/11] Machine queue, 2019-04-25, Peter Maydell, 2019/04/26