From nobody Sun Feb 8 11:26:07 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1550843600668402.31085816772963; Fri, 22 Feb 2019 05:53:20 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 8FF6766986; Fri, 22 Feb 2019 13:53:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 58CB1282FD; Fri, 22 Feb 2019 13:53:18 +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 09EB5247EF; Fri, 22 Feb 2019 13:53:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1KEl1Ff021318 for ; Wed, 20 Feb 2019 09:47:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 89F08183C8; Wed, 20 Feb 2019 14:47:01 +0000 (UTC) Received: from libvirt-fedora-29.redhat.com (ovpn-117-20.phx2.redhat.com [10.3.117.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C16E226F1; Wed, 20 Feb 2019 14:47:00 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 20 Feb 2019 09:46:56 -0500 Message-Id: <20190220144659.7445-2-jferlan@redhat.com> In-Reply-To: <20190220144659.7445-1-jferlan@redhat.com> References: <20190220144659.7445-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/4] conf: Use VIR_STEAL_PTR in domain_conf 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 22 Feb 2019 13:53:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Make usage of VIR_STEAL_PTR in preparation for some autofree mods. Signed-off-by: John Ferlan Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 162 ++++++++++++++--------------------------- 1 file changed, 55 insertions(+), 107 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 56c437ca0a..ceeb247ef4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1596,8 +1596,7 @@ virDomainVcpuDefNew(virDomainXMLOptionPtr xmlopt) if (VIR_ALLOC(ret) < 0) goto cleanup; =20 - ret->privateData =3D priv; - priv =3D NULL; + VIR_STEAL_PTR(ret->privateData, priv); =20 cleanup: virObjectUnref(priv); @@ -6242,10 +6241,8 @@ virDomainDefValidateAliases(const virDomainDef *def, &data) < 0) goto cleanup; =20 - if (aliases) { - *aliases =3D data.aliases; - data.aliases =3D NULL; - } + if (aliases) + VIR_STEAL_PTR(*aliases, data.aliases); =20 ret =3D 0; cleanup: @@ -7798,8 +7795,7 @@ virDomainHostdevSubsysSCSIVHostDefParseXML(xmlNodePtr= sourcenode, virReportError(VIR_ERR_XML_ERROR, "%s", _("malformed 'wwpn' va= lue")); goto cleanup; } - hostsrc->wwpn =3D wwpn; - wwpn =3D NULL; + VIR_STEAL_PTR(hostsrc->wwpn, wwpn); break; case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_NONE: case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_LAST: @@ -8526,8 +8522,7 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, goto error; } =20 - seclabel->label =3D p; - p =3D NULL; + VIR_STEAL_PTR(seclabel->label, p); } =20 /* Only parse imagelabel, if requested live XML with relabeling */ @@ -8541,16 +8536,14 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, "%s", _("security imagelabel is missing")); goto error; } - seclabel->imagelabel =3D p; - p =3D NULL; + VIR_STEAL_PTR(seclabel->imagelabel, p); } =20 /* Only parse baselabel for dynamic label type */ if (seclabel->type =3D=3D VIR_DOMAIN_SECLABEL_DYNAMIC) { p =3D virXPathStringLimit("string(./baselabel[1])", VIR_SECURITY_LABEL_BUFLEN-1, ctxt); - seclabel->baselabel =3D p; - p =3D NULL; + VIR_STEAL_PTR(seclabel->baselabel, p); } =20 return seclabel; @@ -8844,10 +8837,9 @@ virDomainLeaseDefParseXML(xmlNodePtr node) goto error; } =20 - def->key =3D key; - def->lockspace =3D lockspace; - def->path =3D path; - path =3D key =3D lockspace =3D NULL; + VIR_STEAL_PTR(def->key, key); + VIR_STEAL_PTR(def->lockspace, lockspace); + VIR_STEAL_PTR(def->path, path); =20 cleanup: VIR_FREE(lockspace); @@ -8901,8 +8893,7 @@ virDomainDiskSourcePoolDefParse(xmlNodePtr node, goto cleanup; } =20 - *srcpool =3D source; - source =3D NULL; + VIR_STEAL_PTR(*srcpool, source); ret =3D 0; =20 cleanup: @@ -10144,22 +10135,16 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xm= lopt, def->startupPolicy =3D val; } =20 - def->dst =3D target; - target =3D NULL; + VIR_STEAL_PTR(def->dst, target); if (authdef) VIR_STEAL_PTR(def->src->auth, authdef); if (encryption) VIR_STEAL_PTR(def->src->encryption, encryption); - def->domain_name =3D domain_name; - domain_name =3D NULL; - def->serial =3D serial; - serial =3D NULL; - def->wwn =3D wwn; - wwn =3D NULL; - def->vendor =3D vendor; - vendor =3D NULL; - def->product =3D product; - product =3D NULL; + VIR_STEAL_PTR(def->domain_name, domain_name); + VIR_STEAL_PTR(def->serial, serial); + VIR_STEAL_PTR(def->wwn, wwn); + VIR_STEAL_PTR(def->vendor, vendor); + VIR_STEAL_PTR(def->product, product); =20 if (!(flags & VIR_DOMAIN_DEF_PARSE_DISK_SOURCE)) { if (virDomainDiskBackingStoreParse(ctxt, def->src, flags, xmlopt) = < 0) @@ -11004,10 +10989,8 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlop= t, goto error; } =20 - def->src->path =3D source; - source =3D NULL; - def->dst =3D target; - target =3D NULL; + VIR_STEAL_PTR(def->src->path, source); + VIR_STEAL_PTR(def->dst, target); =20 if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) goto error; @@ -11196,8 +11179,7 @@ virDomainActualNetDefParseXML(xmlNodePtr node, if (vlanNode && virNetDevVlanParse(vlanNode, ctxt, &actual->vlan) < 0) goto error; =20 - *def =3D actual; - actual =3D NULL; + VIR_STEAL_PTR(*def, actual); ret =3D 0; error: VIR_FREE(type); @@ -11604,8 +11586,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, _("Model name contains invalid characters")); goto error; } - def->model =3D model; - model =3D NULL; + VIR_STEAL_PTR(def->model, model); } =20 switch (def->type) { @@ -11616,12 +11597,9 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlo= pt, "specified with = ")); goto error; } - def->data.network.name =3D network; - network =3D NULL; - def->data.network.portgroup =3D portgroup; - portgroup =3D NULL; - def->data.network.actual =3D actual; - actual =3D NULL; + VIR_STEAL_PTR(def->data.network.name, network); + VIR_STEAL_PTR(def->data.network.portgroup, portgroup); + VIR_STEAL_PTR(def->data.network.actual, actual); break; =20 case VIR_DOMAIN_NET_TYPE_VHOSTUSER: @@ -11667,8 +11645,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, goto error; =20 def->data.vhostuser->type =3D VIR_DOMAIN_CHR_TYPE_UNIX; - def->data.vhostuser->data.nix.path =3D vhostuser_path; - vhostuser_path =3D NULL; + VIR_STEAL_PTR(def->data.vhostuser->data.nix.path, vhostuser_path); =20 if (STREQ(vhostuser_mode, "server")) { def->data.vhostuser->data.nix.listen =3D true; @@ -11697,8 +11674,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, "specified with "= )); goto error; } - def->data.bridge.brname =3D bridge; - bridge =3D NULL; + VIR_STEAL_PTR(def->data.bridge.brname, bridge); break; =20 case VIR_DOMAIN_NET_TYPE_CLIENT: @@ -11728,8 +11704,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, goto error; } } else { - def->data.socket.address =3D address; - address =3D NULL; + VIR_STEAL_PTR(def->data.socket.address, address); } =20 if (def->type !=3D VIR_DOMAIN_NET_TYPE_UDP) @@ -11754,8 +11729,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, "specified with socket interface")); goto error; } else { - def->data.socket.localaddr =3D localaddr; - localaddr =3D NULL; + VIR_STEAL_PTR(def->data.socket.localaddr, localaddr); } break; =20 @@ -11766,8 +11740,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, "with ")); goto error; } - def->data.internal.name =3D internal; - internal =3D NULL; + VIR_STEAL_PTR(def->data.internal.name, internal); break; =20 case VIR_DOMAIN_NET_TYPE_DIRECT: @@ -11789,8 +11762,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, def->data.direct.mode =3D VIR_NETDEV_MACVLAN_MODE_VEPA; } =20 - def->data.direct.linkdev =3D dev; - dev =3D NULL; + VIR_STEAL_PTR(def->data.direct.linkdev, dev); =20 if (ifname && flags & VIR_DOMAIN_DEF_PARSE_INACTIVE && @@ -11832,26 +11804,16 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xml= opt, ctxt, &def->guestIP) < 0) goto error; =20 - if (script !=3D NULL) { - def->script =3D script; - script =3D NULL; - } - if (domain_name !=3D NULL) { - def->domain_name =3D domain_name; - domain_name =3D NULL; - } - if (ifname !=3D NULL) { - def->ifname =3D ifname; - ifname =3D NULL; - } - if (ifname_guest !=3D NULL) { - def->ifname_guest =3D ifname_guest; - ifname_guest =3D NULL; - } - if (ifname_guest_actual !=3D NULL) { - def->ifname_guest_actual =3D ifname_guest_actual; - ifname_guest_actual =3D NULL; - } + if (script !=3D NULL) + VIR_STEAL_PTR(def->script, script); + if (domain_name !=3D NULL) + VIR_STEAL_PTR(def->domain_name, domain_name); + if (ifname !=3D NULL) + VIR_STEAL_PTR(def->ifname, ifname); + if (ifname_guest !=3D NULL) + VIR_STEAL_PTR(def->ifname_guest, ifname_guest); + if (ifname_guest_actual !=3D NULL) + VIR_STEAL_PTR(def->ifname_guest_actual, ifname_guest_actual); =20 if (def->type !=3D VIR_DOMAIN_NET_TYPE_HOSTDEV && virDomainNetIsVirtioModel(def)) { @@ -12051,8 +12013,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, def->driver.virtio.guest.ufo =3D val; } } - def->backend.vhost =3D vhost_path; - vhost_path =3D NULL; + VIR_STEAL_PTR(def->backend.vhost, vhost_path); } =20 def->linkstate =3D VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DEFAULT; @@ -12070,10 +12031,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlo= pt, case VIR_DOMAIN_NET_TYPE_ETHERNET: case VIR_DOMAIN_NET_TYPE_NETWORK: case VIR_DOMAIN_NET_TYPE_BRIDGE: - def->filter =3D filter; - filter =3D NULL; - def->filterparams =3D filterparams; - filterparams =3D NULL; + VIR_STEAL_PTR(def->filter, filter); + VIR_STEAL_PTR(def->filterparams, filterparams); break; case VIR_DOMAIN_NET_TYPE_USER: case VIR_DOMAIN_NET_TYPE_VHOSTUSER: @@ -13127,9 +13086,8 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlop= t, path =3D virXPathString("string(./backend/device/@path)", ctxt); if (!path && VIR_STRDUP(path, VIR_DOMAIN_TPM_DEFAULT_DEVICE) < 0) goto error; - def->data.passthrough.source.data.file.path =3D path; + VIR_STEAL_PTR(def->data.passthrough.source.data.file.path, path); def->data.passthrough.source.type =3D VIR_DOMAIN_CHR_TYPE_DEV; - path =3D NULL; break; case VIR_DOMAIN_TPM_TYPE_EMULATOR: break; @@ -13694,8 +13652,7 @@ virDomainGraphicsListenDefParseXML(virDomainGraphic= sListenDefPtr def, (def->type =3D=3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS || (def->type =3D=3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK && !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)))) { - def->address =3D address; - address =3D NULL; + VIR_STEAL_PTR(def->address, address); } =20 if (network && network[0]) { @@ -13705,8 +13662,7 @@ virDomainGraphicsListenDefParseXML(virDomainGraphic= sListenDefPtr def, "type 'network'")); goto error; } - def->network =3D network; - network =3D NULL; + VIR_STEAL_PTR(def->network, network); } =20 if (socketPath && socketPath[0]) { @@ -13716,8 +13672,7 @@ virDomainGraphicsListenDefParseXML(virDomainGraphic= sListenDefPtr def, "type 'socket'")); goto error; } - def->socket =3D socketPath; - socketPath =3D NULL; + VIR_STEAL_PTR(def->socket, socketPath); } =20 if (fromConfig && @@ -13805,8 +13760,7 @@ virDomainGraphicsListensParseXML(virDomainGraphicsD= efPtr def, =20 if (socketPath) { newListen.type =3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET; - newListen.socket =3D socketPath; - socketPath =3D NULL; + VIR_STEAL_PTR(newListen.socket, socketPath); } else { newListen.type =3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS; newListen.address =3D virXMLPropString(node, "listen"); @@ -14344,7 +14298,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, VIR_FREE(enable); =20 def->data.spice.gl =3D enableVal; - def->data.spice.rendernode =3D rendernode; + VIR_STEAL_PTR(def->data.spice.rendernode, rendernode); =20 } else if (virXMLNodeNameEqual(cur, "mouse")) { char *mode =3D virXMLPropString(cur, "mode"); @@ -14993,8 +14947,7 @@ virSysinfoBIOSParseXML(xmlNodePtr node, def =3D NULL; } =20 - *bios =3D def; - def =3D NULL; + VIR_STEAL_PTR(*bios, def); ret =3D 0; cleanup: virSysinfoBIOSDefFree(def); @@ -15067,8 +15020,7 @@ virSysinfoSystemParseXML(xmlNodePtr node, def =3D NULL; } =20 - *sysdef =3D def; - def =3D NULL; + VIR_STEAL_PTR(*sysdef, def); ret =3D 0; cleanup: virSysinfoSystemDefFree(def); @@ -15119,9 +15071,8 @@ virSysinfoBaseBoardParseXML(xmlXPathContextPtr ctxt, } } =20 - *baseBoard =3D boards; + VIR_STEAL_PTR(*baseBoard, boards); *nbaseBoard =3D nboards; - boards =3D NULL; ret =3D 0; cleanup: VIR_FREE(boards); @@ -15157,8 +15108,7 @@ virSysinfoOEMStringsParseXML(xmlXPathContextPtr ctx= t, for (i =3D 0; i < nstrings; i++) def->values[i] =3D virXMLNodeContentString(strings[i]); =20 - *oem =3D def; - def =3D NULL; + VIR_STEAL_PTR(*oem, def); ret =3D 0; cleanup: VIR_FREE(strings); @@ -15201,8 +15151,7 @@ virSysinfoChassisParseXML(xmlNodePtr node, def =3D NULL; } =20 - *chassisdef =3D def; - def =3D NULL; + VIR_STEAL_PTR(*chassisdef, def); ret =3D 0; cleanup: virSysinfoChassisDefFree(def); @@ -18431,8 +18380,7 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node, goto cleanup; } =20 - iothrid->cpumask =3D cpumask; - cpumask =3D NULL; + VIR_STEAL_PTR(iothrid->cpumask, cpumask); ret =3D 0; =20 cleanup: --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list