From nobody Sun Feb 8 12:13:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601850244; cv=none; d=zohomail.com; s=zohoarc; b=LdbrHnrmMKA6XPlC6fTokoGFQdEG1eBbvlnEH1N76aJzFwTCDcVzfKP7mQK4oxEMa2nbK2DRj1Em684JZY9Pq0YwHG6TWW3OZYVf467ZU/m275m1lfsKpwYwkHZvYtD6vR4rGAJg2la/zd0oqD1QU3u9x1dmTlDLcI0LzPZML6A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601850244; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/+32GAMFz0AhhA46q3Neaggzi/vXzuFPBEjZCwvRM0s=; b=msVjsQmNL8qMxLU5v4vWxlhn78f5LhbQntzRVn8R+qnznawcfEXCBzchpcdWdaUGGs7vORmYMgT7cbi/F4/Buqm8n0/VB8YE1oPlJXRHInDplUrH3GWjAh26oEzsS0LUPNIEYuuYHn92xlt2RDOLtgyEJCnVv9cXOYAxRBwPlz4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1601850244339221.9268996042731; Sun, 4 Oct 2020 15:24:04 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-335-h0xOt_ksPYShrT0Fgxgxyw-1; Sun, 04 Oct 2020 18:23:02 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A76D11DDF4; Sun, 4 Oct 2020 22:22:56 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8346F19D7C; Sun, 4 Oct 2020 22:22:56 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 509CD181A869; Sun, 4 Oct 2020 22:22:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 094MMsgO031640 for ; Sun, 4 Oct 2020 18:22:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id BE21355789; Sun, 4 Oct 2020 22:22:54 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FF4155797 for ; Sun, 4 Oct 2020 22:22:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601850243; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=/+32GAMFz0AhhA46q3Neaggzi/vXzuFPBEjZCwvRM0s=; b=fNKssjVeTmP8c6v4hM8RSzx1rCMDnenTmwYKvzKkRGlEbFo66tg9oSsMeFc2EerJ783XbQ dHUS8CmHoLa0060Ag1LAzpGN5/Up1E7IvpQ3DAvhoeg+8uN30gX3fzjJT+K99DvyknOsup y2Qw5GZCtCjlNABVrAQ1Vpzp3aQK/0k= X-MC-Unique: h0xOt_ksPYShrT0Fgxgxyw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 4/4] vbox: use g_new0 instead of VIR_ALLOC Date: Mon, 5 Oct 2020 00:22:26 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/vbox/vbox_common.c | 90 +++++++++++------------------------ src/vbox/vbox_network.c | 13 ++--- src/vbox/vbox_snapshot_conf.c | 48 ++++++++----------- 3 files changed, 53 insertions(+), 98 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index f59af697ea..317fb5ce92 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3010,8 +3010,7 @@ vboxHostDeviceGetXMLDesc(vboxDriverPtr data, virDomai= nDefPtr def, IMachine *mach goto release_filters; =20 /* Alloc mem needed for the filters now */ - if (VIR_ALLOC_N(def->hostdevs, def->nhostdevs) < 0) - goto release_filters; + def->hostdevs =3D g_new0(virDomainHostdevDefPtr, def->nhostdevs); =20 for (i =3D 0; i < def->nhostdevs; i++) { def->hostdevs[i] =3D virDomainHostdevDefNew(); @@ -3219,8 +3218,7 @@ vboxDumpDisks(virDomainDefPtr def, vboxDriverPtr data= , IMachine *machine) } =20 /* Allocate mem, if fails return error */ - if (VIR_ALLOC_N(def->disks, def->ndisks) < 0) - goto cleanup; + def->disks =3D g_new0(virDomainDiskDefPtr, def->ndisks); =20 for (i =3D 0; i < def->ndisks; i++) { disk =3D virDomainDiskDefNew(NULL); @@ -3452,12 +3450,10 @@ vboxDumpVideo(virDomainDefPtr def, vboxDriverPtr da= ta G_GNUC_UNUSED, PRBool accelerate2DEnabled =3D PR_FALSE; =20 /* Currently supports only one graphics card */ - if (VIR_ALLOC_N(def->videos, 1) < 0) - return -1; + def->videos =3D g_new0(virDomainVideoDefPtr, 1); def->nvideos =3D 1; =20 - if (VIR_ALLOC(def->videos[0]) < 0) - return -1; + def->videos[0] =3D g_new0(virDomainVideoDef, 1); =20 gVBoxAPI.UIMachine.GetVRAMSize(machine, &VRAMSize); gVBoxAPI.UIMachine.GetMonitorCount(machine, &monitorCount); @@ -3467,8 +3463,7 @@ vboxDumpVideo(virDomainDefPtr def, vboxDriverPtr data= G_GNUC_UNUSED, def->videos[0]->type =3D VIR_DOMAIN_VIDEO_TYPE_VBOX; def->videos[0]->vram =3D VRAMSize * 1024; def->videos[0]->heads =3D monitorCount; - if (VIR_ALLOC(def->videos[0]->accel) < 0) - return -1; + def->videos[0]->accel =3D g_new0(virDomainVideoAccelDef, 1); def->videos[0]->accel->accel3d =3D accelerate3DEnabled ? VIR_TRISTATE_BOOL_YES : VIR_TRISTATE_BOOL_NO; def->videos[0]->accel->accel2d =3D accelerate2DEnabled ? @@ -3506,8 +3501,7 @@ vboxDumpDisplay(virDomainDefPtr def, vboxDriverPtr da= ta, IMachine *machine) PRUnichar *valueDisplayUtf16 =3D NULL; char *valueDisplayUtf8 =3D NULL; =20 - if (VIR_ALLOC(graphics) < 0) - goto cleanup; + graphics =3D g_new0(virDomainGraphicsDef, 1); =20 VBOX_UTF8_TO_UTF16("FRONTEND/Display", &keyUtf16); gVBoxAPI.UIMachine.GetExtraData(machine, keyUtf16, &valueDisplayUt= f16); @@ -3534,8 +3528,7 @@ vboxDumpDisplay(virDomainDefPtr def, vboxDriverPtr da= ta, IMachine *machine) } VBOX_UTF8_FREE(valueDisplayUtf8); } else if (STRNEQ_NULLABLE(valueTypeUtf8, "vrdp")) { - if (VIR_ALLOC(graphics) < 0) - goto cleanup; + graphics =3D g_new0(virDomainGraphicsDef, 1); =20 graphics->type =3D VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP; graphics->data.desktop.display =3D g_strdup(getenv("DISPLAY")); @@ -3554,8 +3547,7 @@ vboxDumpDisplay(virDomainDefPtr def, vboxDriverPtr da= ta, IMachine *machine) PRBool allowMultiConnection =3D PR_FALSE; PRBool reuseSingleConnection =3D PR_FALSE; =20 - if (VIR_ALLOC(graphics) < 0) - goto cleanup; + graphics =3D g_new0(virDomainGraphicsDef, 1); =20 gVBoxAPI.UIVRDEServer.GetPorts(data, VRDEServer, machine, graphics= ); =20 @@ -3612,8 +3604,7 @@ vboxDumpSharedFolders(virDomainDefPtr def, vboxDriver= Ptr data, IMachine *machine goto cleanup; } =20 - if (VIR_ALLOC_N(def->fss, sharedFolders.count) < 0) - goto cleanup; + def->fss =3D g_new0(virDomainFSDefPtr, sharedFolders.count); =20 for (i =3D 0; i < sharedFolders.count; i++) { ISharedFolder *sharedFolder =3D sharedFolders.items[i]; @@ -3798,10 +3789,8 @@ vboxDumpAudio(virDomainDefPtr def, vboxDriverPtr dat= a G_GNUC_UNUSED, PRUint32 audioController =3D AudioControllerType_AC97; =20 def->nsounds =3D 1; - if (VIR_ALLOC_N(def->sounds, def->nsounds) < 0) - return; - if (VIR_ALLOC(def->sounds[0]) < 0) - return; + def->sounds =3D g_new0(virDomainSoundDefPtr, def->nsounds); + def->sounds[0] =3D g_new0(virDomainSoundDef, 1); =20 gVBoxAPI.UIAudioAdapter.GetAudioController(audioAdapter, &audi= oController); if (audioController =3D=3D AudioControllerType_SB16) { @@ -3839,8 +3828,7 @@ vboxDumpSerial(virDomainDefPtr def, vboxDriverPtr dat= a, IMachine *machine, PRUin =20 /* Allocate memory for the serial ports which are enabled */ if (def->nserials > 0) { - if (VIR_ALLOC_N(def->serials, def->nserials) < 0) - return -1; + def->serials =3D g_new0(virDomainChrDefPtr, def->nserials); =20 for (i =3D 0; i < def->nserials; i++) { def->serials[i] =3D virDomainChrDefNew(NULL); @@ -3934,8 +3922,7 @@ vboxDumpParallel(virDomainDefPtr def, vboxDriverPtr d= ata, IMachine *machine, PRU =20 /* Allocate memory for the parallel ports which are enabled */ if (def->nparallels > 0) { - if (VIR_ALLOC_N(def->parallels, def->nparallels) < 0) - return -1; + def->parallels =3D g_new0(virDomainChrDefPtr, def->nparallels); =20 for (i =3D 0; i < def->nparallels; i++) { def->parallels[i] =3D virDomainChrDefNew(NULL); @@ -4715,10 +4702,7 @@ vboxSnapshotRedefine(virDomainPtr dom, VBOX_UTF16_TO_UTF8(formatUtf, &format); VBOX_UTF16_FREE(formatUtf); =20 - if (VIR_ALLOC(readWriteDisk) < 0) { - VIR_FREE(formatUtf); - goto cleanup; - } + readWriteDisk =3D g_new0(virVBoxSnapshotConfHardDisk, 1); =20 readWriteDisk->format =3D format; readWriteDisk->uuid =3D uuid; @@ -4855,11 +4839,7 @@ vboxSnapshotRedefine(virDomainPtr dom, goto cleanup; } =20 - if (VIR_ALLOC(readOnlyDisk) < 0) { - VIR_FREE(uuid); - VIR_FREE(parentUuid); - goto cleanup; - } + readOnlyDisk =3D g_new0(virVBoxSnapshotConfHardDisk, 1); =20 readOnlyDisk->format =3D format; readOnlyDisk->uuid =3D uuid; @@ -4953,8 +4933,7 @@ vboxSnapshotRedefine(virDomainPtr dom, /* Here, all disks are closed or deleted */ =20 /* We are now going to create and fill the Snapshot xml struct */ - if (VIR_ALLOC(newSnapshotPtr) < 0) - goto cleanup; + newSnapshotPtr =3D g_new0(virVBoxSnapshotConfSnapshot, 1); =20 if (virUUIDGenerate(snapshotUuid) < 0) goto cleanup; @@ -5088,8 +5067,7 @@ vboxSnapshotRedefine(virDomainPtr dom, } VBOX_UTF16_FREE(locationUtf16); =20 - if (VIR_ALLOC(disk) < 0) - goto cleanup; + disk =3D g_new0(virVBoxSnapshotConfHardDisk, 1); =20 rc =3D gVBoxAPI.UIMedium.GetFormat(medium, &formatUtf16); if (NS_FAILED(rc)) { @@ -5248,8 +5226,7 @@ vboxSnapshotRedefine(virDomainPtr dom, * media registry and the machine storage controllers. */ =20 - if (VIR_ALLOC(newHardDisk) < 0) - goto cleanup; + newHardDisk =3D g_new0(virVBoxSnapshotConfHardDisk, 1); =20 rc =3D gVBoxAPI.UIMedium.GetId(newMedium, &iid); if (NS_FAILED(rc)) { @@ -5559,8 +5536,7 @@ vboxDomainSnapshotGetAll(virDomainPtr dom, if (count =3D=3D 0) goto out; =20 - if (VIR_ALLOC_N(list, count) < 0) - goto error; + list =3D g_new0(ISnapshot *, count); =20 rc =3D gVBoxAPI.UIMachine.FindSnapshot(machine, &empty, list); if (NS_FAILED(rc) || !list[0]) { @@ -5742,11 +5718,9 @@ vboxSnapshotGetReadWriteDisks(virDomainSnapshotDefPt= r def, } } /* Allocate mem, if fails return error */ - if (VIR_ALLOC_N(def->disks, def->ndisks) < 0) - goto cleanup; + def->disks =3D g_new0(virDomainSnapshotDiskDef, def->ndisks); for (i =3D 0; i < def->ndisks; i++) { - if (VIR_ALLOC(def->disks[i].src) < 0) - goto cleanup; + def->disks[i].src =3D g_new0(virStorageSource, 1); } =20 /* get the attachment details here */ @@ -5971,8 +5945,7 @@ vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDefPtr = def, } =20 /* Allocate mem, if fails return error */ - if (VIR_ALLOC_N(defdom->disks, defdom->ndisks) < 0) - goto cleanup; + defdom->disks =3D g_new0(virDomainDiskDefPtr, defdom->ndisks); =20 for (i =3D 0; i < defdom->ndisks; i++) { virDomainDiskDefPtr diskDef =3D virDomainDiskDefNew(NULL); @@ -6339,8 +6312,7 @@ static int vboxDomainSnapshotListNames(virDomainPtr d= om, char **names, vboxIID empty; =20 VBOX_IID_INITIALIZE(&empty); - if (VIR_ALLOC_N(snapshots, 1) < 0) - goto cleanup; + snapshots =3D g_new0(ISnapshot *, 1); rc =3D gVBoxAPI.UIMachine.FindSnapshot(machine, &empty, snapshots); if (NS_FAILED(rc) || !snapshots[0]) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -7015,8 +6987,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapsho= tPtr snapshot) * the machine storage controller. */ =20 - if (VIR_ALLOC(disk) < 0) - goto cleanup; + disk =3D g_new0(virVBoxSnapshotConfHardDisk, 1); =20 rc =3D gVBoxAPI.UIMedium.GetId(newMedium, &iid); if (NS_FAILED(rc)) { @@ -7508,9 +7479,8 @@ vboxConnectListAllDomains(virConnectPtr conn, !MATCH(VIR_CONNECT_LIST_DOMAINS_NO_AUTOSTART)) || (MATCH(VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE) && !MATCH(VIR_CONNECT_LIST_DOMAINS_NO_MANAGEDSAVE))) { - if (domains && - VIR_ALLOC_N(*domains, 1) < 0) - goto cleanup; + if (domains) + *domains =3D g_new0(virDomainPtr, 1); =20 ret =3D 0; goto cleanup; @@ -7523,9 +7493,8 @@ vboxConnectListAllDomains(virConnectPtr conn, goto cleanup; } =20 - if (domains && - VIR_ALLOC_N(doms, machines.count + 1) < 0) - goto cleanup; + if (domains) + doms =3D g_new0(virDomainPtr, machines.count + 1); =20 for (i =3D 0; i < machines.count; i++) { IMachine *machine =3D machines.items[i]; @@ -7784,8 +7753,7 @@ vboxDomainSendKey(virDomainPtr dom, =20 keyDownCodes =3D (PRInt32 *) keycodes; =20 - if (VIR_ALLOC_N(keyUpCodes, nkeycodes) < 0) - return ret; + keyUpCodes =3D g_new0(PRInt32, nkeycodes); =20 /* translate keycodes to xt and generate keyup scancodes */ for (i =3D 0; i < nkeycodes; i++) { diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index ceffc2053d..c3c9a55248 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -785,10 +785,8 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr netwo= rk, unsigned int flags) VBOX_IID_INITIALIZE(&vboxnet0IID); virCheckFlags(0, NULL); =20 - if (VIR_ALLOC(def) < 0) - goto cleanup; - if (VIR_ALLOC(ipdef) < 0) - goto cleanup; + def =3D g_new0(virNetworkDef, 1); + ipdef =3D g_new0(virNetworkIPDef, 1); def->ips =3D ipdef; def->nips =3D 1; =20 @@ -829,9 +827,7 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr networ= k, unsigned int flags) bool errorOccurred =3D false; =20 ipdef->nranges =3D 1; - - if (VIR_ALLOC_N(ipdef->ranges, ipdef->nranges) < 0) - goto cleanup; + ipdef->ranges =3D g_new0(virNetworkDHCPRangeDef, ipdef->nranges); =20 gVBoxAPI.UIDHCPServer.GetIPAddress(dhcpServer, &ipAddressUtf16); gVBoxAPI.UIDHCPServer.GetNetworkMask(dhcpServer, &networkMaskUtf16= ); @@ -861,8 +857,7 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr networ= k, unsigned int flags) goto cleanup; =20 ipdef->nhosts =3D 1; - if (VIR_ALLOC_N(ipdef->hosts, ipdef->nhosts) < 0) - goto cleanup; + ipdef->hosts =3D g_new0(virNetworkDHCPHostDef, ipdef->nhosts); =20 ipdef->hosts[0].name =3D g_strdup(network->name); gVBoxAPI.UIHNInterface.GetHardwareAddress(networkInterface, &macAd= dressUtf16); diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c index a18958fcc0..cb201e777e 100644 --- a/src/vbox/vbox_snapshot_conf.c +++ b/src/vbox/vbox_snapshot_conf.c @@ -45,8 +45,8 @@ virVBoxSnapshotConfCreateVBoxSnapshotConfHardDiskPtr(xmlN= odePtr diskNode, char *location =3D NULL; char *tmp =3D NULL; int n =3D 0; - if (VIR_ALLOC(hardDisk) < 0) - goto cleanup; + + hardDisk =3D g_new0(virVBoxSnapshotConfHardDisk, 1); =20 xPathContext->node =3D diskNode; =20 @@ -54,8 +54,8 @@ virVBoxSnapshotConfCreateVBoxSnapshotConfHardDiskPtr(xmlN= odePtr diskNode, if (n < 0) goto cleanup; =20 - if (n && VIR_ALLOC_N(hardDisk->children, n) < 0) - goto cleanup; + if (n) + hardDisk->children =3D g_new0(virVBoxSnapshotConfHardDiskPtr, n); hardDisk->nchildren =3D n; for (i =3D 0; i < hardDisk->nchildren; i++) { hardDisk->children[i] =3D virVBoxSnapshotConfCreateVBoxSnapshotCon= fHardDiskPtr(nodes[i], xPathContext, machineLocation); @@ -123,8 +123,7 @@ virVBoxSnapshotConfRetrieveMediaRegistry(xmlNodePtr med= iaRegistryNode, int result =3D -1; int n =3D 0; =20 - if (VIR_ALLOC(mediaRegistry) < 0) - goto cleanup; + mediaRegistry =3D g_new0(virVBoxSnapshotConfMediaRegistry, 1); =20 xPathContext->node =3D mediaRegistryNode; hardDisksNode =3D virXPathNode("./vbox:HardDisks", xPathContext); @@ -133,8 +132,8 @@ virVBoxSnapshotConfRetrieveMediaRegistry(xmlNodePtr med= iaRegistryNode, n =3D virXPathNodeSet("./vbox:HardDisk", xPathContext, &nodes); if (n < 0) goto cleanup; - if (n && VIR_ALLOC_N(mediaRegistry->disks, n) < 0) - goto cleanup; + if (n) + mediaRegistry->disks =3D g_new0(virVBoxSnapshotConfHardDiskPtr, n); mediaRegistry->ndisks =3D n; for (i =3D 0; i < mediaRegistry->ndisks; i++) { mediaRegistry->disks[i] =3D virVBoxSnapshotConfCreateVBoxSnapshotC= onfHardDiskPtr(nodes[i], @@ -154,8 +153,9 @@ virVBoxSnapshotConfRetrieveMediaRegistry(xmlNodePtr med= iaRegistryNode, xPathContext, &nodes); if (n < 0) goto cleanup; - if (n && VIR_ALLOC_N(mediaRegistry->otherMedia, n) < 0) - goto cleanup; + if (n) + mediaRegistry->otherMedia =3D g_new0(char *, n); + mediaRegistry->notherMedia =3D n; for (i =3D 0; i < mediaRegistry->notherMedia; i++) { mediaRegistry->otherMedia[i] =3D virXMLNodeToString(mediaRegistryN= ode->doc, @@ -190,8 +190,7 @@ virVBoxSnapshotConfRetrieveSnapshot(xmlNodePtr snapshot= Node, int result =3D -1; int n =3D 0; =20 - if (VIR_ALLOC(snapshot) < 0) - goto cleanup; + snapshot =3D g_new0(virVBoxSnapshotConfSnapshot, 1); =20 uuid =3D virXMLPropString(snapshotNode, "uuid"); /* we use virStringSearch because the uuid is between brackets */ @@ -248,8 +247,8 @@ virVBoxSnapshotConfRetrieveSnapshot(xmlNodePtr snapshot= Node, n =3D virXPathNodeSet("./vbox:Snapshot", xPathContext, &nodes); if (n < 0) goto cleanup; - if (n && VIR_ALLOC_N(snapshot->children, n) < 0) - goto cleanup; + if (n) + snapshot->children =3D g_new0(virVBoxSnapshotConfSnapshotPtr, = n); snapshot->nchildren =3D n; for (i =3D 0; i < snapshot->nchildren; i++) { snapshot->children[i] =3D virVBoxSnapshotConfRetrieveSnapshot(= nodes[i], xPathContext); @@ -469,8 +468,7 @@ virVBoxSnapshotConfAllChildren(virVBoxSnapshotConfHardD= iskPtr disk, size_t i =3D 0; size_t j =3D 0; =20 - if (VIR_ALLOC_N(ret, 0) < 0) - return 0; + ret =3D g_new0(virVBoxSnapshotConfHardDiskPtr, 0); =20 for (i =3D 0; i < disk->nchildren; i++) { tempSize =3D virVBoxSnapshotConfAllChildren(disk->children[i], &te= mpList); @@ -601,8 +599,7 @@ virVBoxSnapshotConfLoadVboxFile(const char *filePath, goto cleanup; } =20 - if (VIR_ALLOC(machineDescription) < 0) - goto cleanup; + machineDescription =3D g_new0(virVBoxSnapshotConfMachine, 1); =20 xml =3D virXMLParse(filePath, NULL, NULL); if (xml =3D=3D NULL) { @@ -1283,8 +1280,7 @@ virVBoxSnapshotConfGetRWDisksPathsFromLibvirtXML(cons= t char *filePath, xPathContext, &nodes)) < 0) goto cleanup; =20 - if (VIR_ALLOC_N(ret, nodeSize) < 0) - goto cleanup; + ret =3D g_new0(char *, nodeSize); =20 for (i =3D 0; i < nodeSize; i++) { xmlNodePtr node =3D nodes[i]; @@ -1346,8 +1342,7 @@ virVBoxSnapshotConfGetRODisksPathsFromLibvirtXML(cons= t char *filePath, xPathContext, &nodes)) < 0) goto cleanup; - if (VIR_ALLOC_N(ret, nodeSize) < 0) - goto cleanup; + ret =3D g_new0(char *, nodeSize); =20 for (i =3D 0; i < nodeSize; i++) { xmlNodePtr node =3D nodes[i]; @@ -1414,8 +1409,7 @@ virVBoxSnapshotConfDiskListToOpen(virVBoxSnapshotConf= MachinePtr machine, } if (hardDisk =3D=3D NULL) return 0; - if (VIR_ALLOC_N(ret, 1) < 0) - return 0; + ret =3D g_new0(virVBoxSnapshotConfHardDiskPtr, 1); =20 returnSize =3D 1; ret[returnSize - 1] =3D hardDisk; @@ -1446,8 +1440,7 @@ virVBoxSnapshotConfRemoveFakeDisks(virVBoxSnapshotCon= fMachinePtr machine) virVBoxSnapshotConfHardDiskPtr *tempList =3D NULL; virVBoxSnapshotConfHardDiskPtr *diskList =3D NULL; =20 - if (VIR_ALLOC_N(diskList, 0) < 0) - return -1; + diskList =3D g_new0(virVBoxSnapshotConfHardDiskPtr, 0); =20 for (i =3D 0; i < machine->mediaRegistry->ndisks; i++) { tempSize =3D virVBoxSnapshotConfAllChildren(machine->mediaRegistry= ->disks[i], &tempList); @@ -1498,8 +1491,7 @@ virVBoxSnapshotConfDiskIsInMediaRegistry(virVBoxSnaps= hotConfMachinePtr machine, virVBoxSnapshotConfHardDiskPtr *tempList =3D NULL; virVBoxSnapshotConfHardDiskPtr *diskList =3D NULL; =20 - if (VIR_ALLOC_N(diskList, 0) < 0) - return -1; + diskList =3D g_new0(virVBoxSnapshotConfHardDiskPtr, 0); =20 for (i =3D 0; i < machine->mediaRegistry->ndisks; i++) { tempSize =3D virVBoxSnapshotConfAllChildren(machine->mediaRegistry= ->disks[i], &tempList); --=20 2.26.2