[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 36/40] spapr/xive: Simplify error handling in kvmppc_xive_connect(
From: |
David Gibson |
Subject: |
[PULL 36/40] spapr/xive: Simplify error handling in kvmppc_xive_connect() |
Date: |
Tue, 18 Aug 2020 14:19:18 +1000 |
From: Greg Kurz <groug@kaod.org>
Now that all these functions return a negative errno on failure, check
that and get rid of the local_err boilerplate.
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <159707851537.1489912.1030839306195472651.stgit@bahia.lan>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/intc/spapr_xive_kvm.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c
index 005729ebff..e9a36115be 100644
--- a/hw/intc/spapr_xive_kvm.c
+++ b/hw/intc/spapr_xive_kvm.c
@@ -723,12 +723,12 @@ int kvmppc_xive_connect(SpaprInterruptController *intc,
uint32_t nr_servers,
{
SpaprXive *xive = SPAPR_XIVE(intc);
XiveSource *xsrc = &xive->source;
- Error *local_err = NULL;
size_t esb_len = xive_source_esb_len(xsrc);
size_t tima_len = 4ull << TM_SHIFT;
CPUState *cs;
int fd;
void *addr;
+ int ret;
/*
* The KVM XIVE device already in use. This is the case when
@@ -754,9 +754,10 @@ int kvmppc_xive_connect(SpaprInterruptController *intc,
uint32_t nr_servers,
/* Tell KVM about the # of VCPUs we may have */
if (kvm_device_check_attr(xive->fd, KVM_DEV_XIVE_GRP_CTRL,
KVM_DEV_XIVE_NR_SERVERS)) {
- if (kvm_device_access(xive->fd, KVM_DEV_XIVE_GRP_CTRL,
- KVM_DEV_XIVE_NR_SERVERS, &nr_servers, true,
- &local_err)) {
+ ret = kvm_device_access(xive->fd, KVM_DEV_XIVE_GRP_CTRL,
+ KVM_DEV_XIVE_NR_SERVERS, &nr_servers, true,
+ errp);
+ if (ret < 0) {
goto fail;
}
}
@@ -764,8 +765,7 @@ int kvmppc_xive_connect(SpaprInterruptController *intc,
uint32_t nr_servers,
/*
* 1. Source ESB pages - KVM mapping
*/
- addr = kvmppc_xive_mmap(xive, KVM_XIVE_ESB_PAGE_OFFSET, esb_len,
- &local_err);
+ addr = kvmppc_xive_mmap(xive, KVM_XIVE_ESB_PAGE_OFFSET, esb_len, errp);
if (addr == MAP_FAILED) {
goto fail;
}
@@ -783,8 +783,7 @@ int kvmppc_xive_connect(SpaprInterruptController *intc,
uint32_t nr_servers,
/*
* 3. TIMA pages - KVM mapping
*/
- addr = kvmppc_xive_mmap(xive, KVM_XIVE_TIMA_PAGE_OFFSET, tima_len,
- &local_err);
+ addr = kvmppc_xive_mmap(xive, KVM_XIVE_TIMA_PAGE_OFFSET, tima_len, errp);
if (addr == MAP_FAILED) {
goto fail;
}
@@ -802,15 +801,15 @@ int kvmppc_xive_connect(SpaprInterruptController *intc,
uint32_t nr_servers,
CPU_FOREACH(cs) {
PowerPCCPU *cpu = POWERPC_CPU(cs);
- kvmppc_xive_cpu_connect(spapr_cpu_state(cpu)->tctx, &local_err);
- if (local_err) {
+ ret = kvmppc_xive_cpu_connect(spapr_cpu_state(cpu)->tctx, errp);
+ if (ret < 0) {
goto fail;
}
}
/* Update the KVM sources */
- kvmppc_xive_source_reset(xsrc, &local_err);
- if (local_err) {
+ ret = kvmppc_xive_source_reset(xsrc, errp);
+ if (ret < 0) {
goto fail;
}
@@ -820,7 +819,6 @@ int kvmppc_xive_connect(SpaprInterruptController *intc,
uint32_t nr_servers,
return 0;
fail:
- error_propagate(errp, local_err);
kvmppc_xive_disconnect(intc);
return -1;
}
--
2.26.2
- [PULL 27/40] spapr/xive: Rework error handling of kvmppc_xive_source_reset(), (continued)
- [PULL 27/40] spapr/xive: Rework error handling of kvmppc_xive_source_reset(), David Gibson, 2020/08/18
- [PULL 26/40] spapr/xive: Rework error handling of kvmppc_xive_cpu_connect(), David Gibson, 2020/08/18
- [PULL 25/40] spapr: Simplify error handling in spapr_phb_realize(), David Gibson, 2020/08/18
- [PULL 29/40] spapr/xive: Rework error handling of kvmppc_xive_cpu_[gs]et_state(), David Gibson, 2020/08/18
- [PULL 28/40] spapr/xive: Rework error handling of kvmppc_xive_mmap(), David Gibson, 2020/08/18
- [PULL 37/40] ppc/xive: Simplify error handling in xive_tctx_realize(), David Gibson, 2020/08/18
- [PULL 30/40] spapr/xive: Rework error handling of kvmppc_xive_[gs]et_queue_config(), David Gibson, 2020/08/18
- [PULL 31/40] spapr/xive: Rework error handling in kvmppc_xive_get_queues(), David Gibson, 2020/08/18
- [PULL 39/40] nvram: Exit QEMU if NVRAM cannot contain all -prom-env data, David Gibson, 2020/08/18
- [PULL 33/40] spapr/kvm: Fix error handling in kvmppc_xive_pre_save(), David Gibson, 2020/08/18
- [PULL 36/40] spapr/xive: Simplify error handling in kvmppc_xive_connect(),
David Gibson <=
- [PULL 38/40] spapr/xive: Simplify error handling of kvmppc_xive_cpu_synchronize_state(), David Gibson, 2020/08/18
- [PULL 32/40] spapr/xive: Rework error handling of kvmppc_xive_set_source_config(), David Gibson, 2020/08/18
- [PULL 35/40] ppc/xive: Fix error handling in vmstate_xive_tctx_*() callbacks, David Gibson, 2020/08/18
- [PULL 34/40] spapr/xive: Fix error handling in kvmppc_xive_post_load(), David Gibson, 2020/08/18
- [PULL 40/40] spapr/xive: Use xive_source_esb_len(), David Gibson, 2020/08/18
- Re: [PULL 00/40] ppc-for-5.2 queue 20200818, Peter Maydell, 2020/08/23
- Re: [PULL 00/40] ppc-for-5.2 queue 20200818, Peter Maydell, 2020/08/24