libvirt-domain.c: modernize virDomainMigrateVersion1

Use g_autofree on strings and remove the 'done' label since it's
now unneeded.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Daniel Henrique Barboza 2020-07-13 06:49:34 -03:00 committed by Michal Privoznik
parent fe14a62121
commit 37fce4c2ef

View File

@ -2726,9 +2726,8 @@ virDomainMigrateVersion1(virDomainPtr domain,
const char *uri, const char *uri,
unsigned long bandwidth) unsigned long bandwidth)
{ {
virDomainPtr ddomain = NULL; g_autofree char *uri_out = NULL;
char *uri_out = NULL; g_autofree char *cookie = NULL;
char *cookie = NULL;
int cookielen = 0, ret; int cookielen = 0, ret;
virDomainInfo info; virDomainInfo info;
unsigned int destflags; unsigned int destflags;
@ -2758,12 +2757,12 @@ virDomainMigrateVersion1(virDomainPtr domain,
if (dconn->driver->domainMigratePrepare if (dconn->driver->domainMigratePrepare
(dconn, &cookie, &cookielen, uri, &uri_out, destflags, dname, (dconn, &cookie, &cookielen, uri, &uri_out, destflags, dname,
bandwidth) == -1) bandwidth) == -1)
goto done; return NULL;
if (uri == NULL && uri_out == NULL) { if (uri == NULL && uri_out == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domainMigratePrepare did not set uri")); _("domainMigratePrepare did not set uri"));
goto done; return NULL;
} }
if (uri_out) if (uri_out)
uri = uri_out; /* Did domainMigratePrepare change URI? */ uri = uri_out; /* Did domainMigratePrepare change URI? */
@ -2773,7 +2772,7 @@ virDomainMigrateVersion1(virDomainPtr domain,
*/ */
if (domain->conn->driver->domainMigratePerform if (domain->conn->driver->domainMigratePerform
(domain, cookie, cookielen, uri, flags, dname, bandwidth) == -1) (domain, cookie, cookielen, uri, flags, dname, bandwidth) == -1)
goto done; return NULL;
/* Get the destination domain and return it or error. /* Get the destination domain and return it or error.
* 'domain' no longer actually exists at this point * 'domain' no longer actually exists at this point
@ -2782,15 +2781,10 @@ virDomainMigrateVersion1(virDomainPtr domain,
*/ */
dname = dname ? dname : domain->name; dname = dname ? dname : domain->name;
if (dconn->driver->domainMigrateFinish) if (dconn->driver->domainMigrateFinish)
ddomain = dconn->driver->domainMigrateFinish return dconn->driver->domainMigrateFinish
(dconn, dname, cookie, cookielen, uri, destflags); (dconn, dname, cookie, cookielen, uri, destflags);
else
ddomain = virDomainLookupByName(dconn, dname);
done: return virDomainLookupByName(dconn, dname);
VIR_FREE(uri_out);
VIR_FREE(cookie);
return ddomain;
} }