mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
lib: Use g_steal_pointer() more
Generated by the following spatch: @@ expression a, b; @@ + b = g_steal_pointer(&a); - b = a; ... when != a - a = NULL; Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
cebd40590c
commit
0c30e7221c
@ -1702,8 +1702,7 @@ virCapabilitiesInitPages(virCapsPtr caps)
|
||||
&pages_size, NULL, NULL, &npages) < 0)
|
||||
goto cleanup;
|
||||
|
||||
caps->host.pagesSize = pages_size;
|
||||
pages_size = NULL;
|
||||
caps->host.pagesSize = g_steal_pointer(&pages_size);
|
||||
caps->host.nPagesSize = npages;
|
||||
npages = 0;
|
||||
|
||||
|
@ -1995,8 +1995,7 @@ virDomainUSBAddressSetAddController(virDomainUSBAddressSetPtr addrs,
|
||||
if (!(hub = virDomainUSBAddressHubNew(nports)))
|
||||
goto cleanup;
|
||||
|
||||
addrs->buses[cont->idx] = hub;
|
||||
hub = NULL;
|
||||
addrs->buses[cont->idx] = g_steal_pointer(&hub);
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
@ -2112,8 +2111,7 @@ virDomainUSBAddressSetAddHub(virDomainUSBAddressSetPtr addrs,
|
||||
goto cleanup;
|
||||
}
|
||||
ignore_value(virBitmapSetBit(targetHub->portmap, targetPort));
|
||||
targetHub->ports[targetPort] = newHub;
|
||||
newHub = NULL;
|
||||
targetHub->ports[targetPort] = g_steal_pointer(&newHub);
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
|
@ -3961,9 +3961,8 @@ virDomainObjRemoveTransientDef(virDomainObjPtr domain)
|
||||
return;
|
||||
|
||||
virDomainDefFree(domain->def);
|
||||
domain->def = domain->newDef;
|
||||
domain->def = g_steal_pointer(&domain->newDef);
|
||||
domain->def->id = -1;
|
||||
domain->newDef = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1866,8 +1866,7 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt,
|
||||
if (virPCIEDeviceInfoParseXML(ctxt, pciExpress, pci_express) < 0)
|
||||
goto out;
|
||||
|
||||
pci_dev->pci_express = pci_express;
|
||||
pci_express = NULL;
|
||||
pci_dev->pci_express = g_steal_pointer(&pci_express);
|
||||
pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCIE;
|
||||
}
|
||||
|
||||
|
@ -2644,7 +2644,7 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt)
|
||||
name_prefix = virNWFilterIsAllowedChain(chain);
|
||||
if (name_prefix == NULL)
|
||||
goto cleanup;
|
||||
ret->chainsuffix = chain;
|
||||
ret->chainsuffix = g_steal_pointer(&chain);
|
||||
|
||||
if (chain_pri_s) {
|
||||
ret->chainPriority = chain_priority;
|
||||
@ -2656,7 +2656,6 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt)
|
||||
NWFILTER_MIN_FILTER_PRIORITY) / 2;
|
||||
}
|
||||
}
|
||||
chain = NULL;
|
||||
} else {
|
||||
ret->chainsuffix = g_strdup(virNWFilterChainSuffixTypeToString(VIR_NWFILTER_CHAINSUFFIX_ROOT));
|
||||
}
|
||||
|
@ -805,9 +805,8 @@ virObjectEventStateFlush(virObjectEventStatePtr state)
|
||||
/* Copy the queue, so we're reentrant safe when dispatchFunc drops the
|
||||
* driver lock */
|
||||
tempQueue.count = state->queue->count;
|
||||
tempQueue.events = state->queue->events;
|
||||
tempQueue.events = g_steal_pointer(&state->queue->events);
|
||||
state->queue->count = 0;
|
||||
state->queue->events = NULL;
|
||||
if (state->timer != -1)
|
||||
virEventUpdateTimeout(state->timer, -1);
|
||||
|
||||
|
@ -133,11 +133,10 @@ virDomainMomentDropParent(virDomainMomentObjPtr moment)
|
||||
curr = curr->sibling;
|
||||
}
|
||||
if (prev)
|
||||
prev->sibling = moment->sibling;
|
||||
prev->sibling = g_steal_pointer(&moment->sibling);
|
||||
else
|
||||
moment->parent->first_child = moment->sibling;
|
||||
moment->parent->first_child = g_steal_pointer(&moment->sibling);
|
||||
moment->parent = NULL;
|
||||
moment->sibling = NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -201,9 +200,8 @@ virDomainMomentMoveChildren(virDomainMomentObjPtr from,
|
||||
child = child->sibling;
|
||||
}
|
||||
to->nchildren += from->nchildren;
|
||||
to->first_child = from->first_child;
|
||||
to->first_child = g_steal_pointer(&from->first_child);
|
||||
from->nchildren = 0;
|
||||
from->first_child = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -330,8 +330,7 @@ virInterfaceObjListExport(virConnectPtr conn,
|
||||
if (data.ifaces) {
|
||||
/* trim the array to the final size */
|
||||
VIR_REALLOC_N(data.ifaces, data.nifaces + 1);
|
||||
*ifaces = data.ifaces;
|
||||
data.ifaces = NULL;
|
||||
*ifaces = g_steal_pointer(&data.ifaces);
|
||||
}
|
||||
|
||||
ret = data.nifaces;
|
||||
|
@ -696,8 +696,7 @@ virNetworkObjUnsetDefTransient(virNetworkObjPtr obj)
|
||||
{
|
||||
if (obj->newDef) {
|
||||
virNetworkDefFree(obj->def);
|
||||
obj->def = obj->newDef;
|
||||
obj->newDef = NULL;
|
||||
obj->def = g_steal_pointer(&obj->newDef);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1309,8 +1308,7 @@ virNetworkObjUpdate(virNetworkObjPtr obj,
|
||||
if (livedef) {
|
||||
/* successfully modified copy, now replace original */
|
||||
virNetworkDefFree(obj->def);
|
||||
obj->def = livedef;
|
||||
livedef = NULL;
|
||||
obj->def = g_steal_pointer(&livedef);
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
@ -1429,8 +1427,7 @@ virNetworkObjListExport(virConnectPtr conn,
|
||||
if (data.nets) {
|
||||
/* trim the array to the final size */
|
||||
VIR_REALLOC_N(data.nets, data.nnets + 1);
|
||||
*nets = data.nets;
|
||||
data.nets = NULL;
|
||||
*nets = g_steal_pointer(&data.nets);
|
||||
}
|
||||
|
||||
ret = data.nnets;
|
||||
@ -1817,8 +1814,7 @@ virNetworkObjPortListExport(virNetworkPtr net,
|
||||
if (data.ports) {
|
||||
/* trim the array to the final size */
|
||||
VIR_REALLOC_N(data.ports, data.nports + 1);
|
||||
*ports = data.ports;
|
||||
data.ports = NULL;
|
||||
*ports = g_steal_pointer(&data.ports);
|
||||
}
|
||||
|
||||
ret = data.nports;
|
||||
|
@ -270,8 +270,7 @@ void
|
||||
virStoragePoolObjDefUseNewDef(virStoragePoolObjPtr obj)
|
||||
{
|
||||
virStoragePoolDefFree(obj->def);
|
||||
obj->def = obj->newDef;
|
||||
obj->newDef = NULL;
|
||||
obj->def = g_steal_pointer(&obj->newDef);
|
||||
}
|
||||
|
||||
|
||||
|
@ -911,8 +911,7 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
|
||||
if (!(priv->xmlopt = virVMXDomainXMLConfInit(priv->caps)))
|
||||
goto cleanup;
|
||||
|
||||
conn->privateData = priv;
|
||||
priv = NULL;
|
||||
conn->privateData = g_steal_pointer(&priv);
|
||||
result = VIR_DRV_OPEN_SUCCESS;
|
||||
|
||||
cleanup:
|
||||
@ -3554,8 +3553,7 @@ esxDomainSetSchedulerParametersFlags(virDomainPtr domain,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
spec->cpuAllocation->shares = sharesInfo;
|
||||
sharesInfo = NULL;
|
||||
spec->cpuAllocation->shares = g_steal_pointer(&sharesInfo);
|
||||
|
||||
if (params[i].value.i >= 0) {
|
||||
spec->cpuAllocation->shares->level = esxVI_SharesLevel_Custom;
|
||||
@ -4930,8 +4928,7 @@ esxConnectListAllDomains(virConnectPtr conn,
|
||||
}
|
||||
|
||||
if (doms) {
|
||||
*domains = doms;
|
||||
doms = NULL;
|
||||
*domains = g_steal_pointer(&doms);
|
||||
}
|
||||
ret = count;
|
||||
|
||||
|
@ -3511,8 +3511,7 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx,
|
||||
}
|
||||
}
|
||||
|
||||
*fileInfo = searchResults->file;
|
||||
searchResults->file = NULL;
|
||||
*fileInfo = g_steal_pointer(&searchResults->file);
|
||||
|
||||
result = 0;
|
||||
|
||||
|
@ -179,8 +179,7 @@ virDomainDriverMergeBlkioDevice(virBlkioDevicePtr *dest_array,
|
||||
return -1;
|
||||
}
|
||||
|
||||
dest->path = src->path;
|
||||
src->path = NULL;
|
||||
dest->path = g_steal_pointer(&src->path);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -516,8 +516,7 @@ static int netcfConnectListInterfacesImpl(virConnectPtr conn,
|
||||
}
|
||||
virInterfaceDefFree(def);
|
||||
|
||||
names[want++] = allnames[i];
|
||||
allnames[i] = NULL;
|
||||
names[want++] = g_steal_pointer(&allnames[i]);
|
||||
}
|
||||
|
||||
ret = want;
|
||||
|
@ -2506,8 +2506,7 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int vcpu,
|
||||
}
|
||||
|
||||
virBitmapFree(vcpuinfo->cpumask);
|
||||
vcpuinfo->cpumask = pcpumap;
|
||||
pcpumap = NULL;
|
||||
vcpuinfo->cpumask = g_steal_pointer(&pcpumap);
|
||||
|
||||
ret = 0;
|
||||
|
||||
@ -3530,7 +3529,7 @@ libxlDomainAttachDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev)
|
||||
|
||||
switch (dev->type) {
|
||||
case VIR_DOMAIN_DEVICE_DISK:
|
||||
disk = dev->data.disk;
|
||||
disk = g_steal_pointer(&dev->data.disk);
|
||||
if (virDomainDiskIndexByName(vmdef, disk->dst, true) >= 0) {
|
||||
virReportError(VIR_ERR_INVALID_ARG,
|
||||
_("target %s already exists."), disk->dst);
|
||||
@ -3538,11 +3537,10 @@ libxlDomainAttachDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev)
|
||||
}
|
||||
virDomainDiskInsert(vmdef, disk);
|
||||
/* vmdef has the pointer. Generic codes for vmdef will do all jobs */
|
||||
dev->data.disk = NULL;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_CONTROLLER:
|
||||
controller = dev->data.controller;
|
||||
controller = g_steal_pointer(&dev->data.controller);
|
||||
if (controller->idx != -1 &&
|
||||
virDomainControllerFind(vmdef, controller->type,
|
||||
controller->idx) >= 0) {
|
||||
@ -3552,11 +3550,10 @@ libxlDomainAttachDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev)
|
||||
}
|
||||
|
||||
virDomainControllerInsert(vmdef, controller);
|
||||
dev->data.controller = NULL;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_NET:
|
||||
net = dev->data.net;
|
||||
net = g_steal_pointer(&dev->data.net);
|
||||
if (virDomainHasNet(vmdef, net)) {
|
||||
virReportError(VIR_ERR_INVALID_ARG,
|
||||
_("network device with mac %s already exists"),
|
||||
@ -3565,7 +3562,6 @@ libxlDomainAttachDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev)
|
||||
}
|
||||
if (virDomainNetInsert(vmdef, net))
|
||||
return -1;
|
||||
dev->data.net = NULL;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_HOSTDEV:
|
||||
|
@ -602,11 +602,10 @@ libxlDomainMigrationDstPrepareTunnel3(virConnectPtr dconn,
|
||||
args->conn = virObjectRef(dconn);
|
||||
args->vm = virObjectRef(vm);
|
||||
args->flags = flags;
|
||||
args->migcookie = mig;
|
||||
args->migcookie = g_steal_pointer(&mig);
|
||||
/* Receive from pipeOut */
|
||||
args->recvfd = dataFD[0];
|
||||
args->nsocks = 0;
|
||||
mig = NULL;
|
||||
|
||||
VIR_FREE(priv->migrationDstReceiveThr);
|
||||
priv->migrationDstReceiveThr = g_new0(virThread, 1);
|
||||
@ -768,8 +767,7 @@ libxlDomainMigrationDstPrepare(virConnectPtr dconn,
|
||||
args->flags = flags;
|
||||
args->socks = socks;
|
||||
args->nsocks = nsocks;
|
||||
args->migcookie = mig;
|
||||
mig = NULL;
|
||||
args->migcookie = g_steal_pointer(&mig);
|
||||
|
||||
for (i = 0; i < nsocks; i++) {
|
||||
if (virNetSocketSetBlocking(socks[i], true) < 0)
|
||||
|
@ -1071,8 +1071,7 @@ xenParseXLChannel(virConfPtr conf, virDomainDefPtr def)
|
||||
if (STRPREFIX(type, "socket")) {
|
||||
channel->source->type = VIR_DOMAIN_CHR_TYPE_UNIX;
|
||||
channel->source->data.nix.listen = 1;
|
||||
channel->source->data.nix.path = path;
|
||||
path = NULL;
|
||||
channel->source->data.nix.path = g_steal_pointer(&path);
|
||||
} else if (STRPREFIX(type, "pty")) {
|
||||
channel->source->type = VIR_DOMAIN_CHR_TYPE_PTY;
|
||||
VIR_FREE(path);
|
||||
@ -1082,8 +1081,7 @@ xenParseXLChannel(virConfPtr conf, virDomainDefPtr def)
|
||||
|
||||
channel->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL;
|
||||
channel->targetType = VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN;
|
||||
channel->target.name = name;
|
||||
name = NULL;
|
||||
channel->target.name = g_steal_pointer(&name);
|
||||
|
||||
if (VIR_APPEND_ELEMENT(def->channels, def->nchannels, channel) < 0)
|
||||
goto cleanup;
|
||||
|
@ -463,8 +463,7 @@ static int virLXCControllerSetupLoopDeviceFS(virDomainFSDefPtr fs)
|
||||
*/
|
||||
fs->type = VIR_DOMAIN_FS_TYPE_BLOCK;
|
||||
g_free(fs->src->path);
|
||||
fs->src->path = loname;
|
||||
loname = NULL;
|
||||
fs->src->path = g_steal_pointer(&loname);
|
||||
|
||||
return lofd;
|
||||
}
|
||||
|
@ -3041,7 +3041,7 @@ lxcDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
||||
|
||||
switch (dev->type) {
|
||||
case VIR_DOMAIN_DEVICE_DISK:
|
||||
disk = dev->data.disk;
|
||||
disk = g_steal_pointer(&dev->data.disk);
|
||||
if (virDomainDiskIndexByName(vmdef, disk->dst, true) >= 0) {
|
||||
virReportError(VIR_ERR_INVALID_ARG,
|
||||
_("target %s already exists."), disk->dst);
|
||||
@ -3049,20 +3049,18 @@ lxcDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
||||
}
|
||||
virDomainDiskInsert(vmdef, disk);
|
||||
/* vmdef has the pointer. Generic codes for vmdef will do all jobs */
|
||||
dev->data.disk = NULL;
|
||||
ret = 0;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_NET:
|
||||
net = dev->data.net;
|
||||
net = g_steal_pointer(&dev->data.net);
|
||||
if (virDomainNetInsert(vmdef, net) < 0)
|
||||
return -1;
|
||||
dev->data.net = NULL;
|
||||
ret = 0;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_HOSTDEV:
|
||||
hostdev = dev->data.hostdev;
|
||||
hostdev = g_steal_pointer(&dev->data.hostdev);
|
||||
if (virDomainHostdevFind(vmdef, hostdev, NULL) >= 0) {
|
||||
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||
_("device is already in the domain configuration"));
|
||||
@ -3070,7 +3068,6 @@ lxcDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
||||
}
|
||||
if (virDomainHostdevInsert(vmdef, hostdev) < 0)
|
||||
return -1;
|
||||
dev->data.hostdev = NULL;
|
||||
ret = 0;
|
||||
break;
|
||||
|
||||
@ -3095,7 +3092,7 @@ lxcDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
|
||||
|
||||
switch (dev->type) {
|
||||
case VIR_DOMAIN_DEVICE_NET:
|
||||
net = dev->data.net;
|
||||
net = g_steal_pointer(&dev->data.net);
|
||||
if ((idx = virDomainNetFindIdx(vmdef, net)) < 0)
|
||||
return -1;
|
||||
|
||||
@ -3109,7 +3106,6 @@ lxcDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
|
||||
return -1;
|
||||
|
||||
virDomainNetDefFree(oldDev.data.net);
|
||||
dev->data.net = NULL;
|
||||
ret = 0;
|
||||
|
||||
break;
|
||||
|
@ -211,8 +211,7 @@ void virLXCMonitorClose(virLXCMonitorPtr mon)
|
||||
*/
|
||||
VIR_DEBUG("Clear EOF callback mon=%p", mon);
|
||||
vm = mon->vm;
|
||||
client = mon->client;
|
||||
mon->client = NULL;
|
||||
client = g_steal_pointer(&mon->client);
|
||||
mon->cb.eofNotify = NULL;
|
||||
|
||||
virObjectRef(vm);
|
||||
|
@ -1007,8 +1007,7 @@ lxcBlkioDeviceWalkCallback(const char *name, virConfValuePtr value, void *data)
|
||||
if (!device) {
|
||||
VIR_EXPAND_N(def->blkio.devices, def->blkio.ndevices, 1);
|
||||
device = &def->blkio.devices[def->blkio.ndevices - 1];
|
||||
device->path = path;
|
||||
path = NULL;
|
||||
device->path = g_steal_pointer(&path);
|
||||
}
|
||||
|
||||
/* Set the value */
|
||||
|
@ -113,8 +113,7 @@ virLXCProcessReboot(virLXCDriverPtr driver,
|
||||
* to use the current 'def', and not switch to 'newDef'.
|
||||
* So temporarily hide the newDef and then reinstate it
|
||||
*/
|
||||
savedDef = vm->newDef;
|
||||
vm->newDef = NULL;
|
||||
savedDef = g_steal_pointer(&vm->newDef);
|
||||
virLXCProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN);
|
||||
vm->newDef = savedDef;
|
||||
if (virLXCProcessStart(conn, driver, vm,
|
||||
|
@ -451,8 +451,7 @@ udevProcessPCI(struct udev_device *device,
|
||||
pci_express->link_sta->port = -1; /* PCIe can't negotiate port. Yet :) */
|
||||
}
|
||||
pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCIE;
|
||||
pci_dev->pci_express = pci_express;
|
||||
pci_express = NULL;
|
||||
pci_dev->pci_express = g_steal_pointer(&pci_express);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,9 +305,8 @@ qemuAgentIOProcessLine(qemuAgentPtr agent,
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
msg->rxObject = obj;
|
||||
msg->rxObject = g_steal_pointer(&obj);
|
||||
msg->finished = true;
|
||||
obj = NULL;
|
||||
} else {
|
||||
/* we are out of sync */
|
||||
VIR_DEBUG("Ignoring delayed reply");
|
||||
|
@ -1219,8 +1219,7 @@ qemuBlockJobProcessEventCompletedCommit(virQEMUDriverPtr driver,
|
||||
job->data.commit.top = NULL;
|
||||
|
||||
if (cfgbaseparent) {
|
||||
cfgbase = cfgbaseparent->backingStore;
|
||||
cfgbaseparent->backingStore = NULL;
|
||||
cfgbase = g_steal_pointer(&cfgbaseparent->backingStore);
|
||||
|
||||
if (cfgtopparent)
|
||||
cfgtopparent->backingStore = cfgbase;
|
||||
@ -1289,8 +1288,7 @@ qemuBlockJobProcessEventCompletedActiveCommit(virQEMUDriverPtr driver,
|
||||
*/
|
||||
qemuBlockJobRewriteConfigDiskSource(vm, job->disk, job->data.commit.base);
|
||||
} else {
|
||||
cfgbase = cfgbaseparent->backingStore;
|
||||
cfgbaseparent->backingStore = NULL;
|
||||
cfgbase = g_steal_pointer(&cfgbaseparent->backingStore);
|
||||
cfgdisk->src = cfgbase;
|
||||
cfgdisk->src->readonly = cfgtop->readonly;
|
||||
virObjectUnref(cfgtop);
|
||||
|
@ -2920,8 +2920,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
|
||||
if (obj && obj->privateData) {
|
||||
priv = obj->privateData;
|
||||
/* if this is the live domain object, we persist the PCI addresses */
|
||||
priv->pciaddrs = addrs;
|
||||
addrs = NULL;
|
||||
priv->pciaddrs = g_steal_pointer(&addrs);
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
@ -3231,8 +3230,7 @@ qemuDomainAssignUSBAddresses(virDomainDefPtr def,
|
||||
|
||||
if (obj && obj->privateData) {
|
||||
priv = obj->privateData;
|
||||
priv->usbaddrs = addrs;
|
||||
addrs = NULL;
|
||||
priv->usbaddrs = g_steal_pointer(&addrs);
|
||||
}
|
||||
ret = 0;
|
||||
|
||||
|
@ -7238,7 +7238,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
||||
|
||||
switch ((virDomainDeviceType)dev->type) {
|
||||
case VIR_DOMAIN_DEVICE_DISK:
|
||||
disk = dev->data.disk;
|
||||
disk = g_steal_pointer(&dev->data.disk);
|
||||
if (virDomainDiskIndexByName(vmdef, disk->dst, true) >= 0) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
_("target %s already exists"), disk->dst);
|
||||
@ -7250,25 +7250,22 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
||||
return -1;
|
||||
virDomainDiskInsert(vmdef, disk);
|
||||
/* vmdef has the pointer. Generic codes for vmdef will do all jobs */
|
||||
dev->data.disk = NULL;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_NET:
|
||||
net = dev->data.net;
|
||||
net = g_steal_pointer(&dev->data.net);
|
||||
if (virDomainNetInsert(vmdef, net))
|
||||
return -1;
|
||||
dev->data.net = NULL;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_SOUND:
|
||||
sound = dev->data.sound;
|
||||
sound = g_steal_pointer(&dev->data.sound);
|
||||
if (VIR_APPEND_ELEMENT(vmdef->sounds, vmdef->nsounds, sound) < 0)
|
||||
return -1;
|
||||
dev->data.sound = NULL;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_HOSTDEV:
|
||||
hostdev = dev->data.hostdev;
|
||||
hostdev = g_steal_pointer(&dev->data.hostdev);
|
||||
if (virDomainHostdevFind(vmdef, hostdev, NULL) >= 0) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("device is already in the domain configuration"));
|
||||
@ -7276,11 +7273,10 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
||||
}
|
||||
if (virDomainHostdevInsert(vmdef, hostdev))
|
||||
return -1;
|
||||
dev->data.hostdev = NULL;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_LEASE:
|
||||
lease = dev->data.lease;
|
||||
lease = g_steal_pointer(&dev->data.lease);
|
||||
if (virDomainLeaseIndex(vmdef, lease) >= 0) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
_("Lease %s in lockspace %s already exists"),
|
||||
@ -7290,11 +7286,10 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
||||
virDomainLeaseInsert(vmdef, lease);
|
||||
|
||||
/* vmdef has the pointer. Generic codes for vmdef will do all jobs */
|
||||
dev->data.lease = NULL;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_CONTROLLER:
|
||||
controller = dev->data.controller;
|
||||
controller = g_steal_pointer(&dev->data.controller);
|
||||
if (controller->idx != -1 &&
|
||||
virDomainControllerFind(vmdef, controller->type,
|
||||
controller->idx) >= 0) {
|
||||
@ -7305,7 +7300,6 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
||||
}
|
||||
|
||||
virDomainControllerInsert(vmdef, controller);
|
||||
dev->data.controller = NULL;
|
||||
|
||||
break;
|
||||
|
||||
@ -7316,7 +7310,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_FS:
|
||||
fs = dev->data.fs;
|
||||
fs = g_steal_pointer(&dev->data.fs);
|
||||
if (virDomainFSIndexByName(vmdef, fs->dst) >= 0) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
"%s", _("Target already exists"));
|
||||
@ -7325,7 +7319,6 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
||||
|
||||
if (virDomainFSInsert(vmdef, fs) < 0)
|
||||
return -1;
|
||||
dev->data.fs = NULL;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_RNG:
|
||||
@ -7357,15 +7350,14 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_REDIRDEV:
|
||||
redirdev = dev->data.redirdev;
|
||||
redirdev = g_steal_pointer(&dev->data.redirdev);
|
||||
|
||||
if (VIR_APPEND_ELEMENT(vmdef->redirdevs, vmdef->nredirdevs, redirdev) < 0)
|
||||
return -1;
|
||||
dev->data.redirdev = NULL;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_SHMEM:
|
||||
shmem = dev->data.shmem;
|
||||
shmem = g_steal_pointer(&dev->data.shmem);
|
||||
if (virDomainShmemDefFind(vmdef, shmem) >= 0) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("device is already in the domain configuration"));
|
||||
@ -7373,7 +7365,6 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
||||
}
|
||||
if (virDomainShmemDefInsert(vmdef, shmem) < 0)
|
||||
return -1;
|
||||
dev->data.shmem = NULL;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_WATCHDOG:
|
||||
@ -7645,7 +7636,7 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
|
||||
|
||||
switch ((virDomainDeviceType)dev->type) {
|
||||
case VIR_DOMAIN_DEVICE_DISK:
|
||||
newDisk = dev->data.disk;
|
||||
newDisk = g_steal_pointer(&dev->data.disk);
|
||||
if ((pos = virDomainDiskIndexByName(vmdef, newDisk->dst, false)) < 0) {
|
||||
virReportError(VIR_ERR_INVALID_ARG,
|
||||
_("target %s doesn't exist."), newDisk->dst);
|
||||
@ -7660,11 +7651,10 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
|
||||
|
||||
virDomainDiskDefFree(vmdef->disks[pos]);
|
||||
vmdef->disks[pos] = newDisk;
|
||||
dev->data.disk = NULL;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_GRAPHICS:
|
||||
newGraphics = dev->data.graphics;
|
||||
newGraphics = g_steal_pointer(&dev->data.graphics);
|
||||
pos = qemuDomainFindGraphicsIndex(vmdef, newGraphics);
|
||||
if (pos < 0) {
|
||||
virReportError(VIR_ERR_INVALID_ARG,
|
||||
@ -7681,11 +7671,10 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
|
||||
|
||||
virDomainGraphicsDefFree(vmdef->graphics[pos]);
|
||||
vmdef->graphics[pos] = newGraphics;
|
||||
dev->data.graphics = NULL;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_NET:
|
||||
net = dev->data.net;
|
||||
net = g_steal_pointer(&dev->data.net);
|
||||
if ((pos = virDomainNetFindIdx(vmdef, net)) < 0)
|
||||
return -1;
|
||||
|
||||
@ -7699,7 +7688,6 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
|
||||
return -1;
|
||||
|
||||
virDomainNetDefFree(oldDev.data.net);
|
||||
dev->data.net = NULL;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_FS:
|
||||
|
@ -423,8 +423,7 @@ qemuMigrationCookieAddPersistent(qemuMigrationCookiePtr mig,
|
||||
if (!def || !*def)
|
||||
return 0;
|
||||
|
||||
mig->persistent = *def;
|
||||
*def = NULL;
|
||||
mig->persistent = g_steal_pointer(&*def);
|
||||
mig->flags |= QEMU_MIGRATION_COOKIE_PERSISTENT;
|
||||
mig->flagsMandatory |= QEMU_MIGRATION_COOKIE_PERSISTENT;
|
||||
return 0;
|
||||
|
@ -1069,8 +1069,7 @@ qemuMonitorInitBalloonObjectPath(qemuMonitorPtr mon,
|
||||
for (i = 0; i < nprops; i++) {
|
||||
if (STREQ(bprops[i]->name, "guest-stats-polling-interval")) {
|
||||
VIR_DEBUG("Found Balloon Object Path %s", path);
|
||||
mon->balloonpath = path;
|
||||
path = NULL;
|
||||
mon->balloonpath = g_steal_pointer(&path);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
@ -241,9 +241,8 @@ qemuMonitorJSONIOProcessLine(qemuMonitorPtr mon,
|
||||
PROBE(QEMU_MONITOR_RECV_REPLY,
|
||||
"mon=%p reply=%s", mon, line);
|
||||
if (msg) {
|
||||
msg->rxObject = obj;
|
||||
msg->rxObject = g_steal_pointer(&obj);
|
||||
msg->finished = 1;
|
||||
obj = NULL;
|
||||
ret = 0;
|
||||
} else {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
@ -7670,8 +7669,7 @@ qemuMonitorJSONGetDeviceAliases(qemuMonitorPtr mon,
|
||||
alias = *aliases;
|
||||
for (i = 0; i < n; i++) {
|
||||
if (STRPREFIX(paths[i]->type, "child<")) {
|
||||
*alias = paths[i]->name;
|
||||
paths[i]->name = NULL;
|
||||
*alias = g_steal_pointer(&paths[i]->name);
|
||||
alias++;
|
||||
}
|
||||
}
|
||||
|
@ -3061,8 +3061,7 @@ remoteDispatchDomainMigratePrepare(virNetServerPtr server G_GNUC_UNUSED,
|
||||
if (*uri_out == NULL) {
|
||||
ret->uri_out = NULL;
|
||||
} else {
|
||||
ret->uri_out = uri_out;
|
||||
uri_out = NULL;
|
||||
ret->uri_out = g_steal_pointer(&uri_out);
|
||||
}
|
||||
|
||||
rv = 0;
|
||||
@ -5871,9 +5870,8 @@ remoteDispatchConnectGetCPUModelNames(virNetServerPtr server G_GNUC_UNUSED,
|
||||
}
|
||||
|
||||
if (len && models) {
|
||||
ret->models.models_val = models;
|
||||
ret->models.models_val = g_steal_pointer(&models);
|
||||
ret->models.models_len = len;
|
||||
models = NULL;
|
||||
} else {
|
||||
ret->models.models_val = NULL;
|
||||
ret->models.models_len = 0;
|
||||
|
@ -3472,8 +3472,7 @@ remoteConnectFindStoragePoolSources(virConnectPtr conn,
|
||||
(xdrproc_t) xdr_remote_connect_find_storage_pool_sources_ret, (char *) &ret) == -1)
|
||||
goto done;
|
||||
|
||||
rv = ret.xml;
|
||||
ret.xml = NULL; /* To stop xdr_free free'ing it */
|
||||
rv = g_steal_pointer(&ret.xml); /* To stop xdr_free free'ing it */
|
||||
|
||||
xdr_free((xdrproc_t) xdr_remote_connect_find_storage_pool_sources_ret, (char *) &ret);
|
||||
|
||||
@ -6203,9 +6202,8 @@ remoteDomainMigrateFinish3(virConnectPtr dconn,
|
||||
_("caller ignores cookieout or cookieoutlen"));
|
||||
goto error;
|
||||
}
|
||||
*cookieout = ret.cookie_out.cookie_out_val; /* Caller frees. */
|
||||
*cookieout = g_steal_pointer(&ret.cookie_out.cookie_out_val); /* Caller frees. */
|
||||
*cookieoutlen = ret.cookie_out.cookie_out_len;
|
||||
ret.cookie_out.cookie_out_val = NULL;
|
||||
ret.cookie_out.cookie_out_len = 0;
|
||||
}
|
||||
|
||||
@ -6296,8 +6294,7 @@ remoteConnectGetCPUModelNames(virConnectPtr conn,
|
||||
retmodels = g_new0(char *, ret.models.models_len + 1);
|
||||
|
||||
for (i = 0; i < ret.models.models_len; i++) {
|
||||
retmodels[i] = ret.models.models_val[i];
|
||||
ret.models.models_val[i] = NULL;
|
||||
retmodels[i] = g_steal_pointer(&ret.models.models_val[i]);
|
||||
}
|
||||
*models = g_steal_pointer(&retmodels);
|
||||
}
|
||||
@ -7159,9 +7156,8 @@ remoteDomainMigrateFinish3Params(virConnectPtr dconn,
|
||||
_("caller ignores cookieout or cookieoutlen"));
|
||||
goto error;
|
||||
}
|
||||
*cookieout = ret.cookie_out.cookie_out_val; /* Caller frees. */
|
||||
*cookieout = g_steal_pointer(&ret.cookie_out.cookie_out_val); /* Caller frees. */
|
||||
*cookieoutlen = ret.cookie_out.cookie_out_len;
|
||||
ret.cookie_out.cookie_out_val = NULL;
|
||||
ret.cookie_out.cookie_out_len = 0;
|
||||
}
|
||||
|
||||
@ -7549,8 +7545,7 @@ remoteConnectGetAllDomainStats(virConnectPtr conn,
|
||||
&elem->nparams))
|
||||
goto cleanup;
|
||||
|
||||
tmpret[i] = elem;
|
||||
elem = NULL;
|
||||
tmpret[i] = g_steal_pointer(&elem);
|
||||
}
|
||||
|
||||
*retStats = g_steal_pointer(&tmpret);
|
||||
@ -7880,8 +7875,7 @@ remoteDomainRename(virDomainPtr dom, const char *new_name, unsigned int flags)
|
||||
|
||||
if (rv == 0) {
|
||||
VIR_FREE(dom->name);
|
||||
dom->name = tmp;
|
||||
tmp = NULL;
|
||||
dom->name = g_steal_pointer(&tmp);
|
||||
}
|
||||
|
||||
done:
|
||||
|
@ -189,10 +189,9 @@ static void virNetClientCallRemove(virNetClientCallPtr *head,
|
||||
while (tmp) {
|
||||
if (tmp == call) {
|
||||
if (prev)
|
||||
prev->next = tmp->next;
|
||||
prev->next = g_steal_pointer(&tmp->next);
|
||||
else
|
||||
*head = tmp->next;
|
||||
tmp->next = NULL;
|
||||
*head = g_steal_pointer(&tmp->next);
|
||||
return;
|
||||
}
|
||||
prev = tmp;
|
||||
@ -304,8 +303,7 @@ static virNetClientPtr virNetClientNew(virNetSocketPtr sock,
|
||||
if (!(client = virObjectLockableNew(virNetClientClass)))
|
||||
goto error;
|
||||
|
||||
client->sock = sock;
|
||||
sock = NULL;
|
||||
client->sock = g_steal_pointer(&sock);
|
||||
|
||||
client->eventCtx = g_main_context_new();
|
||||
client->eventLoop = g_main_loop_new(client->eventCtx, FALSE);
|
||||
@ -803,8 +801,7 @@ virNetClientCloseLocked(virNetClientPtr client)
|
||||
virObjectUnref(client->sasl);
|
||||
client->sasl = NULL;
|
||||
#endif
|
||||
ka = client->keepalive;
|
||||
client->keepalive = NULL;
|
||||
ka = g_steal_pointer(&client->keepalive);
|
||||
client->wantClose = false;
|
||||
|
||||
virFreeError(client->error);
|
||||
@ -1162,9 +1159,8 @@ virNetClientCallDispatchReply(virNetClientPtr client)
|
||||
thecall->msg->bufferOffset = client->msg.bufferOffset;
|
||||
|
||||
thecall->msg->nfds = client->msg.nfds;
|
||||
thecall->msg->fds = client->msg.fds;
|
||||
thecall->msg->fds = g_steal_pointer(&client->msg.fds);
|
||||
client->msg.nfds = 0;
|
||||
client->msg.fds = NULL;
|
||||
|
||||
thecall->mode = VIR_NET_CLIENT_MODE_COMPLETE;
|
||||
|
||||
|
@ -286,22 +286,18 @@ int virNetClientStreamSetError(virNetClientStreamPtr st,
|
||||
st->err.code = err.code;
|
||||
}
|
||||
if (err.message) {
|
||||
st->err.message = *err.message;
|
||||
*err.message = NULL;
|
||||
st->err.message = g_steal_pointer(&*err.message);
|
||||
}
|
||||
st->err.domain = err.domain;
|
||||
st->err.level = err.level;
|
||||
if (err.str1) {
|
||||
st->err.str1 = *err.str1;
|
||||
*err.str1 = NULL;
|
||||
st->err.str1 = g_steal_pointer(&*err.str1);
|
||||
}
|
||||
if (err.str2) {
|
||||
st->err.str2 = *err.str2;
|
||||
*err.str2 = NULL;
|
||||
st->err.str2 = g_steal_pointer(&*err.str2);
|
||||
}
|
||||
if (err.str3) {
|
||||
st->err.str3 = *err.str3;
|
||||
*err.str3 = NULL;
|
||||
st->err.str3 = g_steal_pointer(&*err.str3);
|
||||
}
|
||||
st->err.int1 = err.int1;
|
||||
st->err.int2 = err.int2;
|
||||
@ -343,10 +339,9 @@ int virNetClientStreamQueuePacket(virNetClientStreamPtr st,
|
||||
memcpy(&tmp_msg->header, &msg->header, sizeof(msg->header));
|
||||
|
||||
/* Steal message buffer */
|
||||
tmp_msg->buffer = msg->buffer;
|
||||
tmp_msg->buffer = g_steal_pointer(&msg->buffer);
|
||||
tmp_msg->bufferLength = msg->bufferLength;
|
||||
tmp_msg->bufferOffset = msg->bufferOffset;
|
||||
msg->buffer = NULL;
|
||||
msg->bufferLength = msg->bufferOffset = 0;
|
||||
|
||||
virObjectLock(st);
|
||||
|
@ -110,8 +110,7 @@ virNetMessagePtr virNetMessageQueueServe(virNetMessagePtr *queue)
|
||||
virNetMessagePtr tmp = *queue;
|
||||
|
||||
if (tmp) {
|
||||
*queue = tmp->next;
|
||||
tmp->next = NULL;
|
||||
*queue = g_steal_pointer(&tmp->next);
|
||||
}
|
||||
|
||||
return tmp;
|
||||
|
@ -999,8 +999,7 @@ virNetServerClientCloseLocked(virNetServerClientPtr client)
|
||||
|
||||
if (client->keepalive) {
|
||||
virKeepAliveStop(client->keepalive);
|
||||
ka = client->keepalive;
|
||||
client->keepalive = NULL;
|
||||
ka = g_steal_pointer(&client->keepalive);
|
||||
virObjectRef(client);
|
||||
virObjectUnlock(client);
|
||||
virObjectUnref(ka);
|
||||
@ -1398,8 +1397,7 @@ virNetServerClientDispatchWrite(virNetServerClientPtr client)
|
||||
virNetMessageClear(msg);
|
||||
msg->bufferLength = VIR_NET_MESSAGE_LEN_MAX;
|
||||
msg->buffer = g_new0(char, msg->bufferLength);
|
||||
client->rx = msg;
|
||||
msg = NULL;
|
||||
client->rx = g_steal_pointer(&msg);
|
||||
client->nrequests++;
|
||||
}
|
||||
}
|
||||
|
@ -2156,11 +2156,9 @@ static void virNetSocketEventFree(void *opaque)
|
||||
void *eopaque;
|
||||
|
||||
virObjectLock(sock);
|
||||
ff = sock->ff;
|
||||
eopaque = sock->opaque;
|
||||
ff = g_steal_pointer(&sock->ff);
|
||||
eopaque = g_steal_pointer(&sock->opaque);
|
||||
sock->func = NULL;
|
||||
sock->ff = NULL;
|
||||
sock->opaque = NULL;
|
||||
virObjectUnlock(sock);
|
||||
|
||||
if (ff)
|
||||
|
@ -240,8 +240,7 @@ virNetSSHKbIntCb(const char *name G_GNUC_UNUSED,
|
||||
|
||||
/* copy retrieved data back */
|
||||
for (i = 0; i < num_prompts; i++) {
|
||||
responses[i].text = askcred[i].result;
|
||||
askcred[i].result = NULL; /* steal the pointer */
|
||||
responses[i].text = g_steal_pointer(&askcred[i].result); /* steal the pointer */
|
||||
responses[i].length = askcred[i].resultlen;
|
||||
}
|
||||
|
||||
|
@ -924,8 +924,7 @@ int virNetTLSContextReloadForServer(virNetTLSContextPtr ctxt,
|
||||
g_autofree char *cert = NULL;
|
||||
g_autofree char *key = NULL;
|
||||
|
||||
x509credBak = ctxt->x509cred;
|
||||
ctxt->x509cred = NULL;
|
||||
x509credBak = g_steal_pointer(&ctxt->x509cred);
|
||||
|
||||
if (virNetTLSContextLocateCredentials(NULL, tryUserPkiPath, true,
|
||||
&cacert, &cacrl, &cert, &key))
|
||||
|
@ -112,7 +112,7 @@ virSecurityDACChownListAppend(virSecurityDACChownListPtr list,
|
||||
|
||||
tmp = g_strdup(path);
|
||||
|
||||
item->path = tmp;
|
||||
item->path = g_steal_pointer(&tmp);
|
||||
item->src = src;
|
||||
item->uid = uid;
|
||||
item->gid = gid;
|
||||
@ -122,8 +122,6 @@ virSecurityDACChownListAppend(virSecurityDACChownListPtr list,
|
||||
if (VIR_APPEND_ELEMENT(list->items, list->nItems, item) < 0)
|
||||
goto cleanup;
|
||||
|
||||
tmp = NULL;
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
VIR_FREE(tmp);
|
||||
|
@ -5829,8 +5829,7 @@ testInterfaceChangeRollback(virConnectPtr conn,
|
||||
}
|
||||
|
||||
virObjectUnref(privconn->ifaces);
|
||||
privconn->ifaces = privconn->backupIfaces;
|
||||
privconn->backupIfaces = NULL;
|
||||
privconn->ifaces = g_steal_pointer(&privconn->backupIfaces);
|
||||
|
||||
privconn->transaction_running = false;
|
||||
|
||||
|
@ -131,8 +131,7 @@ virConfFreeList(virConfValuePtr list)
|
||||
virConfValuePtr next;
|
||||
|
||||
while (list != NULL) {
|
||||
next = list->next;
|
||||
list->next = NULL;
|
||||
next = g_steal_pointer(&list->next);
|
||||
virConfFreeValue(list);
|
||||
list = next;
|
||||
}
|
||||
|
@ -173,8 +173,7 @@ virFDStreamMsgQueuePop(virFDStreamDataPtr fdst,
|
||||
char c;
|
||||
|
||||
if (tmp) {
|
||||
fdst->msg = tmp->next;
|
||||
tmp->next = NULL;
|
||||
fdst->msg = g_steal_pointer(&tmp->next);
|
||||
}
|
||||
|
||||
virCondSignal(&fdst->threadCond);
|
||||
|
@ -944,8 +944,7 @@ virJSONValueObjectRemoveKey(virJSONValuePtr object,
|
||||
for (i = 0; i < object->data.object.npairs; i++) {
|
||||
if (STREQ(object->data.object.pairs[i].key, key)) {
|
||||
if (value) {
|
||||
*value = object->data.object.pairs[i].value;
|
||||
object->data.object.pairs[i].value = NULL;
|
||||
*value = g_steal_pointer(&object->data.object.pairs[i].value);
|
||||
}
|
||||
VIR_FREE(object->data.object.pairs[i].key);
|
||||
virJSONValueFree(object->data.object.pairs[i].value);
|
||||
|
@ -3519,14 +3519,12 @@ vboxDumpDisplay(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine)
|
||||
|
||||
if (STREQ_NULLABLE(valueTypeUtf8, "sdl")) {
|
||||
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SDL;
|
||||
graphics->data.sdl.display = valueDisplayUtf8;
|
||||
valueDisplayUtf8 = NULL;
|
||||
graphics->data.sdl.display = g_steal_pointer(&valueDisplayUtf8);
|
||||
}
|
||||
|
||||
if (STREQ_NULLABLE(valueTypeUtf8, "gui")) {
|
||||
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP;
|
||||
graphics->data.desktop.display = valueDisplayUtf8;
|
||||
valueDisplayUtf8 = NULL;
|
||||
graphics->data.desktop.display = g_steal_pointer(&valueDisplayUtf8);
|
||||
}
|
||||
VBOX_UTF8_FREE(valueDisplayUtf8);
|
||||
} else if (STRNEQ_NULLABLE(valueTypeUtf8, "vrdp")) {
|
||||
|
@ -879,9 +879,7 @@ virVBoxSnapshotConfRemoveSnapshot(virVBoxSnapshotConfMachinePtr machine,
|
||||
|
||||
return 0;
|
||||
}
|
||||
parentSnapshot = snapshot->parent;
|
||||
|
||||
snapshot->parent = NULL;
|
||||
parentSnapshot = g_steal_pointer(&snapshot->parent);
|
||||
while (i < parentSnapshot->nchildren && parentSnapshot->children[i] != snapshot)
|
||||
++i;
|
||||
if (VIR_DELETE_ELEMENT(parentSnapshot->children, i, parentSnapshot->nchildren) < 0)
|
||||
@ -936,11 +934,10 @@ virVBoxSnapshotConfRemoveHardDisk(virVBoxSnapshotConfMediaRegistryPtr mediaRegis
|
||||
return 0;
|
||||
}
|
||||
|
||||
parentHardDisk = hardDisk->parent;
|
||||
parentHardDisk = g_steal_pointer(&hardDisk->parent);
|
||||
i = 0;
|
||||
while (i < parentHardDisk->nchildren && parentHardDisk->children[i] != hardDisk)
|
||||
++i;
|
||||
hardDisk->parent = NULL;
|
||||
if (VIR_DELETE_ELEMENT(parentHardDisk->children, i, parentHardDisk->nchildren) < 0)
|
||||
return -1;
|
||||
|
||||
|
@ -2604,15 +2604,13 @@ virVMXParseFileSystem(virConfPtr conf, int number, virDomainFSDefPtr *def)
|
||||
if (virVMXGetConfigString(conf, hostPath_name, &hostPath, false) < 0)
|
||||
goto cleanup;
|
||||
|
||||
(*def)->src->path = hostPath;
|
||||
hostPath = NULL;
|
||||
(*def)->src->path = g_steal_pointer(&hostPath);
|
||||
|
||||
/* vmx:guestName */
|
||||
if (virVMXGetConfigString(conf, guestName_name, &guestName, false) < 0)
|
||||
goto cleanup;
|
||||
|
||||
(*def)->dst = guestName;
|
||||
guestName = NULL;
|
||||
(*def)->dst = g_steal_pointer(&guestName);
|
||||
|
||||
/* vmx:writeAccess */
|
||||
if (virVMXGetConfigBoolean(conf, writeAccess_name, &writeAccess, false,
|
||||
@ -2819,9 +2817,7 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
|
||||
/* Setup virDomainNetDef */
|
||||
if (connectionType == NULL || STRCASEEQ(connectionType, "bridged")) {
|
||||
(*def)->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
|
||||
(*def)->data.bridge.brname = networkName;
|
||||
|
||||
networkName = NULL;
|
||||
(*def)->data.bridge.brname = g_steal_pointer(&networkName);
|
||||
} else if (STRCASEEQ(connectionType, "hostonly")) {
|
||||
/* FIXME */
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
@ -2833,11 +2829,8 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
|
||||
|
||||
} else if (STRCASEEQ(connectionType, "custom")) {
|
||||
(*def)->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
|
||||
(*def)->data.bridge.brname = networkName;
|
||||
(*def)->ifname = vnet;
|
||||
|
||||
networkName = NULL;
|
||||
vnet = NULL;
|
||||
(*def)->data.bridge.brname = g_steal_pointer(&networkName);
|
||||
(*def)->ifname = g_steal_pointer(&vnet);
|
||||
} else {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Invalid value '%s' for VMX entry '%s'"), connectionType,
|
||||
@ -2952,9 +2945,7 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
|
||||
if (!fileType || STRCASEEQ(fileType, "device")) {
|
||||
(*def)->target.port = port;
|
||||
(*def)->source->type = VIR_DOMAIN_CHR_TYPE_DEV;
|
||||
(*def)->source->data.file.path = fileName;
|
||||
|
||||
fileName = NULL;
|
||||
(*def)->source->data.file.path = g_steal_pointer(&fileName);
|
||||
} else if (STRCASEEQ(fileType, "file")) {
|
||||
(*def)->target.port = port;
|
||||
(*def)->source->type = VIR_DOMAIN_CHR_TYPE_FILE;
|
||||
@ -2970,9 +2961,7 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
|
||||
*/
|
||||
(*def)->target.port = port;
|
||||
(*def)->source->type = VIR_DOMAIN_CHR_TYPE_PIPE;
|
||||
(*def)->source->data.file.path = fileName;
|
||||
|
||||
fileName = NULL;
|
||||
(*def)->source->data.file.path = g_steal_pointer(&fileName);
|
||||
} else if (STRCASEEQ(fileType, "network")) {
|
||||
(*def)->target.port = port;
|
||||
(*def)->source->type = VIR_DOMAIN_CHR_TYPE_TCP;
|
||||
@ -3118,9 +3107,7 @@ virVMXParseParallel(virVMXContext *ctx, virConfPtr conf, int port,
|
||||
if (STRCASEEQ(fileType, "device")) {
|
||||
(*def)->target.port = port;
|
||||
(*def)->source->type = VIR_DOMAIN_CHR_TYPE_DEV;
|
||||
(*def)->source->data.file.path = fileName;
|
||||
|
||||
fileName = NULL;
|
||||
(*def)->source->data.file.path = g_steal_pointer(&fileName);
|
||||
} else if (STRCASEEQ(fileType, "file")) {
|
||||
(*def)->target.port = port;
|
||||
(*def)->source->type = VIR_DOMAIN_CHR_TYPE_FILE;
|
||||
|
@ -768,14 +768,12 @@ prlsdkGetFSInfo(PRL_HANDLE prldisk,
|
||||
if (!(buf = prlsdkGetStringParamVar(PrlVmDev_GetImagePath, prldisk)))
|
||||
goto cleanup;
|
||||
|
||||
fs->src->path = buf;
|
||||
buf = NULL;
|
||||
fs->src->path = g_steal_pointer(&buf);
|
||||
}
|
||||
if (!(buf = prlsdkGetStringParamVar(PrlVmDevHd_GetMountPoint, prldisk)))
|
||||
goto cleanup;
|
||||
|
||||
fs->dst = buf;
|
||||
buf = NULL;
|
||||
fs->dst = g_steal_pointer(&buf);
|
||||
|
||||
ret = 0;
|
||||
|
||||
@ -1176,19 +1174,16 @@ prlsdkGetSerialInfo(PRL_HANDLE serialPort, virDomainChrDefPtr chr)
|
||||
switch (emulatedType) {
|
||||
case PDT_USE_OUTPUT_FILE:
|
||||
chr->source->type = VIR_DOMAIN_CHR_TYPE_FILE;
|
||||
chr->source->data.file.path = friendlyName;
|
||||
friendlyName = NULL;
|
||||
chr->source->data.file.path = g_steal_pointer(&friendlyName);
|
||||
break;
|
||||
case PDT_USE_SERIAL_PORT_SOCKET_MODE:
|
||||
chr->source->type = VIR_DOMAIN_CHR_TYPE_UNIX;
|
||||
chr->source->data.nix.path = friendlyName;
|
||||
chr->source->data.nix.path = g_steal_pointer(&friendlyName);
|
||||
chr->source->data.nix.listen = socket_mode == PSP_SERIAL_SOCKET_SERVER;
|
||||
friendlyName = NULL;
|
||||
break;
|
||||
case PDT_USE_REAL_DEVICE:
|
||||
chr->source->type = VIR_DOMAIN_CHR_TYPE_DEV;
|
||||
chr->source->data.file.path = friendlyName;
|
||||
friendlyName = NULL;
|
||||
chr->source->data.file.path = g_steal_pointer(&friendlyName);
|
||||
break;
|
||||
case PDT_USE_TCP:
|
||||
chr->source->type = VIR_DOMAIN_CHR_TYPE_TCP;
|
||||
@ -1319,8 +1314,7 @@ prlsdkAddVNCInfo(PRL_HANDLE sdkdom, virDomainDefPtr def)
|
||||
goto error;
|
||||
|
||||
if (*passwd != '\0') {
|
||||
gr->data.vnc.auth.passwd = passwd;
|
||||
passwd = NULL;
|
||||
gr->data.vnc.auth.passwd = g_steal_pointer(&passwd);
|
||||
}
|
||||
|
||||
pret = PrlVmCfg_GetVNCPort(sdkdom, &port);
|
||||
|
@ -3857,10 +3857,8 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
|
||||
continue;
|
||||
}
|
||||
|
||||
vol.source = source;
|
||||
vol.target = target;
|
||||
source = NULL;
|
||||
target = NULL;
|
||||
vol.source = g_steal_pointer(&source);
|
||||
vol.target = g_steal_pointer(&target);
|
||||
if (VIR_APPEND_ELEMENT(vols, nvols, vol) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -1425,8 +1425,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd **partial)
|
||||
if (partial) {
|
||||
vshCmdOpt *arg = g_new0(vshCmdOpt, 1);
|
||||
arg->def = opt;
|
||||
arg->data = tkdata;
|
||||
tkdata = NULL;
|
||||
arg->data = g_steal_pointer(&tkdata);
|
||||
arg->next = NULL;
|
||||
|
||||
if (parser->pos - parser->originalLine == parser->point - 1)
|
||||
@ -1479,9 +1478,8 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd **partial)
|
||||
vshCmdOpt *arg = g_new0(vshCmdOpt, 1);
|
||||
|
||||
arg->def = opt;
|
||||
arg->data = tkdata;
|
||||
arg->data = g_steal_pointer(&tkdata);
|
||||
arg->next = NULL;
|
||||
tkdata = NULL;
|
||||
|
||||
if (parser->pos - parser->originalLine == parser->point)
|
||||
arg->completeThis = true;
|
||||
@ -1526,10 +1524,9 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd **partial)
|
||||
break;
|
||||
}
|
||||
|
||||
c->opts = first;
|
||||
c->opts = g_steal_pointer(&first);
|
||||
c->def = cmd;
|
||||
c->next = NULL;
|
||||
first = NULL;
|
||||
|
||||
if (!partial &&
|
||||
vshCommandCheckOpts(ctl, c, opts_required, opts_seen) < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user