[PATCH 2/6] qemuMigrationCookieNew: Refactor allocation and cleanup
Ján Tomko
jtomko at redhat.com
Tue Sep 29 15:10:28 UTC 2020
On a Tuesday in 2020, Peter Krempa wrote:
>Move around some code so that we can get rid of the 'cleanup:' label.
>
>Signed-off-by: Peter Krempa <pkrempa at redhat.com>
>---
> src/qemu/qemu_migration_cookie.c | 35 ++++++++++++++++----------------
> 1 file changed, 17 insertions(+), 18 deletions(-)
>
>diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
>index 124f61e3ea..a04b74f092 100644
>--- a/src/qemu/qemu_migration_cookie.c
>+++ b/src/qemu/qemu_migration_cookie.c
>@@ -280,31 +280,30 @@ qemuMigrationCookieNew(const virDomainDef *def,
> const char *origname)
> {
> qemuMigrationCookiePtr mig = NULL;
>- const char *name;
>+ unsigned char localHostUUID[VIR_UUID_BUFLEN];
>+ g_autofree char *localHostname = NULL;
>
>- if (VIR_ALLOC(mig) < 0)
>- goto error;
>-
>- if (origname)
>- name = origname;
>- else
>- name = def->name;
>- mig->name = g_strdup(name);
>- memcpy(mig->uuid, def->uuid, VIR_UUID_BUFLEN);
>+ if (!(localHostname = virGetHostname()))
>+ return NULL;
>
>- if (!(mig->localHostname = virGetHostname()))
>- goto error;
Note that as of:
commit 26d9748ff114a060ee751959d108d062f737f5d9
util: replace gethostname() with g_get_hostname()
the virGetHostname function always g_strdup's something.
>- if (virGetHostUUID(mig->localHostuuid) < 0) {
>+ if (virGetHostUUID(localHostUUID) < 0) {
> virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> _("Unable to obtain host UUID"));
>- goto error;
>+ return NULL;
> }
>
>- return mig;
>+ mig = g_new0(qemuMigrationCookie, 1);
>
Reviewed-by: Ján Tomko <jtomko at redhat.com>
Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20200929/cd91980b/attachment-0001.sig>
More information about the libvir-list
mailing list