mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
src: Use g_steal_pointer() more
There are few places where the g_steal_pointer() is open coded. Switch them to calling the g_steal_pointer() function instead. Generated by the following spatch: @ rule1 @ expression a, b; @@ <... - b = a; ... when != b - a = NULL; + b = g_steal_pointer(&a); ...> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
a7c016e4cb
commit
2c0898ff4e
@ -1033,8 +1033,7 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path)
|
|||||||
if (root != ctx->service->rootFolder)
|
if (root != ctx->service->rootFolder)
|
||||||
esxVI_ManagedObjectReference_Free(&root);
|
esxVI_ManagedObjectReference_Free(&root);
|
||||||
|
|
||||||
root = folder->_reference;
|
root = g_steal_pointer(&folder->_reference);
|
||||||
folder->_reference = NULL;
|
|
||||||
} else {
|
} else {
|
||||||
/* Try to lookup item as a datacenter */
|
/* Try to lookup item as a datacenter */
|
||||||
if (esxVI_LookupDatacenter(ctx, item, root, NULL, &ctx->datacenter,
|
if (esxVI_LookupDatacenter(ctx, item, root, NULL, &ctx->datacenter,
|
||||||
@ -1087,8 +1086,7 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path)
|
|||||||
if (root != ctx->datacenter->hostFolder)
|
if (root != ctx->datacenter->hostFolder)
|
||||||
esxVI_ManagedObjectReference_Free(&root);
|
esxVI_ManagedObjectReference_Free(&root);
|
||||||
|
|
||||||
root = folder->_reference;
|
root = g_steal_pointer(&folder->_reference);
|
||||||
folder->_reference = NULL;
|
|
||||||
} else {
|
} else {
|
||||||
/* Try to lookup item as a compute resource */
|
/* Try to lookup item as a compute resource */
|
||||||
if (esxVI_LookupComputeResource(ctx, item, root, NULL,
|
if (esxVI_LookupComputeResource(ctx, item, root, NULL,
|
||||||
|
@ -1780,8 +1780,7 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
|
|||||||
|
|
||||||
priv->version = g_strdup(os->data->Version);
|
priv->version = g_strdup(os->data->Version);
|
||||||
|
|
||||||
conn->privateData = priv;
|
conn->privateData = g_steal_pointer(&priv);
|
||||||
priv = NULL;
|
|
||||||
result = VIR_DRV_OPEN_SUCCESS;
|
result = VIR_DRV_OPEN_SUCCESS;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -3519,8 +3518,7 @@ hypervConnectListAllDomains(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (doms)
|
if (doms)
|
||||||
*domains = doms;
|
*domains = g_steal_pointer(&doms);
|
||||||
doms = NULL;
|
|
||||||
ret = count;
|
ret = count;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -994,8 +994,7 @@ hypervEnumAndPull(hypervPrivate *priv, hypervWqlQuery *wqlQuery,
|
|||||||
response = NULL;
|
response = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*list = head;
|
*list = g_steal_pointer(&head);
|
||||||
head = NULL;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -586,8 +586,7 @@ virHostdevRestoreNetConfig(virDomainHostdevDef *hostdev,
|
|||||||
*/
|
*/
|
||||||
if (MAC) {
|
if (MAC) {
|
||||||
VIR_FREE(adminMAC);
|
VIR_FREE(adminMAC);
|
||||||
adminMAC = MAC;
|
adminMAC = g_steal_pointer(&MAC);
|
||||||
MAC = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ignore_value(virNetDevSetNetConfig(linkdev, vf,
|
ignore_value(virNetDevSetNetConfig(linkdev, vf,
|
||||||
|
@ -682,9 +682,8 @@ xenParseVfb(virConf *conf, virDomainDef *def)
|
|||||||
if (xenConfigCopyStringOpt(conf, "keymap", &graphics->data.vnc.keymap) < 0)
|
if (xenConfigCopyStringOpt(conf, "keymap", &graphics->data.vnc.keymap) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
def->graphics = g_new0(virDomainGraphicsDef *, 1);
|
def->graphics = g_new0(virDomainGraphicsDef *, 1);
|
||||||
def->graphics[0] = graphics;
|
def->graphics[0] = g_steal_pointer(&graphics);
|
||||||
def->ngraphics = 1;
|
def->ngraphics = 1;
|
||||||
graphics = NULL;
|
|
||||||
} else {
|
} else {
|
||||||
if (xenConfigGetBool(conf, "sdl", &val, 0) < 0)
|
if (xenConfigGetBool(conf, "sdl", &val, 0) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -696,9 +695,8 @@ xenParseVfb(virConf *conf, virDomainDef *def)
|
|||||||
if (xenConfigCopyStringOpt(conf, "xauthority", &graphics->data.sdl.xauth) < 0)
|
if (xenConfigCopyStringOpt(conf, "xauthority", &graphics->data.sdl.xauth) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
def->graphics = g_new0(virDomainGraphicsDef *, 1);
|
def->graphics = g_new0(virDomainGraphicsDef *, 1);
|
||||||
def->graphics[0] = graphics;
|
def->graphics[0] = g_steal_pointer(&graphics);
|
||||||
def->ngraphics = 1;
|
def->ngraphics = 1;
|
||||||
graphics = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -774,9 +772,8 @@ xenParseVfb(virConf *conf, virDomainDef *def)
|
|||||||
VIR_FREE(listenAddr);
|
VIR_FREE(listenAddr);
|
||||||
}
|
}
|
||||||
def->graphics = g_new0(virDomainGraphicsDef *, 1);
|
def->graphics = g_new0(virDomainGraphicsDef *, 1);
|
||||||
def->graphics[0] = graphics;
|
def->graphics[0] = g_steal_pointer(&graphics);
|
||||||
def->ngraphics = 1;
|
def->ngraphics = 1;
|
||||||
graphics = NULL;
|
|
||||||
} else {
|
} else {
|
||||||
if (xenHandleConfGetValueStringListErrors(rc) < 0)
|
if (xenHandleConfGetValueStringListErrors(rc) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -953,9 +950,8 @@ xenParseCharDev(virConf *conf, virDomainDef *def, const char *nativeFormat)
|
|||||||
|
|
||||||
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
|
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
|
||||||
chr->target.port = 0;
|
chr->target.port = 0;
|
||||||
def->parallels[0] = chr;
|
def->parallels[0] = g_steal_pointer(&chr);
|
||||||
def->nparallels++;
|
def->nparallels++;
|
||||||
chr = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to get the list of values to support multiple serial ports */
|
/* Try to get the list of values to support multiple serial ports */
|
||||||
|
@ -4297,8 +4297,7 @@ qemuDomainChangeGraphics(virQEMUDriver *driver,
|
|||||||
|
|
||||||
/* Steal the new dev's char * reference */
|
/* Steal the new dev's char * reference */
|
||||||
VIR_FREE(olddev->data.vnc.auth.passwd);
|
VIR_FREE(olddev->data.vnc.auth.passwd);
|
||||||
olddev->data.vnc.auth.passwd = dev->data.vnc.auth.passwd;
|
olddev->data.vnc.auth.passwd = g_steal_pointer(&dev->data.vnc.auth.passwd);
|
||||||
dev->data.vnc.auth.passwd = NULL;
|
|
||||||
olddev->data.vnc.auth.validTo = dev->data.vnc.auth.validTo;
|
olddev->data.vnc.auth.validTo = dev->data.vnc.auth.validTo;
|
||||||
olddev->data.vnc.auth.expires = dev->data.vnc.auth.expires;
|
olddev->data.vnc.auth.expires = dev->data.vnc.auth.expires;
|
||||||
olddev->data.vnc.auth.connected = dev->data.vnc.auth.connected;
|
olddev->data.vnc.auth.connected = dev->data.vnc.auth.connected;
|
||||||
@ -4345,8 +4344,7 @@ qemuDomainChangeGraphics(virQEMUDriver *driver,
|
|||||||
|
|
||||||
/* Steal the new dev's char * reference */
|
/* Steal the new dev's char * reference */
|
||||||
VIR_FREE(olddev->data.spice.auth.passwd);
|
VIR_FREE(olddev->data.spice.auth.passwd);
|
||||||
olddev->data.spice.auth.passwd = dev->data.spice.auth.passwd;
|
olddev->data.spice.auth.passwd = g_steal_pointer(&dev->data.spice.auth.passwd);
|
||||||
dev->data.spice.auth.passwd = NULL;
|
|
||||||
olddev->data.spice.auth.validTo = dev->data.spice.auth.validTo;
|
olddev->data.spice.auth.validTo = dev->data.spice.auth.validTo;
|
||||||
olddev->data.spice.auth.expires = dev->data.spice.auth.expires;
|
olddev->data.spice.auth.expires = dev->data.spice.auth.expires;
|
||||||
olddev->data.spice.auth.connected = dev->data.spice.auth.connected;
|
olddev->data.spice.auth.connected = dev->data.spice.auth.connected;
|
||||||
|
@ -3029,8 +3029,7 @@ qemuMigrationDstPrepareAny(virQEMUDriver *driver,
|
|||||||
if (mig->lockState) {
|
if (mig->lockState) {
|
||||||
VIR_DEBUG("Received lockstate %s", mig->lockState);
|
VIR_DEBUG("Received lockstate %s", mig->lockState);
|
||||||
VIR_FREE(priv->lockState);
|
VIR_FREE(priv->lockState);
|
||||||
priv->lockState = mig->lockState;
|
priv->lockState = g_steal_pointer(&mig->lockState);
|
||||||
mig->lockState = NULL;
|
|
||||||
} else {
|
} else {
|
||||||
VIR_DEBUG("Received no lockstate");
|
VIR_DEBUG("Received no lockstate");
|
||||||
}
|
}
|
||||||
@ -5598,8 +5597,7 @@ qemuMigrationDstPersist(virQEMUDriver *driver,
|
|||||||
error:
|
error:
|
||||||
virDomainDefFree(vm->newDef);
|
virDomainDefFree(vm->newDef);
|
||||||
vm->persistent = oldPersist;
|
vm->persistent = oldPersist;
|
||||||
vm->newDef = oldDef;
|
vm->newDef = g_steal_pointer(&oldDef);
|
||||||
oldDef = NULL;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5778,8 +5776,7 @@ qemuMigrationDstFinish(virQEMUDriver *driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mig->jobInfo) {
|
if (mig->jobInfo) {
|
||||||
jobInfo = mig->jobInfo;
|
jobInfo = g_steal_pointer(&mig->jobInfo);
|
||||||
mig->jobInfo = NULL;
|
|
||||||
|
|
||||||
if (jobInfo->sent && timeReceived) {
|
if (jobInfo->sent && timeReceived) {
|
||||||
jobInfo->timeDelta = timeReceived - jobInfo->sent;
|
jobInfo->timeDelta = timeReceived - jobInfo->sent;
|
||||||
|
@ -290,13 +290,10 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterState *state,
|
|||||||
if (meta->capacity)
|
if (meta->capacity)
|
||||||
vol->target.capacity = meta->capacity;
|
vol->target.capacity = meta->capacity;
|
||||||
if (meta->encryption) {
|
if (meta->encryption) {
|
||||||
vol->target.encryption = meta->encryption;
|
vol->target.encryption = g_steal_pointer(&meta->encryption);
|
||||||
meta->encryption = NULL;
|
|
||||||
}
|
}
|
||||||
vol->target.features = meta->features;
|
vol->target.features = g_steal_pointer(&meta->features);
|
||||||
meta->features = NULL;
|
vol->target.compat = g_steal_pointer(&meta->compat);
|
||||||
vol->target.compat = meta->compat;
|
|
||||||
meta->compat = NULL;
|
|
||||||
|
|
||||||
*volptr = g_steal_pointer(&vol);
|
*volptr = g_steal_pointer(&vol);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
@ -3443,8 +3443,7 @@ storageBackendProbeTarget(virStorageSource *target,
|
|||||||
|
|
||||||
target->backingStore = virStorageSourceNew();
|
target->backingStore = virStorageSourceNew();
|
||||||
target->backingStore->type = VIR_STORAGE_TYPE_NETWORK;
|
target->backingStore->type = VIR_STORAGE_TYPE_NETWORK;
|
||||||
target->backingStore->path = meta->backingStoreRaw;
|
target->backingStore->path = g_steal_pointer(&meta->backingStoreRaw);
|
||||||
meta->backingStoreRaw = NULL;
|
|
||||||
target->backingStore->format = VIR_STORAGE_FILE_RAW;
|
target->backingStore->format = VIR_STORAGE_FILE_RAW;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3479,8 +3478,7 @@ storageBackendProbeTarget(virStorageSource *target,
|
|||||||
if (meta->encryption->payload_offset != -1)
|
if (meta->encryption->payload_offset != -1)
|
||||||
target->capacity -= meta->encryption->payload_offset * 512;
|
target->capacity -= meta->encryption->payload_offset * 512;
|
||||||
|
|
||||||
*encryption = meta->encryption;
|
*encryption = g_steal_pointer(&meta->encryption);
|
||||||
meta->encryption = NULL;
|
|
||||||
|
|
||||||
/* XXX ideally we'd fill in secret UUID here
|
/* XXX ideally we'd fill in secret UUID here
|
||||||
* but we cannot guarantee 'conn' is non-NULL
|
* but we cannot guarantee 'conn' is non-NULL
|
||||||
|
@ -967,8 +967,7 @@ int virFileNBDDeviceAssociate(const char *file,
|
|||||||
|
|
||||||
VIR_DEBUG("Associated NBD device %s with file %s and format %s",
|
VIR_DEBUG("Associated NBD device %s with file %s and format %s",
|
||||||
nbddev, file, fmtstr);
|
nbddev, file, fmtstr);
|
||||||
*dev = nbddev;
|
*dev = g_steal_pointer(&nbddev);
|
||||||
nbddev = NULL;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,6 @@ virLeaseNew(virJSONValue **lease_ret,
|
|||||||
if (virJSONValueObjectAppendNumberLong(lease_new, "expiry-time", expirytime) < 0)
|
if (virJSONValueObjectAppendNumberLong(lease_new, "expiry-time", expirytime) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
*lease_ret = lease_new;
|
*lease_ret = g_steal_pointer(&lease_new);
|
||||||
lease_new = NULL;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -839,16 +839,13 @@ virNumaGetPages(int node,
|
|||||||
} while (exchange);
|
} while (exchange);
|
||||||
|
|
||||||
if (pages_size) {
|
if (pages_size) {
|
||||||
*pages_size = tmp_size;
|
*pages_size = g_steal_pointer(&tmp_size);
|
||||||
tmp_size = NULL;
|
|
||||||
}
|
}
|
||||||
if (pages_avail) {
|
if (pages_avail) {
|
||||||
*pages_avail = tmp_avail;
|
*pages_avail = g_steal_pointer(&tmp_avail);
|
||||||
tmp_avail = NULL;
|
|
||||||
}
|
}
|
||||||
if (pages_free) {
|
if (pages_free) {
|
||||||
*pages_free = tmp_free;
|
*pages_free = g_steal_pointer(&tmp_free);
|
||||||
tmp_free = NULL;
|
|
||||||
}
|
}
|
||||||
*npages = ntmp;
|
*npages = ntmp;
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user