util: use g_steal_pointer instead of VIR_STEAL_PTR

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Ján Tomko 2019-10-16 13:43:52 +02:00
parent 4f7c65da27
commit a3931b4996
22 changed files with 57 additions and 57 deletions

View File

@ -264,7 +264,7 @@ virCgroupV1ResolveMountLink(const char *mntDir,
VIR_WARN("Expecting a symlink at %s for controller %s", VIR_WARN("Expecting a symlink at %s for controller %s",
linkSrc, typeStr); linkSrc, typeStr);
} else { } else {
VIR_STEAL_PTR(controller->linkPoint, linkSrc); controller->linkPoint = g_steal_pointer(&linkSrc);
} }
} }
@ -412,7 +412,7 @@ virCgroupV1StealPlacement(virCgroupPtr group)
{ {
char *ret = NULL; char *ret = NULL;
VIR_STEAL_PTR(ret, group->legacy[VIR_CGROUP_CONTROLLER_SYSTEMD].placement); ret = g_steal_pointer(&group->legacy[VIR_CGROUP_CONTROLLER_SYSTEMD].placement);
return ret; return ret;
} }

View File

@ -244,7 +244,7 @@ virCgroupV2StealPlacement(virCgroupPtr group)
{ {
char *ret; char *ret;
VIR_STEAL_PTR(ret, group->unified.placement); ret = g_steal_pointer(&group->unified.placement);
return ret; return ret;
} }

View File

@ -762,7 +762,7 @@ virDBusMessageIterEncode(DBusMessageIter *rootiter,
goto cleanup; goto cleanup;
} }
VIR_FREE(contsig); VIR_FREE(contsig);
VIR_STEAL_PTR(iter, newiter); iter = g_steal_pointer(&newiter);
types = t + 1; types = t + 1;
nstruct = skiplen; nstruct = skiplen;
narray = (size_t)va_arg(args, int); narray = (size_t)va_arg(args, int);
@ -788,7 +788,7 @@ virDBusMessageIterEncode(DBusMessageIter *rootiter,
VIR_FREE(newiter); VIR_FREE(newiter);
goto cleanup; goto cleanup;
} }
VIR_STEAL_PTR(iter, newiter); iter = g_steal_pointer(&newiter);
types = vsig; types = vsig;
nstruct = strlen(types); nstruct = strlen(types);
narray = (size_t)-1; narray = (size_t)-1;
@ -819,7 +819,7 @@ virDBusMessageIterEncode(DBusMessageIter *rootiter,
goto cleanup; goto cleanup;
} }
VIR_FREE(contsig); VIR_FREE(contsig);
VIR_STEAL_PTR(iter, newiter); iter = g_steal_pointer(&newiter);
types = t + 1; types = t + 1;
nstruct = skiplen - 2; nstruct = skiplen - 2;
narray = (size_t)-1; narray = (size_t)-1;
@ -1056,7 +1056,7 @@ virDBusMessageIterDecode(DBusMessageIter *rootiter,
nstruct, narray) < 0) nstruct, narray) < 0)
goto cleanup; goto cleanup;
VIR_FREE(contsig); VIR_FREE(contsig);
VIR_STEAL_PTR(iter, newiter); iter = g_steal_pointer(&newiter);
types = t + 1; types = t + 1;
nstruct = skiplen; nstruct = skiplen;
if (arrayref) { if (arrayref) {
@ -1086,7 +1086,7 @@ virDBusMessageIterDecode(DBusMessageIter *rootiter,
VIR_DEBUG("Push failed"); VIR_DEBUG("Push failed");
goto cleanup; goto cleanup;
} }
VIR_STEAL_PTR(iter, newiter); iter = g_steal_pointer(&newiter);
types = vsig; types = vsig;
nstruct = strlen(types); nstruct = strlen(types);
narray = (size_t)-1; narray = (size_t)-1;
@ -1113,7 +1113,7 @@ virDBusMessageIterDecode(DBusMessageIter *rootiter,
nstruct, narray) < 0) nstruct, narray) < 0)
goto cleanup; goto cleanup;
VIR_FREE(contsig); VIR_FREE(contsig);
VIR_STEAL_PTR(iter, newiter); iter = g_steal_pointer(&newiter);
types = t + 1; types = t + 1;
nstruct = skiplen - 2; nstruct = skiplen - 2;
narray = (size_t)-1; narray = (size_t)-1;

View File

@ -150,7 +150,7 @@ virDevMapperGetTargetsImpl(const char *path,
if (virStringListMerge(&devPaths, &recursiveDevPaths) < 0) if (virStringListMerge(&devPaths, &recursiveDevPaths) < 0)
goto cleanup; goto cleanup;
VIR_STEAL_PTR(*devPaths_ret, devPaths); *devPaths_ret = g_steal_pointer(&devPaths);
ret = 0; ret = 0;
cleanup: cleanup:
virStringListFree(recursiveDevPaths); virStringListFree(recursiveDevPaths);

View File

@ -1497,7 +1497,7 @@ virLastErrorPrefixMessage(const char *fmt, ...)
goto cleanup; goto cleanup;
VIR_FREE(err->message); VIR_FREE(err->message);
VIR_STEAL_PTR(err->message, newmsg); err->message = g_steal_pointer(&newmsg);
cleanup: cleanup:
va_end(args); va_end(args);

View File

@ -4437,7 +4437,7 @@ virFileGetXAttrQuiet(const char *path,
break; break;
} }
VIR_STEAL_PTR(*value, buf); *value = g_steal_pointer(&buf);
ret = 0; ret = 0;
cleanup: cleanup:
VIR_FREE(buf); VIR_FREE(buf);

View File

@ -169,7 +169,7 @@ virFileCacheLoad(virFileCachePtr cache,
VIR_DEBUG("Loaded cached data '%s' for '%s'", file, name); VIR_DEBUG("Loaded cached data '%s' for '%s'", file, name);
ret = 1; ret = 1;
VIR_STEAL_PTR(*data, loadData); *data = g_steal_pointer(&loadData);
cleanup: cleanup:
virObjectUnref(loadData); virObjectUnref(loadData);

View File

@ -257,7 +257,7 @@ virHostdevGetPCIHostDevice(const virDomainHostdevDef *hostdev,
return -1; return -1;
} }
VIR_STEAL_PTR(*pci, actual); *pci = g_steal_pointer(&actual);
return 0; return 0;
} }

View File

@ -178,7 +178,7 @@ virStorageBackendIQNFound(const char *initiatoriqn,
goto cleanup; goto cleanup;
if (STREQ(iqn, initiatoriqn)) { if (STREQ(iqn, initiatoriqn)) {
VIR_STEAL_PTR(*ifacename, iface); *ifacename = g_steal_pointer(&iface);
VIR_DEBUG("Found interface '%s' with IQN '%s'", *ifacename, iqn); VIR_DEBUG("Found interface '%s' with IQN '%s'", *ifacename, iqn);
break; break;
@ -266,7 +266,7 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriqn,
iface_name, initiatoriqn); iface_name, initiatoriqn);
} }
VIR_STEAL_PTR(*ifacename, iface_name); *ifacename = g_steal_pointer(&iface_name);
return 0; return 0;
} }

View File

@ -880,7 +880,7 @@ virJSONValueObjectSteal(virJSONValuePtr object,
for (i = 0; i < object->data.object.npairs; i++) { for (i = 0; i < object->data.object.npairs; i++) {
if (STREQ(object->data.object.pairs[i].key, key)) { if (STREQ(object->data.object.pairs[i].key, key)) {
VIR_STEAL_PTR(obj, object->data.object.pairs[i].value); obj = g_steal_pointer(&object->data.object.pairs[i].value);
VIR_FREE(object->data.object.pairs[i].key); VIR_FREE(object->data.object.pairs[i].key);
VIR_DELETE_ELEMENT(object->data.object.pairs, i, VIR_DELETE_ELEMENT(object->data.object.pairs, i,
object->data.object.npairs); object->data.object.npairs);
@ -2155,7 +2155,7 @@ virJSONValueObjectDeflatten(virJSONValuePtr json)
deflattened) < 0) deflattened) < 0)
return NULL; return NULL;
VIR_STEAL_PTR(ret, deflattened); ret = g_steal_pointer(&deflattened);
return ret; return ret;
} }

View File

@ -156,7 +156,7 @@ virMediatedDeviceNew(const char *uuidstr, virMediatedDeviceModelType model)
if (VIR_ALLOC(dev) < 0) if (VIR_ALLOC(dev) < 0)
return NULL; return NULL;
VIR_STEAL_PTR(dev->path, sysfspath); dev->path = g_steal_pointer(&sysfspath);
/* Check whether the user-provided model corresponds with the actually /* Check whether the user-provided model corresponds with the actually
* supported mediated device's API. * supported mediated device's API.
@ -165,7 +165,7 @@ virMediatedDeviceNew(const char *uuidstr, virMediatedDeviceModelType model)
return NULL; return NULL;
dev->model = model; dev->model = model;
VIR_STEAL_PTR(ret, dev); ret = g_steal_pointer(&dev);
return ret; return ret;
} }
@ -521,7 +521,7 @@ virMediatedDeviceTypeReadAttrs(const char *sysfspath,
#undef MDEV_GET_SYSFS_ATTR #undef MDEV_GET_SYSFS_ATTR
VIR_STEAL_PTR(*type, tmp); *type = g_steal_pointer(&tmp);
return 0; return 0;
} }

View File

@ -399,7 +399,7 @@ int virNetDevTapCreate(char **ifname,
goto cleanup; goto cleanup;
if (virNetDevExists(newname) == 0) { if (virNetDevExists(newname) == 0) {
VIR_STEAL_PTR(newifname, newname); newifname = g_steal_pointer(&newname);
break; break;
} }
} }

View File

@ -317,7 +317,7 @@ int virNetlinkCommand(struct nl_msg *nl_msg,
return -1; return -1;
} }
VIR_STEAL_PTR(*resp, temp_resp); *resp = g_steal_pointer(&temp_resp);
*respbuflen = len; *respbuflen = len;
return 0; return 0;
} }
@ -466,7 +466,7 @@ virNetlinkDumpLink(const char *ifname, int ifindex,
goto malformed_resp; goto malformed_resp;
} }
VIR_STEAL_PTR(*nlData, resp); *nlData = g_steal_pointer(&resp);
return 0; return 0;
malformed_resp: malformed_resp:
@ -737,7 +737,7 @@ virNetlinkGetNeighbor(void **nlData, uint32_t src_pid, uint32_t dst_pid)
goto malformed_resp; goto malformed_resp;
} }
VIR_STEAL_PTR(*nlData, resp); *nlData = g_steal_pointer(&resp);
return recvbuflen; return recvbuflen;
malformed_resp: malformed_resp:

View File

@ -293,7 +293,7 @@ virNumaGetNodeCPUs(int node,
} }
} }
VIR_STEAL_PTR(*cpus, cpumap); *cpus = g_steal_pointer(&cpumap);
return ncpus; return ncpus;
} }
# undef MASK_CPU_ISSET # undef MASK_CPU_ISSET
@ -337,7 +337,7 @@ virNumaNodesetToCPUset(virBitmapPtr nodeset,
return -1; return -1;
} }
VIR_STEAL_PTR(*cpuset, allNodesCPUs); *cpuset = g_steal_pointer(&allNodesCPUs);
return 0; return 0;
} }

View File

@ -489,7 +489,7 @@ virPCIDeviceIterDevices(virPCIDeviceIterPredicate predicate,
break; break;
} else if (rc == 1) { } else if (rc == 1) {
VIR_DEBUG("%s %s: iter matched on %s", dev->id, dev->name, check->name); VIR_DEBUG("%s %s: iter matched on %s", dev->id, dev->name, check->name);
VIR_STEAL_PTR(*matched, check); *matched = g_steal_pointer(&check);
ret = 1; ret = 1;
break; break;
} }
@ -2648,7 +2648,7 @@ virPCIGetMdevTypes(const char *sysfspath,
if (dirret < 0) if (dirret < 0)
goto cleanup; goto cleanup;
VIR_STEAL_PTR(*types, mdev_types); *types = g_steal_pointer(&mdev_types);
ret = ntypes; ret = ntypes;
ntypes = 0; ntypes = 0;
cleanup: cleanup:

View File

@ -610,7 +610,7 @@ virResctrlGetCacheInfo(virResctrlInfoPtr resctrl,
goto cleanup; goto cleanup;
} }
VIR_STEAL_PTR(i_level->types[type], i_type); i_level->types[type] = g_steal_pointer(&i_type);
} }
ret = 0; ret = 0;
@ -666,7 +666,7 @@ virResctrlGetMemoryBandwidthInfo(virResctrlInfoPtr resctrl)
if (rv < 0) if (rv < 0)
goto cleanup; goto cleanup;
VIR_STEAL_PTR(resctrl->membw_info, i_membw); resctrl->membw_info = g_steal_pointer(&i_membw);
ret = 0; ret = 0;
cleanup: cleanup:
VIR_FREE(i_membw); VIR_FREE(i_membw);
@ -748,8 +748,8 @@ virResctrlGetMonitorInfo(virResctrlInfoPtr resctrl)
VIR_DEBUG("Resctrl supported %zd monitoring features", nfeatures); VIR_DEBUG("Resctrl supported %zd monitoring features", nfeatures);
info_monitor->nfeatures = nfeatures; info_monitor->nfeatures = nfeatures;
VIR_STEAL_PTR(info_monitor->features, features); info_monitor->features = g_steal_pointer(&features);
VIR_STEAL_PTR(resctrl->monitor_info, info_monitor); resctrl->monitor_info = g_steal_pointer(&info_monitor);
ret = 0; ret = 0;
cleanup: cleanup:
@ -1025,7 +1025,7 @@ virResctrlInfoGetMonitorPrefix(virResctrlInfoPtr resctrl,
goto cleanup; goto cleanup;
} }
VIR_STEAL_PTR(*monitor, mon); *monitor = g_steal_pointer(&mon);
cleanup: cleanup:
virResctrlInfoMonFree(mon); virResctrlInfoMonFree(mon);
return ret; return ret;

View File

@ -406,7 +406,7 @@ virRotatingFileWriterRollover(virRotatingFileWriterPtr file)
} }
VIR_FREE(nextpath); VIR_FREE(nextpath);
VIR_STEAL_PTR(nextpath, thispath); nextpath = g_steal_pointer(&thispath);
} }
} }

View File

@ -238,7 +238,7 @@ virSCSIDeviceNew(const char *sysfs_prefix,
if (virAsprintf(&dev->id, "%s:%s", vendor, model) < 0) if (virAsprintf(&dev->id, "%s:%s", vendor, model) < 0)
return NULL; return NULL;
VIR_STEAL_PTR(ret, dev); ret = g_steal_pointer(&dev);
return ret; return ret;
} }

View File

@ -269,7 +269,7 @@ virSCSIVHostDeviceNew(const char *name)
VIR_DEBUG("%s: initialized", dev->name); VIR_DEBUG("%s: initialized", dev->name);
VIR_STEAL_PTR(ret, dev); ret = g_steal_pointer(&dev);
return ret; return ret;
} }

View File

@ -310,7 +310,7 @@ virStorageEncryptionParseNode(xmlNodePtr node,
} }
} }
VIR_STEAL_PTR(ret, encdef); ret = g_steal_pointer(&encdef);
cleanup: cleanup:
VIR_FREE(format_str); VIR_FREE(format_str);

View File

@ -1141,7 +1141,7 @@ virStorageFileMetadataNew(const char *path,
if (VIR_STRDUP(def->path, path) < 0) if (VIR_STRDUP(def->path, path) < 0)
return NULL; return NULL;
VIR_STEAL_PTR(ret, def); ret = g_steal_pointer(&def);
return ret; return ret;
} }
@ -1240,7 +1240,7 @@ virStorageFileGetMetadataFromFD(const char *path,
* update the metadata.*/ * update the metadata.*/
meta->type = VIR_STORAGE_TYPE_DIR; meta->type = VIR_STORAGE_TYPE_DIR;
meta->format = VIR_STORAGE_FILE_DIR; meta->format = VIR_STORAGE_FILE_DIR;
VIR_STEAL_PTR(ret, meta); ret = g_steal_pointer(&meta);
return ret; return ret;
} }
@ -1262,7 +1262,7 @@ virStorageFileGetMetadataFromFD(const char *path,
else if (S_ISBLK(sb.st_mode)) else if (S_ISBLK(sb.st_mode))
meta->type = VIR_STORAGE_TYPE_BLOCK; meta->type = VIR_STORAGE_TYPE_BLOCK;
VIR_STEAL_PTR(ret, meta); ret = g_steal_pointer(&meta);
return ret; return ret;
} }
@ -1867,7 +1867,7 @@ virStorageAuthDefCopy(const virStorageAuthDef *src)
if (virSecretLookupDefCopy(&authdef->seclookupdef, &src->seclookupdef) < 0) if (virSecretLookupDefCopy(&authdef->seclookupdef, &src->seclookupdef) < 0)
return NULL; return NULL;
VIR_STEAL_PTR(ret, authdef); ret = g_steal_pointer(&authdef);
return ret; return ret;
} }
@ -1924,7 +1924,7 @@ virStorageAuthDefParse(xmlNodePtr node,
if (virSecretLookupParseSecret(secretnode, &authdef->seclookupdef) < 0) if (virSecretLookupParseSecret(secretnode, &authdef->seclookupdef) < 0)
goto cleanup; goto cleanup;
VIR_STEAL_PTR(ret, authdef); ret = g_steal_pointer(&authdef);
cleanup: cleanup:
ctxt->node = saveNode; ctxt->node = saveNode;
@ -2028,8 +2028,8 @@ virStoragePRDefParseXML(xmlXPathContextPtr ctxt)
goto cleanup; goto cleanup;
} }
VIR_STEAL_PTR(prd->path, path); prd->path = g_steal_pointer(&path);
VIR_STEAL_PTR(ret, prd); ret = g_steal_pointer(&prd);
cleanup: cleanup:
virStoragePRDefFree(prd); virStoragePRDefFree(prd);
@ -2113,7 +2113,7 @@ virStoragePRDefCopy(virStoragePRDefPtr src)
VIR_STRDUP(copy->mgralias, src->mgralias) < 0) VIR_STRDUP(copy->mgralias, src->mgralias) < 0)
goto cleanup; goto cleanup;
VIR_STEAL_PTR(ret, copy); ret = g_steal_pointer(&copy);
cleanup: cleanup:
virStoragePRDefFree(copy); virStoragePRDefFree(copy);
@ -2346,7 +2346,7 @@ virStorageSourceCopy(const virStorageSource *src,
return NULL; return NULL;
} }
VIR_STEAL_PTR(ret, def); ret = g_steal_pointer(&def);
return ret; return ret;
} }
@ -2671,7 +2671,7 @@ virStorageSourceNewFromBackingRelative(virStorageSourcePtr parent,
def->type = VIR_STORAGE_TYPE_FILE; def->type = VIR_STORAGE_TYPE_FILE;
} }
VIR_STEAL_PTR(ret, def); ret = g_steal_pointer(&def);
return ret; return ret;
} }
@ -2854,7 +2854,7 @@ virStorageSourceParseRBDColonString(const char *rbdstr,
/* pool vs. image name */ /* pool vs. image name */
if ((p = strchr(src->path, '/'))) { if ((p = strchr(src->path, '/'))) {
VIR_STEAL_PTR(src->volume, src->path); src->volume = g_steal_pointer(&src->path);
if (VIR_STRDUP(src->path, p + 1) < 0) if (VIR_STRDUP(src->path, p + 1) < 0)
return -1; return -1;
*p = '\0'; *p = '\0';
@ -2897,7 +2897,7 @@ virStorageSourceParseRBDColonString(const char *rbdstr,
if (VIR_STRDUP(authdef->secrettype, if (VIR_STRDUP(authdef->secrettype,
virSecretUsageTypeToString(VIR_SECRET_USAGE_TYPE_CEPH)) < 0) virSecretUsageTypeToString(VIR_SECRET_USAGE_TYPE_CEPH)) < 0)
return -1; return -1;
VIR_STEAL_PTR(src->auth, authdef); src->auth = g_steal_pointer(&authdef);
src->authInherited = true; src->authInherited = true;
/* Cannot formulate a secretType (eg, usage or uuid) given /* Cannot formulate a secretType (eg, usage or uuid) given
@ -3720,7 +3720,7 @@ virStorageSourceNewFromBackingAbsolute(const char *path,
} }
} }
VIR_STEAL_PTR(*src, def); *src = g_steal_pointer(&def);
return rc; return rc;
} }
@ -3779,7 +3779,7 @@ virStorageSourceNewFromChild(virStorageSourcePtr parent,
def->detected = true; def->detected = true;
VIR_STEAL_PTR(*child, def); *child = g_steal_pointer(&def);
return rc; return rc;
} }
@ -4266,7 +4266,7 @@ virStorageFileGetRelativeBackingPath(virStorageSourcePtr top,
return -1; return -1;
} }
VIR_STEAL_PTR(*relpath, path); *relpath = g_steal_pointer(&path);
return 0; return 0;
} }
@ -5025,7 +5025,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
goto cleanup; goto cleanup;
} }
VIR_STEAL_PTR(src->backingStore, backingStore); src->backingStore = g_steal_pointer(&backingStore);
if (src->externalDataStoreRaw) { if (src->externalDataStoreRaw) {
g_autoptr(virStorageSource) externalDataStore = NULL; g_autoptr(virStorageSource) externalDataStore = NULL;
@ -5040,7 +5040,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
goto cleanup; goto cleanup;
} }
VIR_STEAL_PTR(src->externalDataStore, externalDataStore); src->externalDataStore = g_steal_pointer(&externalDataStore);
} }
ret = 0; ret = 0;
@ -5150,6 +5150,6 @@ virStorageFileGetBackingStoreStr(virStorageSourcePtr src,
if (virStorageFileGetMetadataInternal(tmp, buf, headerLen, NULL) < 0) if (virStorageFileGetMetadataInternal(tmp, buf, headerLen, NULL) < 0)
return -1; return -1;
VIR_STEAL_PTR(*backing, tmp->backingStoreRaw); *backing = g_steal_pointer(&tmp->backingStoreRaw);
return 0; return 0;
} }

View File

@ -761,7 +761,7 @@ virTypedParamListStealParams(virTypedParamListPtr list,
{ {
size_t ret = list->npar; size_t ret = list->npar;
VIR_STEAL_PTR(*params, list->par); *params = g_steal_pointer(&list->par);
list->npar = 0; list->npar = 0;
list->par_alloc = 0; list->par_alloc = 0;