May be a matter of a taste but this version with one return point in every function looks simplier to understand and to extend too. Anyway after such a heavy refactoring a little cleanup will not hurt. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx> --- src/libvirt-domain.c | 61 +++++++++++++++++++++++--------------------------- 1 files changed, 28 insertions(+), 33 deletions(-) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index fc61830..f012f4b 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -4242,6 +4242,7 @@ virDomainMigrateToURI(virDomainPtr domain, const char *dname, unsigned long bandwidth) { + int ret = -1; const char *dconnuri = NULL; const char *miguri = NULL; @@ -4252,26 +4253,24 @@ virDomainMigrateToURI(virDomainPtr domain, /* First checkout the source */ virCheckDomainReturn(domain, -1); - virCheckReadOnlyGoto(domain->conn->flags, error); - virCheckNonNullArgGoto(duri, error); + virCheckReadOnlyGoto(domain->conn->flags, cleanup); + virCheckNonNullArgGoto(duri, cleanup); if (virDomainMigrateUnmanagedCheckCompat(domain, flags) < 0) - goto error; + goto cleanup; if (flags & VIR_MIGRATE_PEER2PEER) dconnuri = duri; else miguri = duri; - if (virDomainMigrateUnmanaged(domain, NULL, flags, - dname, dconnuri, miguri, bandwidth) < 0) - goto error; - - return 0; + ret = virDomainMigrateUnmanaged(domain, NULL, flags, + dname, dconnuri, miguri, bandwidth); + cleanup: + if (ret < 0) + virDispatchError(domain->conn); - error: - virDispatchError(domain->conn); - return -1; + return ret; } @@ -4370,6 +4369,7 @@ virDomainMigrateToURI2(virDomainPtr domain, const char *dname, unsigned long bandwidth) { + int ret = -1; VIR_DOMAIN_DEBUG(domain, "dconnuri=%s, miguri=%s, dxml=%s, " "flags=%lx, dname=%s, bandwidth=%lu", NULLSTR(dconnuri), NULLSTR(miguri), NULLSTR(dxml), @@ -4379,23 +4379,20 @@ virDomainMigrateToURI2(virDomainPtr domain, /* First checkout the source */ virCheckDomainReturn(domain, -1); - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckReadOnlyGoto(domain->conn->flags, cleanup); if (virDomainMigrateUnmanagedCheckCompat(domain, flags) < 0) - goto error; + goto cleanup; if (!(flags & VIR_MIGRATE_PEER2PEER)) dconnuri = NULL; - if (virDomainMigrateUnmanaged(domain, NULL, flags, - dname, dconnuri, miguri, bandwidth) < 0) - goto error; - - return 0; - - error: - virDispatchError(domain->conn); - return -1; + ret = virDomainMigrateUnmanaged(domain, NULL, flags, + dname, dconnuri, miguri, bandwidth); + cleanup: + if (ret < 0) + virDispatchError(domain->conn); + return ret; } @@ -4443,6 +4440,7 @@ virDomainMigrateToURI3(virDomainPtr domain, unsigned int nparams, unsigned int flags) { + int ret = -1; VIR_DOMAIN_DEBUG(domain, "dconnuri=%s, params=%p, nparms=%u flags=%x", NULLSTR(dconnuri), params, nparams, flags); VIR_TYPED_PARAMS_DEBUG(params, nparams); @@ -4451,23 +4449,20 @@ virDomainMigrateToURI3(virDomainPtr domain, /* First checkout the source */ virCheckDomainReturn(domain, -1); - virCheckReadOnlyGoto(domain->conn->flags, error); + virCheckReadOnlyGoto(domain->conn->flags, cleanup); if (virDomainMigrateUnmanagedCheckCompat(domain, flags) < 0) - goto error; + goto cleanup; if (!(flags & VIR_MIGRATE_PEER2PEER)) dconnuri = NULL; - if (virDomainMigrateUnmanagedParams(domain, dconnuri, - params, nparams, flags) < -1) - goto error; - - return 0; - - error: - virDispatchError(domain->conn); - return -1; + ret = virDomainMigrateUnmanagedParams(domain, dconnuri, + params, nparams, flags); + cleanup: + if (ret < 0) + virDispatchError(domain->conn); + return ret; } -- 1.7.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list