From a3931b4996e46db409ad031e0230a507fb303287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Wed, 16 Oct 2019 13:43:52 +0200 Subject: [PATCH] util: use g_steal_pointer instead of VIR_STEAL_PTR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ján Tomko Reviewed-by: Michal Privoznik --- src/util/vircgroupv1.c | 4 ++-- src/util/vircgroupv2.c | 2 +- src/util/virdbus.c | 12 +++++------ src/util/virdevmapper.c | 2 +- src/util/virerror.c | 2 +- src/util/virfile.c | 2 +- src/util/virfilecache.c | 2 +- src/util/virhostdev.c | 2 +- src/util/viriscsi.c | 4 ++-- src/util/virjson.c | 4 ++-- src/util/virmdev.c | 6 +++--- src/util/virnetdevtap.c | 2 +- src/util/virnetlink.c | 6 +++--- src/util/virnuma.c | 4 ++-- src/util/virpci.c | 4 ++-- src/util/virresctrl.c | 10 ++++----- src/util/virrotatingfile.c | 2 +- src/util/virscsi.c | 2 +- src/util/virscsivhost.c | 2 +- src/util/virstorageencryption.c | 2 +- src/util/virstoragefile.c | 36 ++++++++++++++++----------------- src/util/virtypedparam.c | 2 +- 22 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index d23045331e..6ab79a1897 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -264,7 +264,7 @@ virCgroupV1ResolveMountLink(const char *mntDir, VIR_WARN("Expecting a symlink at %s for controller %s", linkSrc, typeStr); } else { - VIR_STEAL_PTR(controller->linkPoint, linkSrc); + controller->linkPoint = g_steal_pointer(&linkSrc); } } @@ -412,7 +412,7 @@ virCgroupV1StealPlacement(virCgroupPtr group) { 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; } diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 403b3b145e..621ab71eb5 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -244,7 +244,7 @@ virCgroupV2StealPlacement(virCgroupPtr group) { char *ret; - VIR_STEAL_PTR(ret, group->unified.placement); + ret = g_steal_pointer(&group->unified.placement); return ret; } diff --git a/src/util/virdbus.c b/src/util/virdbus.c index f423305e11..f54c917c03 100644 --- a/src/util/virdbus.c +++ b/src/util/virdbus.c @@ -762,7 +762,7 @@ virDBusMessageIterEncode(DBusMessageIter *rootiter, goto cleanup; } VIR_FREE(contsig); - VIR_STEAL_PTR(iter, newiter); + iter = g_steal_pointer(&newiter); types = t + 1; nstruct = skiplen; narray = (size_t)va_arg(args, int); @@ -788,7 +788,7 @@ virDBusMessageIterEncode(DBusMessageIter *rootiter, VIR_FREE(newiter); goto cleanup; } - VIR_STEAL_PTR(iter, newiter); + iter = g_steal_pointer(&newiter); types = vsig; nstruct = strlen(types); narray = (size_t)-1; @@ -819,7 +819,7 @@ virDBusMessageIterEncode(DBusMessageIter *rootiter, goto cleanup; } VIR_FREE(contsig); - VIR_STEAL_PTR(iter, newiter); + iter = g_steal_pointer(&newiter); types = t + 1; nstruct = skiplen - 2; narray = (size_t)-1; @@ -1056,7 +1056,7 @@ virDBusMessageIterDecode(DBusMessageIter *rootiter, nstruct, narray) < 0) goto cleanup; VIR_FREE(contsig); - VIR_STEAL_PTR(iter, newiter); + iter = g_steal_pointer(&newiter); types = t + 1; nstruct = skiplen; if (arrayref) { @@ -1086,7 +1086,7 @@ virDBusMessageIterDecode(DBusMessageIter *rootiter, VIR_DEBUG("Push failed"); goto cleanup; } - VIR_STEAL_PTR(iter, newiter); + iter = g_steal_pointer(&newiter); types = vsig; nstruct = strlen(types); narray = (size_t)-1; @@ -1113,7 +1113,7 @@ virDBusMessageIterDecode(DBusMessageIter *rootiter, nstruct, narray) < 0) goto cleanup; VIR_FREE(contsig); - VIR_STEAL_PTR(iter, newiter); + iter = g_steal_pointer(&newiter); types = t + 1; nstruct = skiplen - 2; narray = (size_t)-1; diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c index 1abd8044e7..a9996b067c 100644 --- a/src/util/virdevmapper.c +++ b/src/util/virdevmapper.c @@ -150,7 +150,7 @@ virDevMapperGetTargetsImpl(const char *path, if (virStringListMerge(&devPaths, &recursiveDevPaths) < 0) goto cleanup; - VIR_STEAL_PTR(*devPaths_ret, devPaths); + *devPaths_ret = g_steal_pointer(&devPaths); ret = 0; cleanup: virStringListFree(recursiveDevPaths); diff --git a/src/util/virerror.c b/src/util/virerror.c index f02d6f3b8a..b45c53b7df 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -1497,7 +1497,7 @@ virLastErrorPrefixMessage(const char *fmt, ...) goto cleanup; VIR_FREE(err->message); - VIR_STEAL_PTR(err->message, newmsg); + err->message = g_steal_pointer(&newmsg); cleanup: va_end(args); diff --git a/src/util/virfile.c b/src/util/virfile.c index e0b6398823..2fb389eeb2 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -4437,7 +4437,7 @@ virFileGetXAttrQuiet(const char *path, break; } - VIR_STEAL_PTR(*value, buf); + *value = g_steal_pointer(&buf); ret = 0; cleanup: VIR_FREE(buf); diff --git a/src/util/virfilecache.c b/src/util/virfilecache.c index 823d5e15e0..3a99dc210b 100644 --- a/src/util/virfilecache.c +++ b/src/util/virfilecache.c @@ -169,7 +169,7 @@ virFileCacheLoad(virFileCachePtr cache, VIR_DEBUG("Loaded cached data '%s' for '%s'", file, name); ret = 1; - VIR_STEAL_PTR(*data, loadData); + *data = g_steal_pointer(&loadData); cleanup: virObjectUnref(loadData); diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index 2a4a095347..6b29bb1a73 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -257,7 +257,7 @@ virHostdevGetPCIHostDevice(const virDomainHostdevDef *hostdev, return -1; } - VIR_STEAL_PTR(*pci, actual); + *pci = g_steal_pointer(&actual); return 0; } diff --git a/src/util/viriscsi.c b/src/util/viriscsi.c index 50e8e7afc5..dc553e7752 100644 --- a/src/util/viriscsi.c +++ b/src/util/viriscsi.c @@ -178,7 +178,7 @@ virStorageBackendIQNFound(const char *initiatoriqn, goto cleanup; if (STREQ(iqn, initiatoriqn)) { - VIR_STEAL_PTR(*ifacename, iface); + *ifacename = g_steal_pointer(&iface); VIR_DEBUG("Found interface '%s' with IQN '%s'", *ifacename, iqn); break; @@ -266,7 +266,7 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriqn, iface_name, initiatoriqn); } - VIR_STEAL_PTR(*ifacename, iface_name); + *ifacename = g_steal_pointer(&iface_name); return 0; } diff --git a/src/util/virjson.c b/src/util/virjson.c index c1476bfbbe..d3e6c9e41d 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -880,7 +880,7 @@ virJSONValueObjectSteal(virJSONValuePtr object, for (i = 0; i < object->data.object.npairs; i++) { 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_DELETE_ELEMENT(object->data.object.pairs, i, object->data.object.npairs); @@ -2155,7 +2155,7 @@ virJSONValueObjectDeflatten(virJSONValuePtr json) deflattened) < 0) return NULL; - VIR_STEAL_PTR(ret, deflattened); + ret = g_steal_pointer(&deflattened); return ret; } diff --git a/src/util/virmdev.c b/src/util/virmdev.c index 31fd961277..7e70ceb658 100644 --- a/src/util/virmdev.c +++ b/src/util/virmdev.c @@ -156,7 +156,7 @@ virMediatedDeviceNew(const char *uuidstr, virMediatedDeviceModelType model) if (VIR_ALLOC(dev) < 0) return NULL; - VIR_STEAL_PTR(dev->path, sysfspath); + dev->path = g_steal_pointer(&sysfspath); /* Check whether the user-provided model corresponds with the actually * supported mediated device's API. @@ -165,7 +165,7 @@ virMediatedDeviceNew(const char *uuidstr, virMediatedDeviceModelType model) return NULL; dev->model = model; - VIR_STEAL_PTR(ret, dev); + ret = g_steal_pointer(&dev); return ret; } @@ -521,7 +521,7 @@ virMediatedDeviceTypeReadAttrs(const char *sysfspath, #undef MDEV_GET_SYSFS_ATTR - VIR_STEAL_PTR(*type, tmp); + *type = g_steal_pointer(&tmp); return 0; } diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index b4637a91f9..8ca4626a90 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -399,7 +399,7 @@ int virNetDevTapCreate(char **ifname, goto cleanup; if (virNetDevExists(newname) == 0) { - VIR_STEAL_PTR(newifname, newname); + newifname = g_steal_pointer(&newname); break; } } diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index 90049b58a1..ab41b57672 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -317,7 +317,7 @@ int virNetlinkCommand(struct nl_msg *nl_msg, return -1; } - VIR_STEAL_PTR(*resp, temp_resp); + *resp = g_steal_pointer(&temp_resp); *respbuflen = len; return 0; } @@ -466,7 +466,7 @@ virNetlinkDumpLink(const char *ifname, int ifindex, goto malformed_resp; } - VIR_STEAL_PTR(*nlData, resp); + *nlData = g_steal_pointer(&resp); return 0; malformed_resp: @@ -737,7 +737,7 @@ virNetlinkGetNeighbor(void **nlData, uint32_t src_pid, uint32_t dst_pid) goto malformed_resp; } - VIR_STEAL_PTR(*nlData, resp); + *nlData = g_steal_pointer(&resp); return recvbuflen; malformed_resp: diff --git a/src/util/virnuma.c b/src/util/virnuma.c index 6f3f0420d2..8f50634c2a 100644 --- a/src/util/virnuma.c +++ b/src/util/virnuma.c @@ -293,7 +293,7 @@ virNumaGetNodeCPUs(int node, } } - VIR_STEAL_PTR(*cpus, cpumap); + *cpus = g_steal_pointer(&cpumap); return ncpus; } # undef MASK_CPU_ISSET @@ -337,7 +337,7 @@ virNumaNodesetToCPUset(virBitmapPtr nodeset, return -1; } - VIR_STEAL_PTR(*cpuset, allNodesCPUs); + *cpuset = g_steal_pointer(&allNodesCPUs); return 0; } diff --git a/src/util/virpci.c b/src/util/virpci.c index d173b29476..2c54c8baa1 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -489,7 +489,7 @@ virPCIDeviceIterDevices(virPCIDeviceIterPredicate predicate, break; } else if (rc == 1) { 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; break; } @@ -2648,7 +2648,7 @@ virPCIGetMdevTypes(const char *sysfspath, if (dirret < 0) goto cleanup; - VIR_STEAL_PTR(*types, mdev_types); + *types = g_steal_pointer(&mdev_types); ret = ntypes; ntypes = 0; cleanup: diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 9b50c09221..ab650b59b9 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -610,7 +610,7 @@ virResctrlGetCacheInfo(virResctrlInfoPtr resctrl, goto cleanup; } - VIR_STEAL_PTR(i_level->types[type], i_type); + i_level->types[type] = g_steal_pointer(&i_type); } ret = 0; @@ -666,7 +666,7 @@ virResctrlGetMemoryBandwidthInfo(virResctrlInfoPtr resctrl) if (rv < 0) goto cleanup; - VIR_STEAL_PTR(resctrl->membw_info, i_membw); + resctrl->membw_info = g_steal_pointer(&i_membw); ret = 0; cleanup: VIR_FREE(i_membw); @@ -748,8 +748,8 @@ virResctrlGetMonitorInfo(virResctrlInfoPtr resctrl) VIR_DEBUG("Resctrl supported %zd monitoring features", nfeatures); info_monitor->nfeatures = nfeatures; - VIR_STEAL_PTR(info_monitor->features, features); - VIR_STEAL_PTR(resctrl->monitor_info, info_monitor); + info_monitor->features = g_steal_pointer(&features); + resctrl->monitor_info = g_steal_pointer(&info_monitor); ret = 0; cleanup: @@ -1025,7 +1025,7 @@ virResctrlInfoGetMonitorPrefix(virResctrlInfoPtr resctrl, goto cleanup; } - VIR_STEAL_PTR(*monitor, mon); + *monitor = g_steal_pointer(&mon); cleanup: virResctrlInfoMonFree(mon); return ret; diff --git a/src/util/virrotatingfile.c b/src/util/virrotatingfile.c index 7a268319a6..1171d3b153 100644 --- a/src/util/virrotatingfile.c +++ b/src/util/virrotatingfile.c @@ -406,7 +406,7 @@ virRotatingFileWriterRollover(virRotatingFileWriterPtr file) } VIR_FREE(nextpath); - VIR_STEAL_PTR(nextpath, thispath); + nextpath = g_steal_pointer(&thispath); } } diff --git a/src/util/virscsi.c b/src/util/virscsi.c index 425d7adfe9..17e8aa1daa 100644 --- a/src/util/virscsi.c +++ b/src/util/virscsi.c @@ -238,7 +238,7 @@ virSCSIDeviceNew(const char *sysfs_prefix, if (virAsprintf(&dev->id, "%s:%s", vendor, model) < 0) return NULL; - VIR_STEAL_PTR(ret, dev); + ret = g_steal_pointer(&dev); return ret; } diff --git a/src/util/virscsivhost.c b/src/util/virscsivhost.c index 9ba0d3f2a0..0bcd8902a4 100644 --- a/src/util/virscsivhost.c +++ b/src/util/virscsivhost.c @@ -269,7 +269,7 @@ virSCSIVHostDeviceNew(const char *name) VIR_DEBUG("%s: initialized", dev->name); - VIR_STEAL_PTR(ret, dev); + ret = g_steal_pointer(&dev); return ret; } diff --git a/src/util/virstorageencryption.c b/src/util/virstorageencryption.c index 49df7fddd8..14d7dc26e2 100644 --- a/src/util/virstorageencryption.c +++ b/src/util/virstorageencryption.c @@ -310,7 +310,7 @@ virStorageEncryptionParseNode(xmlNodePtr node, } } - VIR_STEAL_PTR(ret, encdef); + ret = g_steal_pointer(&encdef); cleanup: VIR_FREE(format_str); diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index ac0c70b21e..e04cc413a4 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1141,7 +1141,7 @@ virStorageFileMetadataNew(const char *path, if (VIR_STRDUP(def->path, path) < 0) return NULL; - VIR_STEAL_PTR(ret, def); + ret = g_steal_pointer(&def); return ret; } @@ -1240,7 +1240,7 @@ virStorageFileGetMetadataFromFD(const char *path, * update the metadata.*/ meta->type = VIR_STORAGE_TYPE_DIR; meta->format = VIR_STORAGE_FILE_DIR; - VIR_STEAL_PTR(ret, meta); + ret = g_steal_pointer(&meta); return ret; } @@ -1262,7 +1262,7 @@ virStorageFileGetMetadataFromFD(const char *path, else if (S_ISBLK(sb.st_mode)) meta->type = VIR_STORAGE_TYPE_BLOCK; - VIR_STEAL_PTR(ret, meta); + ret = g_steal_pointer(&meta); return ret; } @@ -1867,7 +1867,7 @@ virStorageAuthDefCopy(const virStorageAuthDef *src) if (virSecretLookupDefCopy(&authdef->seclookupdef, &src->seclookupdef) < 0) return NULL; - VIR_STEAL_PTR(ret, authdef); + ret = g_steal_pointer(&authdef); return ret; } @@ -1924,7 +1924,7 @@ virStorageAuthDefParse(xmlNodePtr node, if (virSecretLookupParseSecret(secretnode, &authdef->seclookupdef) < 0) goto cleanup; - VIR_STEAL_PTR(ret, authdef); + ret = g_steal_pointer(&authdef); cleanup: ctxt->node = saveNode; @@ -2028,8 +2028,8 @@ virStoragePRDefParseXML(xmlXPathContextPtr ctxt) goto cleanup; } - VIR_STEAL_PTR(prd->path, path); - VIR_STEAL_PTR(ret, prd); + prd->path = g_steal_pointer(&path); + ret = g_steal_pointer(&prd); cleanup: virStoragePRDefFree(prd); @@ -2113,7 +2113,7 @@ virStoragePRDefCopy(virStoragePRDefPtr src) VIR_STRDUP(copy->mgralias, src->mgralias) < 0) goto cleanup; - VIR_STEAL_PTR(ret, copy); + ret = g_steal_pointer(©); cleanup: virStoragePRDefFree(copy); @@ -2346,7 +2346,7 @@ virStorageSourceCopy(const virStorageSource *src, return NULL; } - VIR_STEAL_PTR(ret, def); + ret = g_steal_pointer(&def); return ret; } @@ -2671,7 +2671,7 @@ virStorageSourceNewFromBackingRelative(virStorageSourcePtr parent, def->type = VIR_STORAGE_TYPE_FILE; } - VIR_STEAL_PTR(ret, def); + ret = g_steal_pointer(&def); return ret; } @@ -2854,7 +2854,7 @@ virStorageSourceParseRBDColonString(const char *rbdstr, /* pool vs. image name */ 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) return -1; *p = '\0'; @@ -2897,7 +2897,7 @@ virStorageSourceParseRBDColonString(const char *rbdstr, if (VIR_STRDUP(authdef->secrettype, virSecretUsageTypeToString(VIR_SECRET_USAGE_TYPE_CEPH)) < 0) return -1; - VIR_STEAL_PTR(src->auth, authdef); + src->auth = g_steal_pointer(&authdef); src->authInherited = true; /* 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; } @@ -3779,7 +3779,7 @@ virStorageSourceNewFromChild(virStorageSourcePtr parent, def->detected = true; - VIR_STEAL_PTR(*child, def); + *child = g_steal_pointer(&def); return rc; } @@ -4266,7 +4266,7 @@ virStorageFileGetRelativeBackingPath(virStorageSourcePtr top, return -1; } - VIR_STEAL_PTR(*relpath, path); + *relpath = g_steal_pointer(&path); return 0; } @@ -5025,7 +5025,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src, goto cleanup; } - VIR_STEAL_PTR(src->backingStore, backingStore); + src->backingStore = g_steal_pointer(&backingStore); if (src->externalDataStoreRaw) { g_autoptr(virStorageSource) externalDataStore = NULL; @@ -5040,7 +5040,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src, goto cleanup; } - VIR_STEAL_PTR(src->externalDataStore, externalDataStore); + src->externalDataStore = g_steal_pointer(&externalDataStore); } ret = 0; @@ -5150,6 +5150,6 @@ virStorageFileGetBackingStoreStr(virStorageSourcePtr src, if (virStorageFileGetMetadataInternal(tmp, buf, headerLen, NULL) < 0) return -1; - VIR_STEAL_PTR(*backing, tmp->backingStoreRaw); + *backing = g_steal_pointer(&tmp->backingStoreRaw); return 0; } diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index a9dfa85be2..2cd7e81bdd 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -761,7 +761,7 @@ virTypedParamListStealParams(virTypedParamListPtr list, { size_t ret = list->npar; - VIR_STEAL_PTR(*params, list->par); + *params = g_steal_pointer(&list->par); list->npar = 0; list->par_alloc = 0; -- GitLab