diff options
author | Markus Armbruster <armbru@redhat.com> | 2015-09-11 15:04:45 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2016-01-13 11:58:58 +0100 |
commit | 007b06578ab6063d49b6834d95274c37387a1efb (patch) | |
tree | d8218a5a0b7c377079468333483a8d6576ab6192 /hw/smbios | |
parent | 8d780f43921feb7fd8d0b58f779a22d1265f2378 (diff) | |
download | qemu-007b06578ab6063d49b6834d95274c37387a1efb.tar.gz qemu-007b06578ab6063d49b6834d95274c37387a1efb.tar.bz2 qemu-007b06578ab6063d49b6834d95274c37387a1efb.zip |
Use error_fatal to simplify obvious fatal errors
Done with this Coccinelle semantic patch:
@@
type T;
identifier FUN, RET;
expression list ARGS;
expression ERR, EC;
@@
(
- T RET = FUN(ARGS, &ERR);
+ T RET = FUN(ARGS, &error_fatal);
|
- RET = FUN(ARGS, &ERR);
+ RET = FUN(ARGS, &error_fatal);
|
- FUN(ARGS, &ERR);
+ FUN(ARGS, &error_fatal);
)
- if (ERR != NULL) {
- error_report_err(ERR);
- exit(EC);
- }
This is actually a more elegant version of my initial semantic patch
by courtesy of Eduardo.
It leaves dead Error * variables behind, cleaned up manually.
Cc: qemu-arm@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'hw/smbios')
-rw-r--r-- | hw/smbios/smbios.c | 43 |
1 files changed, 7 insertions, 36 deletions
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index b81a1d349d..a3e575ac79 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -937,7 +937,6 @@ static void save_opt(const char **dest, QemuOpts *opts, const char *name) void smbios_entry_add(QemuOpts *opts) { - Error *local_err = NULL; const char *val; assert(!smbios_immutable); @@ -948,11 +947,7 @@ void smbios_entry_add(QemuOpts *opts) int size; struct smbios_table *table; /* legacy mode only */ - qemu_opts_validate(opts, qemu_smbios_file_opts, &local_err); - if (local_err) { - error_report_err(local_err); - exit(1); - } + qemu_opts_validate(opts, qemu_smbios_file_opts, &error_fatal); size = get_image_size(val); if (size == -1 || size < sizeof(struct smbios_structure_header)) { @@ -1034,11 +1029,7 @@ void smbios_entry_add(QemuOpts *opts) switch (type) { case 0: - qemu_opts_validate(opts, qemu_smbios_type0_opts, &local_err); - if (local_err) { - error_report_err(local_err); - exit(1); - } + qemu_opts_validate(opts, qemu_smbios_type0_opts, &error_fatal); save_opt(&type0.vendor, opts, "vendor"); save_opt(&type0.version, opts, "version"); save_opt(&type0.date, opts, "date"); @@ -1054,11 +1045,7 @@ void smbios_entry_add(QemuOpts *opts) } return; case 1: - qemu_opts_validate(opts, qemu_smbios_type1_opts, &local_err); - if (local_err) { - error_report_err(local_err); - exit(1); - } + qemu_opts_validate(opts, qemu_smbios_type1_opts, &error_fatal); save_opt(&type1.manufacturer, opts, "manufacturer"); save_opt(&type1.product, opts, "product"); save_opt(&type1.version, opts, "version"); @@ -1076,11 +1063,7 @@ void smbios_entry_add(QemuOpts *opts) } return; case 2: - qemu_opts_validate(opts, qemu_smbios_type2_opts, &local_err); - if (local_err) { - error_report_err(local_err); - exit(1); - } + qemu_opts_validate(opts, qemu_smbios_type2_opts, &error_fatal); save_opt(&type2.manufacturer, opts, "manufacturer"); save_opt(&type2.product, opts, "product"); save_opt(&type2.version, opts, "version"); @@ -1089,11 +1072,7 @@ void smbios_entry_add(QemuOpts *opts) save_opt(&type2.location, opts, "location"); return; case 3: - qemu_opts_validate(opts, qemu_smbios_type3_opts, &local_err); - if (local_err) { - error_report_err(local_err); - exit(1); - } + qemu_opts_validate(opts, qemu_smbios_type3_opts, &error_fatal); save_opt(&type3.manufacturer, opts, "manufacturer"); save_opt(&type3.version, opts, "version"); save_opt(&type3.serial, opts, "serial"); @@ -1101,11 +1080,7 @@ void smbios_entry_add(QemuOpts *opts) save_opt(&type3.sku, opts, "sku"); return; case 4: - qemu_opts_validate(opts, qemu_smbios_type4_opts, &local_err); - if (local_err) { - error_report_err(local_err); - exit(1); - } + qemu_opts_validate(opts, qemu_smbios_type4_opts, &error_fatal); save_opt(&type4.sock_pfx, opts, "sock_pfx"); save_opt(&type4.manufacturer, opts, "manufacturer"); save_opt(&type4.version, opts, "version"); @@ -1114,11 +1089,7 @@ void smbios_entry_add(QemuOpts *opts) save_opt(&type4.part, opts, "part"); return; case 17: - qemu_opts_validate(opts, qemu_smbios_type17_opts, &local_err); - if (local_err) { - error_report_err(local_err); - exit(1); - } + qemu_opts_validate(opts, qemu_smbios_type17_opts, &error_fatal); save_opt(&type17.loc_pfx, opts, "loc_pfx"); save_opt(&type17.bank, opts, "bank"); save_opt(&type17.manufacturer, opts, "manufacturer"); |