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:
parent
4b5766488f
commit
50beeb6809
@ -198,17 +198,12 @@ static void ics_get_kvm_state(ICSState *ics)
|
||||
{
|
||||
uint64_t state;
|
||||
int i;
|
||||
Error *local_err = NULL;
|
||||
|
||||
for (i = 0; i < ics->nr_irqs; i++) {
|
||||
ICSIRQState *irq = &ics->irqs[i];
|
||||
|
||||
kvm_device_access(kernel_xics_fd, KVM_DEV_XICS_GRP_SOURCES,
|
||||
i + ics->offset, &state, false, &local_err);
|
||||
if (local_err) {
|
||||
error_report_err(local_err);
|
||||
exit(1);
|
||||
}
|
||||
i + ics->offset, &state, false, &error_fatal);
|
||||
|
||||
irq->server = state & KVM_XICS_DESTINATION_MASK;
|
||||
irq->saved_priority = (state >> KVM_XICS_PRIORITY_SHIFT)
|
||||
|
@ -1002,11 +1002,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
exp = nbd_export_new(bs, dev_offset, fd_size, nbdflags, nbd_export_closed,
|
||||
writethrough, NULL, &local_err);
|
||||
if (!exp) {
|
||||
error_report_err(local_err);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
writethrough, NULL, &error_fatal);
|
||||
nbd_export_set_name(exp, export_name);
|
||||
nbd_export_set_description(exp, export_description);
|
||||
|
||||
|
20
scripts/coccinelle/use-error_fatal.cocci
Normal file
20
scripts/coccinelle/use-error_fatal.cocci
Normal 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
7
vl.c
@ -2002,15 +2002,10 @@ static void select_vgahw(const char *p)
|
||||
|
||||
static void parse_display_qapi(const char *optarg)
|
||||
{
|
||||
Error *err = NULL;
|
||||
DisplayOptions *opts;
|
||||
Visitor *v;
|
||||
|
||||
v = qobject_input_visitor_new_str(optarg, "type", &err);
|
||||
if (!v) {
|
||||
error_report_err(err);
|
||||
exit(1);
|
||||
}
|
||||
v = qobject_input_visitor_new_str(optarg, "type", &error_fatal);
|
||||
|
||||
visit_type_DisplayOptions(v, NULL, &opts, &error_fatal);
|
||||
QAPI_CLONE_MEMBERS(DisplayOptions, &dpy, opts);
|
||||
|
Loading…
Reference in New Issue
Block a user