Use error_fatal to simplify obvious fatal errors (again)

Add a slight improvement of the Coccinelle semantic patch from commit
007b06578a, and use it to clean up.  It leaves dead Error * variables
behind, cleaned up manually.

Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Alexander Graf <agraf@suse.de>
Cc: Eric Blake <eblake@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Message-Id: <20181017082702.5581-3-armbru@redhat.com>
This commit is contained in:
Markus Armbruster 2018-10-17 10:26:26 +02:00
parent 4b5766488f
commit 50beeb6809
4 changed files with 23 additions and 17 deletions

View File

@ -198,17 +198,12 @@ static void ics_get_kvm_state(ICSState *ics)
{ {
uint64_t state; uint64_t state;
int i; int i;
Error *local_err = NULL;
for (i = 0; i < ics->nr_irqs; i++) { for (i = 0; i < ics->nr_irqs; i++) {
ICSIRQState *irq = &ics->irqs[i]; ICSIRQState *irq = &ics->irqs[i];
kvm_device_access(kernel_xics_fd, KVM_DEV_XICS_GRP_SOURCES, kvm_device_access(kernel_xics_fd, KVM_DEV_XICS_GRP_SOURCES,
i + ics->offset, &state, false, &local_err); i + ics->offset, &state, false, &error_fatal);
if (local_err) {
error_report_err(local_err);
exit(1);
}
irq->server = state & KVM_XICS_DESTINATION_MASK; irq->server = state & KVM_XICS_DESTINATION_MASK;
irq->saved_priority = (state >> KVM_XICS_PRIORITY_SHIFT) irq->saved_priority = (state >> KVM_XICS_PRIORITY_SHIFT)

View File

@ -1002,11 +1002,7 @@ int main(int argc, char **argv)
} }
exp = nbd_export_new(bs, dev_offset, fd_size, nbdflags, nbd_export_closed, exp = nbd_export_new(bs, dev_offset, fd_size, nbdflags, nbd_export_closed,
writethrough, NULL, &local_err); writethrough, NULL, &error_fatal);
if (!exp) {
error_report_err(local_err);
exit(EXIT_FAILURE);
}
nbd_export_set_name(exp, export_name); nbd_export_set_name(exp, export_name);
nbd_export_set_description(exp, export_description); nbd_export_set_description(exp, export_description);

View File

@ -0,0 +1,20 @@
@@
type T;
identifier FUN, RET;
expression list ARGS;
expression ERR, EC, FAIL;
@@
(
- 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 (FAIL) {
- error_report_err(ERR);
- exit(EC);
- }

7
vl.c
View File

@ -2002,15 +2002,10 @@ static void select_vgahw(const char *p)
static void parse_display_qapi(const char *optarg) static void parse_display_qapi(const char *optarg)
{ {
Error *err = NULL;
DisplayOptions *opts; DisplayOptions *opts;
Visitor *v; Visitor *v;
v = qobject_input_visitor_new_str(optarg, "type", &err); v = qobject_input_visitor_new_str(optarg, "type", &error_fatal);
if (!v) {
error_report_err(err);
exit(1);
}
visit_type_DisplayOptions(v, NULL, &opts, &error_fatal); visit_type_DisplayOptions(v, NULL, &opts, &error_fatal);
QAPI_CLONE_MEMBERS(DisplayOptions, &dpy, opts); QAPI_CLONE_MEMBERS(DisplayOptions, &dpy, opts);