Since commit 44e7f029159ed701b4a1739ac711507ee53790ed util: rewrite auto cleanup macros to use glib's equivalent VIR_AUTOFREE is just an alias for g_autofree. Use the GLib macros directly instead of our custom aliases. Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx> --- src/conf/checkpoint_conf.c | 6 +- src/conf/domain_conf.c | 694 ++++++++++----------- src/conf/secret_conf.c | 4 +- src/conf/snapshot_conf.c | 2 +- src/conf/storage_conf.c | 44 +- src/conf/virnetworkobj.c | 8 +- src/conf/virnetworkportdef.c | 16 +- src/cpu/cpu_x86.c | 12 +- src/driver.c | 4 +- src/interface/interface_backend_netcf.c | 2 +- src/interface/interface_backend_udev.c | 2 +- src/libvirt-admin.c | 2 +- src/libxl/xen_common.c | 22 +- src/libxl/xen_xl.c | 12 +- src/libxl/xen_xm.c | 8 +- src/lxc/lxc_native.c | 16 +- src/network/bridge_driver.c | 10 +- src/node_device/node_device_hal.c | 2 +- src/node_device/node_device_udev.c | 2 +- src/qemu/qemu_block.c | 22 +- src/qemu/qemu_blockjob.c | 8 +- src/qemu/qemu_capabilities.c | 6 +- src/qemu/qemu_checkpoint.c | 8 +- src/qemu/qemu_command.c | 148 ++--- src/qemu/qemu_conf.c | 42 +- src/qemu/qemu_domain.c | 56 +- src/qemu/qemu_domain_address.c | 6 +- src/qemu/qemu_driver.c | 22 +- src/qemu/qemu_extdevice.c | 4 +- src/qemu/qemu_firmware.c | 4 +- src/qemu/qemu_hotplug.c | 118 ++-- src/qemu/qemu_interop_config.c | 16 +- src/qemu/qemu_migration.c | 2 +- src/qemu/qemu_monitor.c | 4 +- src/qemu/qemu_monitor_json.c | 6 +- src/qemu/qemu_process.c | 2 +- src/qemu/qemu_slirp.c | 26 +- src/qemu/qemu_tpm.c | 10 +- src/qemu/qemu_vhost_user.c | 4 +- src/qemu/qemu_vhost_user_gpu.c | 14 +- src/remote/remote_daemon_dispatch.c | 8 +- src/remote/remote_driver.c | 42 +- src/secret/secret_driver.c | 4 +- src/security/security_util.c | 36 +- src/storage/storage_backend.c | 2 +- src/storage/storage_backend_disk.c | 10 +- src/storage/storage_backend_fs.c | 6 +- src/storage/storage_backend_gluster.c | 6 +- src/storage/storage_backend_iscsi.c | 16 +- src/storage/storage_backend_iscsi_direct.c | 10 +- src/storage/storage_backend_logical.c | 12 +- src/storage/storage_backend_mpath.c | 2 +- src/storage/storage_backend_rbd.c | 16 +- src/storage/storage_backend_scsi.c | 14 +- src/storage/storage_backend_sheepdog.c | 4 +- src/storage/storage_backend_vstorage.c | 8 +- src/storage/storage_backend_zfs.c | 6 +- src/storage/storage_driver.c | 26 +- src/storage/storage_file_gluster.c | 4 +- src/storage/storage_util.c | 80 +-- src/test/test_driver.c | 46 +- src/util/iohelper.c | 2 +- src/util/virarptable.c | 4 +- src/util/viraudit.c | 2 +- src/util/virauth.c | 10 +- src/util/virauthconfig.c | 4 +- src/util/virbuffer.c | 6 +- src/util/vircgroup.c | 40 +- src/util/vircgroupv1.c | 108 ++-- src/util/vircgroupv2.c | 108 ++-- src/util/vircommand.c | 20 +- src/util/virerror.c | 4 +- src/util/vireventpoll.c | 2 +- src/util/virfcp.c | 4 +- src/util/virfile.c | 68 +- src/util/virfilecache.c | 8 +- src/util/virfirewall.c | 10 +- src/util/virfirewalld.c | 4 +- src/util/virhook.c | 4 +- src/util/virhostdev.c | 20 +- src/util/virhostmem.c | 12 +- src/util/viriptables.c | 20 +- src/util/viriscsi.c | 18 +- src/util/virjson.c | 12 +- src/util/virkmod.c | 4 +- src/util/virlease.c | 4 +- src/util/virmdev.c | 16 +- src/util/virnetdevbridge.c | 14 +- src/util/virnetdevip.c | 38 +- src/util/virnetdevmacvlan.c | 4 +- src/util/virnetdevopenvswitch.c | 10 +- src/util/virnetdevtap.c | 6 +- src/util/virnetdevveth.c | 6 +- src/util/virnetlink.c | 14 +- src/util/virnodesuspend.c | 2 +- src/util/virnuma.c | 20 +- src/util/virpci.c | 78 +-- src/util/virperf.c | 4 +- src/util/virpidfile.c | 22 +- src/util/virprocess.c | 18 +- src/util/virqemu.c | 4 +- src/util/virresctrl.c | 2 +- src/util/virscsi.c | 14 +- src/util/virsocketaddr.c | 8 +- src/util/virstoragefile.c | 42 +- src/util/virtpm.c | 4 +- src/util/virusb.c | 4 +- src/util/virutil.c | 2 +- tests/cputest.c | 4 +- tests/networkxml2firewalltest.c | 4 +- tests/qemublocktest.c | 26 +- tests/qemucapabilitiestest.c | 4 +- tests/qemucaps2xmltest.c | 4 +- tests/qemudomaincheckpointxml2xmltest.c | 6 +- tests/qemufirmwaretest.c | 10 +- tests/qemumonitorjsontest.c | 8 +- tests/qemumonitortestutils.c | 18 +- tests/qemusecuritytest.c | 6 +- tests/qemuvhostusertest.c | 10 +- tests/storagebackendsheepdogtest.c | 8 +- tests/storagepoolcapstest.c | 4 +- tests/storagepoolxml2argvtest.c | 8 +- tests/storagepoolxml2xmltest.c | 6 +- tests/storagevolxml2argvtest.c | 14 +- tests/storagevolxml2xmltest.c | 8 +- tests/testutils.c | 4 +- tests/testutilsqemu.c | 2 +- tests/virfilewrapper.c | 12 +- tests/virhostdevtest.c | 2 +- tests/virjsontest.c | 36 +- tests/virmockstathelpers.c | 16 +- tests/virnetdevopenvswitchtest.c | 4 +- tests/virpcimock.c | 56 +- tests/virstoragetest.c | 14 +- tests/virstorageutiltest.c | 4 +- tools/virsh-completer-domain.c | 12 +- tools/virsh-completer-host.c | 14 +- tools/virsh-completer.c | 2 +- tools/virsh-domain-monitor.c | 10 +- tools/virsh-domain.c | 14 +- tools/virsh-network.c | 2 +- tools/virsh-pool.c | 2 +- tools/virsh-secret.c | 2 +- tools/virt-admin.c | 6 +- 144 files changed, 1473 insertions(+), 1473 deletions(-) diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c index a83863adcc..9b407dca78 100644 --- a/src/conf/checkpoint_conf.c +++ b/src/conf/checkpoint_conf.c @@ -98,7 +98,7 @@ virDomainCheckpointDiskDefParseXML(xmlNodePtr node, xmlXPathContextPtr ctxt, virDomainCheckpointDiskDefPtr def) { - VIR_AUTOFREE(char *) checkpoint = NULL; + g_autofree char *checkpoint = NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt); ctxt->node = node; @@ -133,7 +133,7 @@ virDomainCheckpointDefParse(xmlXPathContextPtr ctxt, size_t i; int n; char *tmp; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; VIR_AUTOUNREF(virDomainCheckpointDefPtr) def = NULL; if (!(def = virDomainCheckpointDefNew())) @@ -210,7 +210,7 @@ virDomainCheckpointDefParseNode(xmlDocPtr xml, unsigned int flags) { VIR_AUTOPTR(xmlXPathContext) ctxt = NULL; - VIR_AUTOFREE(char *) schema = NULL; + g_autofree char *schema = NULL; if (!virXMLNodeNameEqual(root, "domaincheckpoint")) { virReportError(VIR_ERR_XML_ERROR, "%s", _("domaincheckpoint")); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 16b939d511..139dccefff 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1300,8 +1300,8 @@ virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDefPtr keywrap, { int state_type; int name_type; - VIR_AUTOFREE(char *) name = NULL; - VIR_AUTOFREE(char *) state = NULL; + g_autofree char *name = NULL; + g_autofree char *state = NULL; if (!(name = virXMLPropString(node, "name"))) { virReportError(VIR_ERR_CONF_SYNTAX, "%s", @@ -1364,8 +1364,8 @@ virDomainKeyWrapDefParseXML(virDomainDefPtr def, xmlXPathContextPtr ctxt) { size_t i; int n; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; - VIR_AUTOFREE(virDomainKeyWrapDefPtr) keywrap = NULL; + g_autofree xmlNodePtr *nodes = NULL; + g_autofree virDomainKeyWrapDefPtr keywrap = NULL; if ((n = virXPathNodeSet("./keywrap/cipher", ctxt, &nodes)) < 0) return n; @@ -1455,7 +1455,7 @@ virDomainVirtioOptionsParseXML(xmlNodePtr driver, { int val; virDomainVirtioOptionsPtr res; - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; if (*virtio || !driver) return 0; @@ -1544,7 +1544,7 @@ virDomainBlkioDeviceParseXML(xmlNodePtr root, virBlkioDevicePtr dev) { xmlNodePtr node; - VIR_AUTOFREE(char *) c = NULL; + g_autofree char *c = NULL; node = root->children; while (node) { @@ -5585,7 +5585,7 @@ virDomainDefCollectBootOrder(virDomainDefPtr def G_GNUC_UNUSED, void *data) { virHashTablePtr bootHash = data; - VIR_AUTOFREE(char *) order = NULL; + g_autofree char *order = NULL; if (info->bootIndex == 0) return 0; @@ -7251,7 +7251,7 @@ static int virDomainDeviceUSBMasterParseXML(xmlNodePtr node, virDomainDeviceUSBMasterPtr master) { - VIR_AUTOFREE(char *) startport = NULL; + g_autofree char *startport = NULL; memset(master, 0, sizeof(*master)); @@ -7271,8 +7271,8 @@ static int virDomainDeviceBootParseXML(xmlNodePtr node, virDomainDeviceInfoPtr info) { - VIR_AUTOFREE(char *) order = NULL; - VIR_AUTOFREE(char *) loadparm = NULL; + g_autofree char *order = NULL; + g_autofree char *loadparm = NULL; if (!(order = virXMLPropString(node, "order"))) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -7310,8 +7310,8 @@ static int virDomainDeviceISAAddressParseXML(xmlNodePtr node, virDomainDeviceISAAddressPtr addr) { - VIR_AUTOFREE(char *) iobase = NULL; - VIR_AUTOFREE(char *) irq = NULL; + g_autofree char *iobase = NULL; + g_autofree char *irq = NULL; memset(addr, 0, sizeof(*addr)); @@ -7340,7 +7340,7 @@ static int virDomainDeviceDimmAddressParseXML(xmlNodePtr node, virDomainDeviceDimmAddressPtr addr) { - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree char *tmp = NULL; if (!(tmp = virXMLPropString(node, "slot")) || virStrToLong_uip(tmp, NULL, 10, &addr->slot) < 0) { @@ -7367,7 +7367,7 @@ static int virDomainDeviceAddressParseXML(xmlNodePtr address, virDomainDeviceInfoPtr info) { - VIR_AUTOFREE(char *) type = virXMLPropString(address, "type"); + g_autofree char *type = virXMLPropString(address, "type"); if (type) { if ((info->type = virDomainDeviceAddressTypeFromString(type)) <= 0) { @@ -7473,9 +7473,9 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt G_GNUC_UNUSED, xmlNodePtr boot = NULL; xmlNodePtr rom = NULL; int ret = -1; - VIR_AUTOFREE(char *) romenabled = NULL; - VIR_AUTOFREE(char *) rombar = NULL; - VIR_AUTOFREE(char *) aliasStr = NULL; + g_autofree char *romenabled = NULL; + g_autofree char *rombar = NULL; + g_autofree char *aliasStr = NULL; virDomainDeviceInfoClear(info); @@ -7586,8 +7586,8 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node, bool got_product, got_vendor; xmlNodePtr cur; virDomainHostdevSubsysUSBPtr usbsrc = &def->source.subsys.u.usb; - VIR_AUTOFREE(char *) startupPolicy = NULL; - VIR_AUTOFREE(char *) autoAddress = NULL; + g_autofree char *startupPolicy = NULL; + g_autofree char *autoAddress = NULL; if ((startupPolicy = virXMLPropString(node, "startupPolicy"))) { def->startupPolicy = @@ -7614,7 +7614,7 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node, while (cur != NULL) { if (cur->type == XML_ELEMENT_NODE) { if (virXMLNodeNameEqual(cur, "vendor")) { - VIR_AUTOFREE(char *) vendor = virXMLPropString(cur, "id"); + g_autofree char *vendor = virXMLPropString(cur, "id"); if (vendor) { got_vendor = true; @@ -7629,7 +7629,7 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node, goto out; } } else if (virXMLNodeNameEqual(cur, "product")) { - VIR_AUTOFREE(char *) product = virXMLPropString(cur, "id"); + g_autofree char *product = virXMLPropString(cur, "id"); if (product) { got_product = true; @@ -7646,8 +7646,8 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node, goto out; } } else if (virXMLNodeNameEqual(cur, "address")) { - VIR_AUTOFREE(char *) bus = NULL; - VIR_AUTOFREE(char *) device = NULL; + g_autofree char *bus = NULL; + g_autofree char *device = NULL; bus = virXMLPropString(cur, "bus"); if (bus) { @@ -7763,7 +7763,7 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr node, } else if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) && virXMLNodeNameEqual(cur, "state")) { /* Legacy back-compat. Don't add any more attributes here */ - VIR_AUTOFREE(char *) devaddr = virXMLPropString(cur, "devaddr"); + g_autofree char *devaddr = virXMLPropString(cur, "devaddr"); if (devaddr && virDomainParseLegacyDeviceAddress(devaddr, &def->info->addr.pci) < 0) { @@ -7799,8 +7799,8 @@ virDomainStorageNetworkParseHost(xmlNodePtr hostnode, virStorageNetHostDefPtr host) { int ret = -1; - VIR_AUTOFREE(char *) transport = NULL; - VIR_AUTOFREE(char *) port = NULL; + g_autofree char *transport = NULL; + g_autofree char *port = NULL; memset(host, 0, sizeof(*host)); host->transport = VIR_STORAGE_NET_HOST_TRANS_TCP; @@ -7888,9 +7888,9 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode, bool got_address = false, got_adapter = false; xmlNodePtr cur; virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host; - VIR_AUTOFREE(char *) bus = NULL; - VIR_AUTOFREE(char *) target = NULL; - VIR_AUTOFREE(char *) unit = NULL; + g_autofree char *bus = NULL; + g_autofree char *target = NULL; + g_autofree char *unit = NULL; cur = sourcenode->children; while (cur != NULL) { @@ -8042,7 +8042,7 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr sourcenode, virDomainHostdevSubsysSCSIPtr scsisrc, xmlXPathContextPtr ctxt) { - VIR_AUTOFREE(char *) protocol = NULL; + g_autofree char *protocol = NULL; if ((protocol = virXMLPropString(sourcenode, "protocol"))) { scsisrc->protocol = @@ -8066,8 +8066,8 @@ virDomainHostdevSubsysSCSIVHostDefParseXML(xmlNodePtr sourcenode, virDomainHostdevDefPtr def) { virDomainHostdevSubsysSCSIVHostPtr hostsrc = &def->source.subsys.u.scsi_host; - VIR_AUTOFREE(char *) protocol = NULL; - VIR_AUTOFREE(char *) wwpn = NULL; + g_autofree char *protocol = NULL; + g_autofree char *wwpn = NULL; if (!(protocol = virXMLPropString(sourcenode, "protocol"))) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -8117,7 +8117,7 @@ virDomainHostdevSubsysMediatedDevDefParseXML(virDomainHostdevDefPtr def, unsigned char uuid[VIR_UUID_BUFLEN] = {0}; xmlNodePtr node = NULL; virDomainHostdevSubsysMediatedDevPtr mdevsrc = &def->source.subsys.u.mdev; - VIR_AUTOFREE(char *) uuidxml = NULL; + g_autofree char *uuidxml = NULL; if (!(node = virXPathNode("./source/address", ctxt))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -8155,12 +8155,12 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, virDomainHostdevSubsysSCSIPtr scsisrc = &def->source.subsys.u.scsi; virDomainHostdevSubsysSCSIVHostPtr scsihostsrc = &def->source.subsys.u.scsi_host; virDomainHostdevSubsysMediatedDevPtr mdevsrc = &def->source.subsys.u.mdev; - VIR_AUTOFREE(char *) managed = NULL; - VIR_AUTOFREE(char *) sgio = NULL; - VIR_AUTOFREE(char *) rawio = NULL; - VIR_AUTOFREE(char *) backendStr = NULL; - VIR_AUTOFREE(char *) model = NULL; - VIR_AUTOFREE(char *) display = NULL; + g_autofree char *managed = NULL; + g_autofree char *sgio = NULL; + g_autofree char *rawio = NULL; + g_autofree char *backendStr = NULL; + g_autofree char *model = NULL; + g_autofree char *display = NULL; /* @managed can be read from the xml document - it is always an * attribute of the toplevel element, no matter what type of @@ -8340,11 +8340,11 @@ virDomainNetIPParseXML(xmlNodePtr node) virNetDevIPAddrPtr ret = NULL; unsigned int prefixValue = 0; int family = AF_UNSPEC; - VIR_AUTOFREE(virNetDevIPAddrPtr) ip = NULL; - VIR_AUTOFREE(char *) prefixStr = NULL; - VIR_AUTOFREE(char *) familyStr = NULL; - VIR_AUTOFREE(char *) address = NULL; - VIR_AUTOFREE(char *) peer = NULL; + g_autofree virNetDevIPAddrPtr ip = NULL; + g_autofree char *prefixStr = NULL; + g_autofree char *familyStr = NULL; + g_autofree char *address = NULL; + g_autofree char *peer = NULL; if (!(address = virXMLPropString(node, "address"))) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -8408,8 +8408,8 @@ virDomainNetIPInfoParseXML(const char *source, int nnodes; int ret = -1; size_t i; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; - VIR_AUTOFREE(virNetDevIPAddrPtr) ip = NULL; + g_autofree xmlNodePtr *nodes = NULL; + g_autofree virNetDevIPAddrPtr ip = NULL; if ((nnodes = virXPathNodeSet("./ip", ctxt, &nodes)) < 0) goto cleanup; @@ -8446,7 +8446,7 @@ virDomainNetDefCoalesceParseXML(xmlNodePtr node, virNetDevCoalescePtr ret = NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt); unsigned long long tmp = 0; - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; ctxt->node = node; @@ -8845,7 +8845,7 @@ virSecurityLabelDefsParseXML(virDomainDefPtr def, size_t i = 0, j; int n; virCapsHostPtr host = &caps->host; - VIR_AUTOFREE(xmlNodePtr *) list = NULL; + g_autofree xmlNodePtr *list = NULL; /* Allocate a security labels based on XML */ if ((n = virXPathNodeSet("./seclabel", ctxt, &list)) < 0) @@ -8946,7 +8946,7 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceLabelDefPtr **seclabels_rtn, int n; size_t i, j; char *model, *relabel, *label, *labelskip; - VIR_AUTOFREE(xmlNodePtr *) list = NULL; + g_autofree xmlNodePtr *list = NULL; if ((n = virXPathNodeSet("./seclabel", ctxt, &list)) < 0) goto error; @@ -9062,10 +9062,10 @@ virDomainLeaseDefParseXML(xmlNodePtr node) { virDomainLeaseDefPtr def; xmlNodePtr cur; - VIR_AUTOFREE(char *) lockspace = NULL; - VIR_AUTOFREE(char *) key = NULL; - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(char *) offset = NULL; + g_autofree char *lockspace = NULL; + g_autofree char *key = NULL; + g_autofree char *path = NULL; + g_autofree char *offset = NULL; if (VIR_ALLOC(def) < 0) return NULL; @@ -9124,7 +9124,7 @@ virDomainDiskSourcePoolDefParse(xmlNodePtr node, { virStorageSourcePoolDefPtr source; int ret = -1; - VIR_AUTOFREE(char *) mode = NULL; + g_autofree char *mode = NULL; *srcpool = NULL; @@ -9172,9 +9172,9 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, unsigned int flags) { int tlsCfgVal; - VIR_AUTOFREE(char *) protocol = NULL; - VIR_AUTOFREE(char *) haveTLS = NULL; - VIR_AUTOFREE(char *) tlsCfg = NULL; + g_autofree char *protocol = NULL; + g_autofree char *haveTLS = NULL; + g_autofree char *tlsCfg = NULL; if (!(protocol = virXMLPropString(node, "protocol"))) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -9403,9 +9403,9 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt, VIR_XPATH_NODE_AUTORESTORE(ctxt); xmlNodePtr source; VIR_AUTOUNREF(virStorageSourcePtr) backingStore = NULL; - VIR_AUTOFREE(char *) type = NULL; - VIR_AUTOFREE(char *) format = NULL; - VIR_AUTOFREE(char *) idx = NULL; + g_autofree char *type = NULL; + g_autofree char *format = NULL; + g_autofree char *idx = NULL; if (!(ctxt->node = virXPathNode("./backingStore", ctxt))) return 0; @@ -9539,11 +9539,11 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def, { xmlNodePtr mirrorNode; VIR_XPATH_NODE_AUTORESTORE(ctxt); - VIR_AUTOFREE(char *) mirrorFormat = NULL; - VIR_AUTOFREE(char *) mirrorType = NULL; - VIR_AUTOFREE(char *) ready = NULL; - VIR_AUTOFREE(char *) blockJob = NULL; - VIR_AUTOFREE(char *) index = NULL; + g_autofree char *mirrorFormat = NULL; + g_autofree char *mirrorType = NULL; + g_autofree char *ready = NULL; + g_autofree char *blockJob = NULL; + g_autofree char *index = NULL; ctxt->node = cur; @@ -9612,7 +9612,7 @@ static int virDomainDiskDefGeometryParse(virDomainDiskDefPtr def, xmlNodePtr cur) { - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree char *tmp = NULL; if ((tmp = virXMLPropString(cur, "cyls"))) { if (virStrToLong_ui(tmp, NULL, 10, &def->geometry.cylinders) < 0) { @@ -9795,7 +9795,7 @@ static int virDomainDiskDefDriverParseXML(virDomainDiskDefPtr def, xmlNodePtr cur) { - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree char *tmp = NULL; def->driverName = virXMLPropString(cur, "name"); @@ -9955,23 +9955,23 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, bool source = false; virStorageEncryptionPtr encryption = NULL; VIR_AUTOPTR(virStorageAuthDef) authdef = NULL; - VIR_AUTOFREE(char *) tmp = NULL; - VIR_AUTOFREE(char *) snapshot = NULL; - VIR_AUTOFREE(char *) rawio = NULL; - VIR_AUTOFREE(char *) sgio = NULL; - VIR_AUTOFREE(char *) target = NULL; - VIR_AUTOFREE(char *) bus = NULL; - VIR_AUTOFREE(char *) devaddr = NULL; - VIR_AUTOFREE(char *) serial = NULL; - VIR_AUTOFREE(char *) startupPolicy = NULL; - VIR_AUTOFREE(char *) tray = NULL; - VIR_AUTOFREE(char *) removable = NULL; - VIR_AUTOFREE(char *) logical_block_size = NULL; - VIR_AUTOFREE(char *) physical_block_size = NULL; - VIR_AUTOFREE(char *) wwn = NULL; - VIR_AUTOFREE(char *) vendor = NULL; - VIR_AUTOFREE(char *) product = NULL; - VIR_AUTOFREE(char *) domain_name = NULL; + g_autofree char *tmp = NULL; + g_autofree char *snapshot = NULL; + g_autofree char *rawio = NULL; + g_autofree char *sgio = NULL; + g_autofree char *target = NULL; + g_autofree char *bus = NULL; + g_autofree char *devaddr = NULL; + g_autofree char *serial = NULL; + g_autofree char *startupPolicy = NULL; + g_autofree char *tray = NULL; + g_autofree char *removable = NULL; + g_autofree char *logical_block_size = NULL; + g_autofree char *physical_block_size = NULL; + g_autofree char *wwn = NULL; + g_autofree char *vendor = NULL; + g_autofree char *product = NULL; + g_autofree char *domain_name = NULL; if (!(def = virDomainDiskDefNew(xmlopt))) return NULL; @@ -10406,9 +10406,9 @@ virDomainParseScaledValue(const char *xpath, bool required) { unsigned long long bytes; - VIR_AUTOFREE(char *) xpath_full = NULL; - VIR_AUTOFREE(char *) unit = NULL; - VIR_AUTOFREE(char *) bytes_str = NULL; + g_autofree char *xpath_full = NULL; + g_autofree char *unit = NULL; + g_autofree char *bytes_str = NULL; *val = 0; if (virAsprintf(&xpath_full, "string(%s)", xpath) < 0) @@ -10653,21 +10653,21 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt, int ports = -1; VIR_XPATH_NODE_AUTORESTORE(ctxt); int rc; - VIR_AUTOFREE(char *) typeStr = NULL; - VIR_AUTOFREE(char *) idx = NULL; - VIR_AUTOFREE(char *) model = NULL; - VIR_AUTOFREE(char *) queues = NULL; - VIR_AUTOFREE(char *) cmd_per_lun = NULL; - VIR_AUTOFREE(char *) max_sectors = NULL; - VIR_AUTOFREE(char *) modelName = NULL; - VIR_AUTOFREE(char *) chassisNr = NULL; - VIR_AUTOFREE(char *) chassis = NULL; - VIR_AUTOFREE(char *) port = NULL; - VIR_AUTOFREE(char *) busNr = NULL; - VIR_AUTOFREE(char *) targetIndex = NULL; - VIR_AUTOFREE(char *) ioeventfd = NULL; - VIR_AUTOFREE(char *) portsStr = NULL; - VIR_AUTOFREE(char *) iothread = NULL; + g_autofree char *typeStr = NULL; + g_autofree char *idx = NULL; + g_autofree char *model = NULL; + g_autofree char *queues = NULL; + g_autofree char *cmd_per_lun = NULL; + g_autofree char *max_sectors = NULL; + g_autofree char *modelName = NULL; + g_autofree char *chassisNr = NULL; + g_autofree char *chassis = NULL; + g_autofree char *port = NULL; + g_autofree char *busNr = NULL; + g_autofree char *targetIndex = NULL; + g_autofree char *ioeventfd = NULL; + g_autofree char *portsStr = NULL; + g_autofree char *iothread = NULL; ctxt->node = node; @@ -10806,7 +10806,7 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt, switch (def->type) { case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: { - VIR_AUTOFREE(char *) vectors = virXMLPropString(node, "vectors"); + g_autofree char *vectors = virXMLPropString(node, "vectors"); def->opts.vioserial.ports = ports; if (vectors) { @@ -10974,7 +10974,7 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt, } break; case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS: { - VIR_AUTOFREE(char *) gntframes = virXMLPropString(node, "maxGrantFrames"); + g_autofree char *gntframes = virXMLPropString(node, "maxGrantFrames"); if (gntframes) { int r = virStrToLong_i(gntframes, NULL, 10, @@ -11022,16 +11022,16 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt, VIR_XPATH_NODE_AUTORESTORE(ctxt); virDomainFSDefPtr def; xmlNodePtr cur; - VIR_AUTOFREE(char *) type = NULL; - VIR_AUTOFREE(char *) fsdriver = NULL; - VIR_AUTOFREE(char *) source = NULL; - VIR_AUTOFREE(char *) target = NULL; - VIR_AUTOFREE(char *) format = NULL; - VIR_AUTOFREE(char *) accessmode = NULL; - VIR_AUTOFREE(char *) wrpolicy = NULL; - VIR_AUTOFREE(char *) usage = NULL; - VIR_AUTOFREE(char *) units = NULL; - VIR_AUTOFREE(char *) model = NULL; + g_autofree char *type = NULL; + g_autofree char *fsdriver = NULL; + g_autofree char *source = NULL; + g_autofree char *target = NULL; + g_autofree char *format = NULL; + g_autofree char *accessmode = NULL; + g_autofree char *wrpolicy = NULL; + g_autofree char *usage = NULL; + g_autofree char *units = NULL; + g_autofree char *model = NULL; ctxt->node = node; @@ -11207,11 +11207,11 @@ virDomainActualNetDefParseXML(xmlNodePtr node, xmlNodePtr bandwidth_node = NULL; xmlNodePtr vlanNode; xmlNodePtr virtPortNode; - VIR_AUTOFREE(char *) type = NULL; - VIR_AUTOFREE(char *) mode = NULL; - VIR_AUTOFREE(char *) addrtype = NULL; - VIR_AUTOFREE(char *) trustGuestRxFilters = NULL; - VIR_AUTOFREE(char *) macTableManager = NULL; + g_autofree char *type = NULL; + g_autofree char *mode = NULL; + g_autofree char *addrtype = NULL; + g_autofree char *trustGuestRxFilters = NULL; + g_autofree char *macTableManager = NULL; if (VIR_ALLOC(actual) < 0) return -1; @@ -11310,7 +11310,7 @@ virDomainActualNetDefParseXML(xmlNodePtr node, } } else if (actual->type == VIR_DOMAIN_NET_TYPE_BRIDGE || actual->type == VIR_DOMAIN_NET_TYPE_NETWORK) { - VIR_AUTOFREE(char *) class_id = NULL; + g_autofree char *class_id = NULL; xmlNodePtr sourceNode; class_id = virXPathString("string(./class/@id)", ctxt); @@ -11404,7 +11404,7 @@ virDomainChrSourceReconnectDefParseXML(virDomainChrSourceReconnectDefPtr def, int tmpVal; VIR_XPATH_NODE_AUTORESTORE(ctxt); xmlNodePtr cur; - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree char *tmp = NULL; ctxt->node = node; @@ -11463,43 +11463,43 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, VIR_XPATH_NODE_AUTORESTORE(ctxt); virDomainChrSourceReconnectDef reconnect = {0}; int rv, val; - VIR_AUTOFREE(char *) macaddr = NULL; - VIR_AUTOFREE(char *) type = NULL; - VIR_AUTOFREE(char *) network = NULL; - VIR_AUTOFREE(char *) portgroup = NULL; - VIR_AUTOFREE(char *) portid = NULL; - VIR_AUTOFREE(char *) bridge = NULL; - VIR_AUTOFREE(char *) dev = NULL; - VIR_AUTOFREE(char *) ifname = NULL; - VIR_AUTOFREE(char *) managed_tap = NULL; - VIR_AUTOFREE(char *) ifname_guest = NULL; - VIR_AUTOFREE(char *) ifname_guest_actual = NULL; - VIR_AUTOFREE(char *) script = NULL; - VIR_AUTOFREE(char *) address = NULL; - VIR_AUTOFREE(char *) port = NULL; - VIR_AUTOFREE(char *) localaddr = NULL; - VIR_AUTOFREE(char *) localport = NULL; - VIR_AUTOFREE(char *) model = NULL; - VIR_AUTOFREE(char *) backend = NULL; - VIR_AUTOFREE(char *) txmode = NULL; - VIR_AUTOFREE(char *) ioeventfd = NULL; - VIR_AUTOFREE(char *) event_idx = NULL; - VIR_AUTOFREE(char *) queues = NULL; - VIR_AUTOFREE(char *) rx_queue_size = NULL; - VIR_AUTOFREE(char *) tx_queue_size = NULL; - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) filter = NULL; - VIR_AUTOFREE(char *) internal = NULL; - VIR_AUTOFREE(char *) devaddr = NULL; - VIR_AUTOFREE(char *) mode = NULL; - VIR_AUTOFREE(char *) linkstate = NULL; - VIR_AUTOFREE(char *) addrtype = NULL; - VIR_AUTOFREE(char *) domain_name = NULL; - VIR_AUTOFREE(char *) vhostuser_mode = NULL; - VIR_AUTOFREE(char *) vhostuser_path = NULL; - VIR_AUTOFREE(char *) vhostuser_type = NULL; - VIR_AUTOFREE(char *) trustGuestRxFilters = NULL; - VIR_AUTOFREE(char *) vhost_path = NULL; + g_autofree char *macaddr = NULL; + g_autofree char *type = NULL; + g_autofree char *network = NULL; + g_autofree char *portgroup = NULL; + g_autofree char *portid = NULL; + g_autofree char *bridge = NULL; + g_autofree char *dev = NULL; + g_autofree char *ifname = NULL; + g_autofree char *managed_tap = NULL; + g_autofree char *ifname_guest = NULL; + g_autofree char *ifname_guest_actual = NULL; + g_autofree char *script = NULL; + g_autofree char *address = NULL; + g_autofree char *port = NULL; + g_autofree char *localaddr = NULL; + g_autofree char *localport = NULL; + g_autofree char *model = NULL; + g_autofree char *backend = NULL; + g_autofree char *txmode = NULL; + g_autofree char *ioeventfd = NULL; + g_autofree char *event_idx = NULL; + g_autofree char *queues = NULL; + g_autofree char *rx_queue_size = NULL; + g_autofree char *tx_queue_size = NULL; + g_autofree char *str = NULL; + g_autofree char *filter = NULL; + g_autofree char *internal = NULL; + g_autofree char *devaddr = NULL; + g_autofree char *mode = NULL; + g_autofree char *linkstate = NULL; + g_autofree char *addrtype = NULL; + g_autofree char *domain_name = NULL; + g_autofree char *vhostuser_mode = NULL; + g_autofree char *vhostuser_path = NULL; + g_autofree char *vhostuser_type = NULL; + g_autofree char *trustGuestRxFilters = NULL; + g_autofree char *vhost_path = NULL; if (!(def = virDomainNetDefNew(xmlopt))) return NULL; @@ -12359,11 +12359,11 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr def, { xmlNodePtr child; unsigned int port; - VIR_AUTOFREE(char *) targetType = virXMLPropString(cur, "type"); - VIR_AUTOFREE(char *) targetModel = NULL; - VIR_AUTOFREE(char *) addrStr = NULL; - VIR_AUTOFREE(char *) portStr = NULL; - VIR_AUTOFREE(char *) stateStr = NULL; + g_autofree char *targetType = virXMLPropString(cur, "type"); + g_autofree char *targetModel = NULL; + g_autofree char *addrStr = NULL; + g_autofree char *portStr = NULL; + g_autofree char *stateStr = NULL; if ((def->targetType = virDomainChrTargetTypeFromString(def->deviceType, @@ -12495,7 +12495,7 @@ typedef enum { static int virDomainChrSourceDefParseMode(xmlNodePtr source) { - VIR_AUTOFREE(char *) mode = virXMLPropString(source, "mode"); + g_autofree char *mode = virXMLPropString(source, "mode"); if (!mode || STREQ(mode, "connect")) { return VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT; @@ -12517,7 +12517,7 @@ virDomainChrSourceDefParseTCP(virDomainChrSourceDefPtr def, { int mode; int tmpVal; - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree char *tmp = NULL; if ((mode = virDomainChrSourceDefParseMode(source)) < 0) return -1; @@ -12607,7 +12607,7 @@ static int virDomainChrSourceDefParseFile(virDomainChrSourceDefPtr def, xmlNodePtr source) { - VIR_AUTOFREE(char *) append = NULL; + g_autofree char *append = NULL; def->data.file.path = virXMLPropString(source, "path"); @@ -12627,7 +12627,7 @@ static int virDomainChrSourceDefParseProtocol(virDomainChrSourceDefPtr def, xmlNodePtr protocol) { - VIR_AUTOFREE(char *) prot = NULL; + g_autofree char *prot = NULL; if (def->type != VIR_DOMAIN_CHR_TYPE_TCP) return 0; @@ -12648,7 +12648,7 @@ static int virDomainChrSourceDefParseLog(virDomainChrSourceDefPtr def, xmlNodePtr log) { - VIR_AUTOFREE(char *) append = NULL; + g_autofree char *append = NULL; def->logfile = virXMLPropString(log, "file"); @@ -12910,7 +12910,7 @@ virDomainChrDefParseXML(virDomainXMLOptionPtr xmlopt, const char *nodeName; virDomainChrDefPtr def; bool seenTarget = false; - VIR_AUTOFREE(char *) type = NULL; + g_autofree char *type = NULL; if (!(def = virDomainChrDefNew(xmlopt))) return NULL; @@ -12994,8 +12994,8 @@ virDomainSmartcardDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr cur; virDomainSmartcardDefPtr def; size_t i; - VIR_AUTOFREE(char *) mode = NULL; - VIR_AUTOFREE(char *) type = NULL; + g_autofree char *mode = NULL; + g_autofree char *type = NULL; if (VIR_ALLOC(def) < 0) return NULL; @@ -13148,12 +13148,12 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt, virDomainTPMDefPtr def; VIR_XPATH_NODE_AUTORESTORE(ctxt); int nbackends; - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(char *) model = NULL; - VIR_AUTOFREE(char *) backend = NULL; - VIR_AUTOFREE(char *) version = NULL; - VIR_AUTOFREE(char *) secretuuid = NULL; - VIR_AUTOFREE(xmlNodePtr *) backends = NULL; + g_autofree char *path = NULL; + g_autofree char *model = NULL; + g_autofree char *backend = NULL; + g_autofree char *version = NULL; + g_autofree char *secretuuid = NULL; + g_autofree xmlNodePtr *backends = NULL; if (VIR_ALLOC(def) < 0) return NULL; @@ -13249,7 +13249,7 @@ virDomainPanicDefParseXML(virDomainXMLOptionPtr xmlopt, unsigned int flags) { virDomainPanicDefPtr panic; - VIR_AUTOFREE(char *) model = NULL; + g_autofree char *model = NULL; if (VIR_ALLOC(panic) < 0) return NULL; @@ -13285,10 +13285,10 @@ virDomainInputDefParseXML(virDomainXMLOptionPtr xmlopt, { VIR_XPATH_NODE_AUTORESTORE(ctxt); virDomainInputDefPtr def; - VIR_AUTOFREE(char *) evdev = NULL; - VIR_AUTOFREE(char *) type = NULL; - VIR_AUTOFREE(char *) bus = NULL; - VIR_AUTOFREE(char *) model = NULL; + g_autofree char *evdev = NULL; + g_autofree char *type = NULL; + g_autofree char *bus = NULL; + g_autofree char *model = NULL; if (VIR_ALLOC(def) < 0) return NULL; @@ -13441,7 +13441,7 @@ virDomainHubDefParseXML(virDomainXMLOptionPtr xmlopt, unsigned int flags) { virDomainHubDefPtr def; - VIR_AUTOFREE(char *) type = NULL; + g_autofree char *type = NULL; if (VIR_ALLOC(def) < 0) return NULL; @@ -13482,11 +13482,11 @@ virDomainTimerDefParseXML(xmlNodePtr node, VIR_XPATH_NODE_AUTORESTORE(ctxt); xmlNodePtr catchup; int ret; - VIR_AUTOFREE(char *) name = NULL; - VIR_AUTOFREE(char *) present = NULL; - VIR_AUTOFREE(char *) tickpolicy = NULL; - VIR_AUTOFREE(char *) track = NULL; - VIR_AUTOFREE(char *) mode = NULL; + g_autofree char *name = NULL; + g_autofree char *present = NULL; + g_autofree char *tickpolicy = NULL; + g_autofree char *track = NULL; + g_autofree char *mode = NULL; if (VIR_ALLOC(def) < 0) return NULL; @@ -13602,8 +13602,8 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node, virDomainGraphicsAuthDefPtr def, int type) { - VIR_AUTOFREE(char *) validTo = NULL; - VIR_AUTOFREE(char *) connected = virXMLPropString(node, "connected"); + g_autofree char *validTo = NULL; + g_autofree char *connected = virXMLPropString(node, "connected"); def->passwd = virXMLPropString(node, "passwd"); @@ -13689,14 +13689,14 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, int ret = -1; const char *graphicsType = virDomainGraphicsTypeToString(graphics->type); int tmp, typeVal; - VIR_AUTOFREE(char *) type = virXMLPropString(node, "type"); - VIR_AUTOFREE(char *) address = virXMLPropString(node, "address"); - VIR_AUTOFREE(char *) network = virXMLPropString(node, "network"); - VIR_AUTOFREE(char *) socketPath = virXMLPropString(node, "socket"); - VIR_AUTOFREE(char *) fromConfig = virXMLPropString(node, "fromConfig"); - VIR_AUTOFREE(char *) autoGenerated = virXMLPropString(node, "autoGenerated"); - VIR_AUTOFREE(char *) addressCompat = NULL; - VIR_AUTOFREE(char *) socketCompat = NULL; + g_autofree char *type = virXMLPropString(node, "type"); + g_autofree char *address = virXMLPropString(node, "address"); + g_autofree char *network = virXMLPropString(node, "network"); + g_autofree char *socketPath = virXMLPropString(node, "socket"); + g_autofree char *fromConfig = virXMLPropString(node, "fromConfig"); + g_autofree char *autoGenerated = virXMLPropString(node, "autoGenerated"); + g_autofree char *addressCompat = NULL; + g_autofree char *socketCompat = NULL; if (parent) { addressCompat = virXMLPropString(parent, "listen"); @@ -13835,8 +13835,8 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def, virDomainGraphicsListenDef newListen = {0}; int nListens; int ret = -1; - VIR_AUTOFREE(xmlNodePtr *) listenNodes = NULL; - VIR_AUTOFREE(char *) socketPath = NULL; + g_autofree xmlNodePtr *listenNodes = NULL; + g_autofree char *socketPath = NULL; ctxt->node = node; @@ -13912,11 +13912,11 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDefPtr def, xmlXPathContextPtr ctxt, unsigned int flags) { - VIR_AUTOFREE(char *) port = virXMLPropString(node, "port"); - VIR_AUTOFREE(char *) websocket = virXMLPropString(node, "websocket"); - VIR_AUTOFREE(char *) websocketGenerated = virXMLPropString(node, "websocketGenerated"); - VIR_AUTOFREE(char *) sharePolicy = virXMLPropString(node, "sharePolicy"); - VIR_AUTOFREE(char *) autoport = virXMLPropString(node, "autoport"); + g_autofree char *port = virXMLPropString(node, "port"); + g_autofree char *websocket = virXMLPropString(node, "websocket"); + g_autofree char *websocketGenerated = virXMLPropString(node, "websocketGenerated"); + g_autofree char *sharePolicy = virXMLPropString(node, "sharePolicy"); + g_autofree char *autoport = virXMLPropString(node, "autoport"); if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) return -1; @@ -13994,8 +13994,8 @@ virDomainGraphicsDefParseXMLSDL(virDomainGraphicsDefPtr def, int enableVal; xmlNodePtr glNode; int ret = -1; - VIR_AUTOFREE(char *) fullscreen = virXMLPropString(node, "fullscreen"); - VIR_AUTOFREE(char *) enable = NULL; + g_autofree char *fullscreen = virXMLPropString(node, "fullscreen"); + g_autofree char *enable = NULL; ctxt->node = node; @@ -14042,10 +14042,10 @@ virDomainGraphicsDefParseXMLRDP(virDomainGraphicsDefPtr def, xmlXPathContextPtr ctxt, unsigned int flags) { - VIR_AUTOFREE(char *) port = virXMLPropString(node, "port"); - VIR_AUTOFREE(char *) autoport = virXMLPropString(node, "autoport"); - VIR_AUTOFREE(char *) replaceUser = virXMLPropString(node, "replaceUser"); - VIR_AUTOFREE(char *) multiUser = virXMLPropString(node, "multiUser"); + g_autofree char *port = virXMLPropString(node, "port"); + g_autofree char *autoport = virXMLPropString(node, "autoport"); + g_autofree char *replaceUser = virXMLPropString(node, "replaceUser"); + g_autofree char *multiUser = virXMLPropString(node, "multiUser"); if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) return -1; @@ -14085,7 +14085,7 @@ static int virDomainGraphicsDefParseXMLDesktop(virDomainGraphicsDefPtr def, xmlNodePtr node) { - VIR_AUTOFREE(char *) fullscreen = virXMLPropString(node, "fullscreen"); + g_autofree char *fullscreen = virXMLPropString(node, "fullscreen"); if (fullscreen != NULL) { if (virStringParseYesNo(fullscreen, &def->data.desktop.fullscreen) < 0) { @@ -14111,10 +14111,10 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, { xmlNodePtr cur; int defaultModeVal; - VIR_AUTOFREE(char *) port = virXMLPropString(node, "port"); - VIR_AUTOFREE(char *) tlsPort = virXMLPropString(node, "tlsPort"); - VIR_AUTOFREE(char *) autoport = virXMLPropString(node, "autoport"); - VIR_AUTOFREE(char *) defaultMode = virXMLPropString(node, "defaultMode"); + g_autofree char *port = virXMLPropString(node, "port"); + g_autofree char *tlsPort = virXMLPropString(node, "tlsPort"); + g_autofree char *autoport = virXMLPropString(node, "autoport"); + g_autofree char *defaultMode = virXMLPropString(node, "defaultMode"); if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) return -1; @@ -14175,8 +14175,8 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, if (cur->type == XML_ELEMENT_NODE) { if (virXMLNodeNameEqual(cur, "channel")) { int nameval, modeval; - VIR_AUTOFREE(char *) name = NULL; - VIR_AUTOFREE(char *) mode = NULL; + g_autofree char *name = NULL; + g_autofree char *mode = NULL; name = virXMLPropString(cur, "name"); mode = virXMLPropString(cur, "mode"); @@ -14203,7 +14203,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, def->data.spice.channels[nameval] = modeval; } else if (virXMLNodeNameEqual(cur, "image")) { int compressionVal; - VIR_AUTOFREE(char *) compression = virXMLPropString(cur, "compression"); + g_autofree char *compression = virXMLPropString(cur, "compression"); if (!compression) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -14222,7 +14222,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, def->data.spice.image = compressionVal; } else if (virXMLNodeNameEqual(cur, "jpeg")) { int compressionVal; - VIR_AUTOFREE(char *) compression = virXMLPropString(cur, "compression"); + g_autofree char *compression = virXMLPropString(cur, "compression"); if (!compression) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -14241,7 +14241,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, def->data.spice.jpeg = compressionVal; } else if (virXMLNodeNameEqual(cur, "zlib")) { int compressionVal; - VIR_AUTOFREE(char *) compression = virXMLPropString(cur, "compression"); + g_autofree char *compression = virXMLPropString(cur, "compression"); if (!compression) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -14260,7 +14260,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, def->data.spice.zlib = compressionVal; } else if (virXMLNodeNameEqual(cur, "playback")) { int compressionVal; - VIR_AUTOFREE(char *) compression = virXMLPropString(cur, "compression"); + g_autofree char *compression = virXMLPropString(cur, "compression"); if (!compression) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -14278,7 +14278,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, def->data.spice.playback = compressionVal; } else if (virXMLNodeNameEqual(cur, "streaming")) { int modeVal; - VIR_AUTOFREE(char *) mode = virXMLPropString(cur, "mode"); + g_autofree char *mode = virXMLPropString(cur, "mode"); if (!mode) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -14295,7 +14295,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, def->data.spice.streaming = modeVal; } else if (virXMLNodeNameEqual(cur, "clipboard")) { int copypasteVal; - VIR_AUTOFREE(char *) copypaste = virXMLPropString(cur, "copypaste"); + g_autofree char *copypaste = virXMLPropString(cur, "copypaste"); if (!copypaste) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -14313,7 +14313,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, def->data.spice.copypaste = copypasteVal; } else if (virXMLNodeNameEqual(cur, "filetransfer")) { int enableVal; - VIR_AUTOFREE(char *) enable = virXMLPropString(cur, "enable"); + g_autofree char *enable = virXMLPropString(cur, "enable"); if (!enable) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -14331,8 +14331,8 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, def->data.spice.filetransfer = enableVal; } else if (virXMLNodeNameEqual(cur, "gl")) { int enableVal; - VIR_AUTOFREE(char *) enable = virXMLPropString(cur, "enable"); - VIR_AUTOFREE(char *) rendernode = virXMLPropString(cur, "rendernode"); + g_autofree char *enable = virXMLPropString(cur, "enable"); + g_autofree char *rendernode = virXMLPropString(cur, "rendernode"); if (!enable) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -14352,7 +14352,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, } else if (virXMLNodeNameEqual(cur, "mouse")) { int modeVal; - VIR_AUTOFREE(char *) mode = virXMLPropString(cur, "mode"); + g_autofree char *mode = virXMLPropString(cur, "mode"); if (!mode) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -14439,7 +14439,7 @@ virDomainGraphicsDefParseXML(virDomainXMLOptionPtr xmlopt, { virDomainGraphicsDefPtr def; int typeVal; - VIR_AUTOFREE(char *) type = NULL; + g_autofree char *type = NULL; if (!(def = virDomainGraphicsDefNew(xmlopt))) return NULL; @@ -14501,7 +14501,7 @@ static virDomainSoundCodecDefPtr virDomainSoundCodecDefParseXML(xmlNodePtr node) { virDomainSoundCodecDefPtr def; - VIR_AUTOFREE(char *) type = NULL; + g_autofree char *type = NULL; if (VIR_ALLOC(def) < 0) return NULL; @@ -14531,7 +14531,7 @@ virDomainSoundDefParseXML(virDomainXMLOptionPtr xmlopt, { virDomainSoundDefPtr def; VIR_XPATH_NODE_AUTORESTORE(ctxt); - VIR_AUTOFREE(char *) model = NULL; + g_autofree char *model = NULL; if (VIR_ALLOC(def) < 0) return NULL; @@ -14548,7 +14548,7 @@ virDomainSoundDefParseXML(virDomainXMLOptionPtr xmlopt, if (def->model == VIR_DOMAIN_SOUND_MODEL_ICH6 || def->model == VIR_DOMAIN_SOUND_MODEL_ICH9) { int ncodecs; - VIR_AUTOFREE(xmlNodePtr *) codecNodes = NULL; + g_autofree xmlNodePtr *codecNodes = NULL; /* parse the <codec> subelements for sound models that support it */ ncodecs = virXPathNodeSet("./codec", ctxt, &codecNodes); @@ -14591,8 +14591,8 @@ virDomainWatchdogDefParseXML(virDomainXMLOptionPtr xmlopt, unsigned int flags) { virDomainWatchdogDefPtr def; - VIR_AUTOFREE(char *) model = NULL; - VIR_AUTOFREE(char *) action = NULL; + g_autofree char *model = NULL; + g_autofree char *action = NULL; if (VIR_ALLOC(def) < 0) return NULL; @@ -14644,10 +14644,10 @@ virDomainRNGDefParseXML(virDomainXMLOptionPtr xmlopt, virDomainRNGDefPtr def; VIR_XPATH_NODE_AUTORESTORE(ctxt); int nbackends; - VIR_AUTOFREE(xmlNodePtr *) backends = NULL; - VIR_AUTOFREE(char *) model = NULL; - VIR_AUTOFREE(char *) backend = NULL; - VIR_AUTOFREE(char *) type = NULL; + g_autofree xmlNodePtr *backends = NULL; + g_autofree char *model = NULL; + g_autofree char *backend = NULL; + g_autofree char *type = NULL; if (VIR_ALLOC(def) < 0) return NULL; @@ -14757,8 +14757,8 @@ virDomainMemballoonDefParseXML(virDomainXMLOptionPtr xmlopt, virDomainMemballoonDefPtr def; VIR_XPATH_NODE_AUTORESTORE(ctxt); unsigned int period = 0; - VIR_AUTOFREE(char *) model = NULL; - VIR_AUTOFREE(char *) deflate = NULL; + g_autofree char *model = NULL; + g_autofree char *deflate = NULL; if (VIR_ALLOC(def) < 0) return NULL; @@ -14844,7 +14844,7 @@ virDomainShmemDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr msi = NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt); xmlNodePtr server = NULL; - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree char *tmp = NULL; if (VIR_ALLOC(def) < 0) return NULL; @@ -14998,7 +14998,7 @@ virSysinfoSystemParseXML(xmlNodePtr node, VIR_XPATH_NODE_AUTORESTORE(ctxt); int ret = -1; virSysinfoSystemDefPtr def; - VIR_AUTOFREE(char *) tmpUUID = NULL; + g_autofree char *tmpUUID = NULL; ctxt->node = node; @@ -15073,8 +15073,8 @@ virSysinfoBaseBoardParseXML(xmlXPathContextPtr ctxt, size_t i, nboards = 0; VIR_XPATH_NODE_AUTORESTORE(ctxt); int n; - VIR_AUTOFREE(virSysinfoBaseBoardDefPtr) boards = NULL; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree virSysinfoBaseBoardDefPtr boards = NULL; + g_autofree xmlNodePtr *nodes = NULL; if ((n = virXPathNodeSet("./baseBoard", ctxt, &nodes)) < 0) return ret; @@ -15126,7 +15126,7 @@ virSysinfoOEMStringsParseXML(xmlNodePtr node, virSysinfoOEMStringsDefPtr def; int nstrings; size_t i; - VIR_AUTOFREE(xmlNodePtr *) strings = NULL; + g_autofree xmlNodePtr *strings = NULL; ctxt->node = node; @@ -15207,7 +15207,7 @@ virSysinfoParseXML(xmlNodePtr node, { virSysinfoDefPtr def; xmlNodePtr tmpnode; - VIR_AUTOFREE(char *) type = NULL; + g_autofree char *type = NULL; if (!virXMLNodeNameEqual(node, "sysinfo")) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -15358,9 +15358,9 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node) xmlNodePtr cur; virDomainVideoAccelDefPtr def; int val; - VIR_AUTOFREE(char *) accel2d = NULL; - VIR_AUTOFREE(char *) accel3d = NULL; - VIR_AUTOFREE(char *) rendernode = NULL; + g_autofree char *accel2d = NULL; + g_autofree char *accel3d = NULL; + g_autofree char *rendernode = NULL; cur = node->children; while (cur != NULL) { @@ -15412,7 +15412,7 @@ virDomainVideoDriverDefParseXML(xmlNodePtr node) xmlNodePtr cur; virDomainVideoDriverDefPtr def; int val; - VIR_AUTOFREE(char *) vgaconf = NULL; + g_autofree char *vgaconf = NULL; cur = node->children; while (cur != NULL) { @@ -15452,14 +15452,14 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xmlopt, virDomainVideoDefPtr def; xmlNodePtr cur; VIR_XPATH_NODE_AUTORESTORE(ctxt); - VIR_AUTOFREE(char *) type = NULL; - VIR_AUTOFREE(char *) driver_name = NULL; - VIR_AUTOFREE(char *) heads = NULL; - VIR_AUTOFREE(char *) vram = NULL; - VIR_AUTOFREE(char *) vram64 = NULL; - VIR_AUTOFREE(char *) ram = NULL; - VIR_AUTOFREE(char *) vgamem = NULL; - VIR_AUTOFREE(char *) primary = NULL; + g_autofree char *type = NULL; + g_autofree char *driver_name = NULL; + g_autofree char *heads = NULL; + g_autofree char *vram = NULL; + g_autofree char *vram64 = NULL; + g_autofree char *ram = NULL; + g_autofree char *vgamem = NULL; + g_autofree char *primary = NULL; if (!(def = virDomainVideoDefNew(xmlopt))) return NULL; @@ -15594,8 +15594,8 @@ virDomainHostdevDefParseXML(virDomainXMLOptionPtr xmlopt, { virDomainHostdevDefPtr def; VIR_XPATH_NODE_AUTORESTORE(ctxt); - VIR_AUTOFREE(char *) mode = virXMLPropString(node, "mode"); - VIR_AUTOFREE(char *) type = virXMLPropString(node, "type"); + g_autofree char *mode = virXMLPropString(node, "mode"); + g_autofree char *type = virXMLPropString(node, "type"); ctxt->node = node; @@ -15671,8 +15671,8 @@ virDomainRedirdevDefParseXML(virDomainXMLOptionPtr xmlopt, { xmlNodePtr cur; virDomainRedirdevDefPtr def; - VIR_AUTOFREE(char *) bus = NULL; - VIR_AUTOFREE(char *) type = NULL; + g_autofree char *bus = NULL; + g_autofree char *type = NULL; if (VIR_ALLOC(def) < 0) return NULL; @@ -15778,11 +15778,11 @@ static virDomainRedirFilterUSBDevDefPtr virDomainRedirFilterUSBDevDefParseXML(xmlNodePtr node) { virDomainRedirFilterUSBDevDefPtr def; - VIR_AUTOFREE(char *) class = NULL; - VIR_AUTOFREE(char *) vendor = NULL; - VIR_AUTOFREE(char *) product = NULL; - VIR_AUTOFREE(char *) version = NULL; - VIR_AUTOFREE(char *) allow = NULL; + g_autofree char *class = NULL; + g_autofree char *vendor = NULL; + g_autofree char *product = NULL; + g_autofree char *version = NULL; + g_autofree char *allow = NULL; if (VIR_ALLOC(def) < 0) return NULL; @@ -15866,7 +15866,7 @@ virDomainRedirFilterDefParseXML(xmlNodePtr node, size_t i; VIR_XPATH_NODE_AUTORESTORE(ctxt); virDomainRedirFilterDefPtr def = NULL; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; if (VIR_ALLOC(def) < 0) goto error; @@ -15902,7 +15902,7 @@ virDomainEventActionParseXML(xmlXPathContextPtr ctxt, int defaultVal, virEventActionFromStringFunc convFunc) { - VIR_AUTOFREE(char *) tmp = virXPathString(xpath, ctxt); + g_autofree char *tmp = virXPathString(xpath, ctxt); if (tmp == NULL) { *val = defaultVal; @@ -15922,7 +15922,7 @@ virDomainPMStateParseXML(xmlXPathContextPtr ctxt, const char *xpath, int *val) { - VIR_AUTOFREE(char *) tmp = virXPathString(xpath, ctxt); + g_autofree char *tmp = virXPathString(xpath, ctxt); if (tmp) { *val = virTristateBoolTypeFromString(tmp); @@ -15942,8 +15942,8 @@ virDomainPerfEventDefParseXML(virDomainPerfDefPtr perf, xmlNodePtr node) { int event; - VIR_AUTOFREE(char *) name = NULL; - VIR_AUTOFREE(char *) enabled = NULL; + g_autofree char *name = NULL; + g_autofree char *enabled = NULL; if (!(name = virXMLPropString(node, "name"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing perf event name")); @@ -15984,7 +15984,7 @@ virDomainPerfDefParseXML(virDomainDefPtr def, { size_t i; int n; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; if ((n = virXPathNodeSet("./perf/event", ctxt, &nodes)) < 0) return n; @@ -16005,7 +16005,7 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node, int ret = -1; VIR_XPATH_NODE_AUTORESTORE(ctxt); ctxt->node = node; - VIR_AUTOFREE(char *) nodemask = NULL; + g_autofree char *nodemask = NULL; switch ((virDomainMemoryModel) def->model) { case VIR_DOMAIN_MEMORY_MODEL_DIMM: @@ -16113,7 +16113,7 @@ virDomainSEVDefParseXML(xmlNodePtr sevNode, VIR_XPATH_NODE_AUTORESTORE(ctxt); virDomainSEVDefPtr def; unsigned long policy; - VIR_AUTOFREE(char *) type = NULL; + g_autofree char *type = NULL; if (VIR_ALLOC(def) < 0) return NULL; @@ -16181,7 +16181,7 @@ virDomainMemoryDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node; virDomainMemoryDefPtr def; int val; - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree char *tmp = NULL; if (VIR_ALLOC(def) < 0) return NULL; @@ -16257,8 +16257,8 @@ virDomainIOMMUDefParseXML(xmlNodePtr node, VIR_XPATH_NODE_AUTORESTORE(ctxt); xmlNodePtr driver; int val; - VIR_AUTOFREE(char *) tmp = NULL; - VIR_AUTOFREE(virDomainIOMMUDefPtr) iommu = NULL; + g_autofree char *tmp = NULL; + g_autofree virDomainIOMMUDefPtr iommu = NULL; ctxt->node = node; @@ -16332,8 +16332,8 @@ virDomainVsockDefParseXML(virDomainXMLOptionPtr xmlopt, VIR_XPATH_NODE_AUTORESTORE(ctxt); xmlNodePtr cid; int val; - VIR_AUTOFREE(char *) tmp = NULL; - VIR_AUTOFREE(virDomainVsockDefPtr) vsock = NULL; + g_autofree char *tmp = NULL; + g_autofree virDomainVsockDefPtr vsock = NULL; ctxt->node = node; @@ -16395,7 +16395,7 @@ virDomainDeviceDefParse(const char *xmlStr, VIR_AUTOPTR(xmlDoc) xml = NULL; xmlNodePtr node; VIR_AUTOPTR(xmlXPathContext) ctxt = NULL; - VIR_AUTOFREE(virDomainDeviceDefPtr) dev = NULL; + g_autofree virDomainDeviceDefPtr dev = NULL; char *netprefix; if (!(xml = virXMLParseStringCtxt(xmlStr, _("(device_definition)"), &ctxt))) @@ -18004,7 +18004,7 @@ virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps) { char *retemu; - VIR_AUTOFREE(virCapsDomainDataPtr) capsdata = NULL; + g_autofree virCapsDomainDataPtr capsdata = NULL; if (!(capsdata = virCapabilitiesDomainDataLookup(caps, def->os.type, def->os.arch, def->virtType, NULL, NULL))) @@ -18023,8 +18023,8 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, xmlNodePtr node; size_t i; int n; - VIR_AUTOFREE(char *) tmp = NULL; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree char *tmp = NULL; + g_autofree xmlNodePtr *nodes = NULL; /* analysis of the boot devices */ if ((n = virXPathNodeSet("./os/boot", ctxt, &nodes)) < 0) @@ -18182,7 +18182,7 @@ static virDomainIOThreadIDDefPtr virDomainIOThreadIDDefParseXML(xmlNodePtr node) { virDomainIOThreadIDDefPtr iothrid; - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree char *tmp = NULL; if (VIR_ALLOC(iothrid) < 0) return NULL; @@ -18216,8 +18216,8 @@ virDomainDefParseIOThreads(virDomainDefPtr def, size_t i; int n = 0; unsigned int iothreads = 0; - VIR_AUTOFREE(char *) tmp = NULL; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree char *tmp = NULL; + g_autofree xmlNodePtr *nodes = NULL; tmp = virXPathString("string(./iothreads[1])", ctxt); if (tmp && virStrToLong_uip(tmp, NULL, 10, &iothreads) < 0) { @@ -18266,7 +18266,7 @@ virDomainVcpuPinDefParseXML(virDomainDefPtr def, { virDomainVcpuDefPtr vcpu; unsigned int vcpuid; - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree char *tmp = NULL; if (!(tmp = virXMLPropString(node, "vcpu"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing vcpu id in vcpupin")); @@ -18320,7 +18320,7 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node, { virDomainIOThreadIDDefPtr iothrid; unsigned int iothreadid; - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree char *tmp = NULL; VIR_AUTOPTR(virBitmap) cpumask = NULL; if (!(tmp = virXMLPropString(node, "iothread"))) { @@ -18385,7 +18385,7 @@ static virBitmapPtr virDomainEmulatorPinDefParseXML(xmlNodePtr node) { virBitmapPtr ret = NULL; - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree char *tmp = NULL; VIR_AUTOPTR(virBitmap) def = NULL; if (!(tmp = virXMLPropString(node, "cpuset"))) { @@ -18539,7 +18539,7 @@ virDomainHugepagesParseXML(xmlNodePtr node, { int ret = -1; VIR_XPATH_NODE_AUTORESTORE(ctxt); - VIR_AUTOFREE(char *) nodeset = NULL; + g_autofree char *nodeset = NULL; ctxt->node = node; @@ -18640,9 +18640,9 @@ virDomainLoaderDefParseXML(xmlNodePtr node, virDomainLoaderDefPtr loader, bool fwAutoSelect) { - VIR_AUTOFREE(char *) readonly_str = NULL; - VIR_AUTOFREE(char *) secure_str = NULL; - VIR_AUTOFREE(char *) type_str = NULL; + g_autofree char *readonly_str = NULL; + g_autofree char *secure_str = NULL; + g_autofree char *type_str = NULL; secure_str = virXMLPropString(node, "secure"); @@ -18688,7 +18688,7 @@ virDomainSchedulerParseCommonAttrs(xmlNodePtr node, int *priority) { int pol = 0; - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree char *tmp = NULL; if (!(tmp = virXMLPropString(node, "scheduler"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -18728,7 +18728,7 @@ static int virDomainEmulatorSchedParse(xmlNodePtr node, virDomainDefPtr def) { - VIR_AUTOFREE(virDomainThreadSchedParamPtr) sched = NULL; + g_autofree virDomainThreadSchedParamPtr sched = NULL; if (VIR_ALLOC(sched) < 0) return -1; @@ -18750,7 +18750,7 @@ virDomainSchedulerParse(xmlNodePtr node, int *priority) { virBitmapPtr ret = NULL; - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree char *tmp = NULL; if (!(tmp = virXMLPropString(node, name))) { virReportError(VIR_ERR_XML_ERROR, @@ -18861,8 +18861,8 @@ virDomainVcpuParse(virDomainDefPtr def, size_t i; unsigned int maxvcpus; unsigned int vcpus; - VIR_AUTOFREE(char *) tmp = NULL; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree char *tmp = NULL; + g_autofree xmlNodePtr *nodes = NULL; vcpus = maxvcpus = 1; @@ -19004,8 +19004,8 @@ virDomainDefParseBootOptions(virDomainDefPtr def, char *name = NULL; size_t i; int n; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree xmlNodePtr *nodes = NULL; + g_autofree char *tmp = NULL; /* * Booting options for different OS types.... @@ -19078,7 +19078,7 @@ virDomainDefParseBootOptions(virDomainDefPtr def, def->os.type == VIR_DOMAIN_OSTYPE_XENPVH || def->os.type == VIR_DOMAIN_OSTYPE_HVM || def->os.type == VIR_DOMAIN_OSTYPE_UML) { - VIR_AUTOFREE(char *) firmware = NULL; + g_autofree char *firmware = NULL; xmlNodePtr loader_node; def->os.kernel = virXPathString("string(./os/kernel[1])", ctxt); @@ -19162,7 +19162,7 @@ virDomainResctrlParseVcpus(virDomainDefPtr def, xmlNodePtr node, virBitmapPtr *vcpus) { - VIR_AUTOFREE(char *) vcpus_str = NULL; + g_autofree char *vcpus_str = NULL; vcpus_str = virXMLPropString(node, "vcpus"); if (!vcpus_str) { @@ -19221,7 +19221,7 @@ virDomainCachetuneDefParseCache(xmlXPathContextPtr ctxt, int type; unsigned long long size; int ret = -1; - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree char *tmp = NULL; ctxt->node = node; @@ -19368,9 +19368,9 @@ virDomainResctrlMonDefParse(virDomainDefPtr def, int n = 0; int rv = -1; int ret = -1; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; - VIR_AUTOFREE(char *) tmp = NULL; - VIR_AUTOFREE(char *) id = NULL; + g_autofree xmlNodePtr *nodes = NULL; + g_autofree char *tmp = NULL; + g_autofree char *id = NULL; ctxt->node = node; @@ -19470,8 +19470,8 @@ virDomainResctrlNew(xmlNodePtr node, { virDomainResctrlDefPtr resctrl = NULL; virDomainResctrlDefPtr ret = NULL; - VIR_AUTOFREE(char *) vcpus_str = NULL; - VIR_AUTOFREE(char *) alloc_id = NULL; + g_autofree char *vcpus_str = NULL; + g_autofree char *alloc_id = NULL; /* We need to format it back because we need to be consistent in the naming * even when users specify some "sub-optimal" string there. */ @@ -19525,7 +19525,7 @@ virDomainCachetuneDefParse(virDomainDefPtr def, int n; int ret = -1; VIR_AUTOPTR(virBitmap) vcpus = NULL; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; VIR_AUTOUNREF(virResctrlAllocPtr) alloc = NULL; ctxt->node = node; @@ -19590,10 +19590,10 @@ virDomainDefParseCaps(virDomainDefPtr def, virCapsPtr caps, unsigned int flags) { - VIR_AUTOFREE(char *) virttype = NULL; - VIR_AUTOFREE(char *) arch = NULL; - VIR_AUTOFREE(char *) ostype = NULL; - VIR_AUTOFREE(virCapsDomainDataPtr) capsdata = NULL; + g_autofree char *virttype = NULL; + g_autofree char *arch = NULL; + g_autofree char *ostype = NULL; + g_autofree virCapsDomainDataPtr capsdata = NULL; virttype = virXPathString("string(./@type)", ctxt); ostype = virXPathString("string(./os/type[1])", ctxt); @@ -19675,7 +19675,7 @@ virDomainMemorytuneDefParseMemory(xmlXPathContextPtr ctxt, unsigned int id; unsigned int bandwidth; int ret = -1; - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree char *tmp = NULL; ctxt->node = node; @@ -19723,7 +19723,7 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, VIR_XPATH_NODE_AUTORESTORE(ctxt); virDomainResctrlDefPtr resctrl = NULL; VIR_AUTOPTR(virBitmap) vcpus = NULL; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; VIR_AUTOUNREF(virResctrlAllocPtr) alloc = NULL; ssize_t i = 0; int n; @@ -19795,11 +19795,11 @@ virDomainDefParseXML(xmlDocPtr xml, bool usb_other = false; bool usb_master = false; char *netprefix = NULL; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree xmlNodePtr *nodes = NULL; + g_autofree char *tmp = NULL; if (flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA) { - VIR_AUTOFREE(char *) schema = NULL; + g_autofree char *schema = NULL; schema = virFileFindResource("domain.rng", abs_top_srcdir "/docs/schemas", @@ -21512,8 +21512,8 @@ virDomainObjParseXML(xmlDocPtr xml, int state; int reason = 0; void *parseOpaque = NULL; - VIR_AUTOFREE(char *) tmp = NULL; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree char *tmp = NULL; + g_autofree xmlNodePtr *nodes = NULL; if (!(obj = virDomainObjNew(xmlopt))) return NULL; @@ -22383,8 +22383,8 @@ virDomainChannelDefCheckABIStability(virDomainChrDefPtr src, case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD: if (memcmp(src->target.addr, dst->target.addr, sizeof(*src->target.addr)) != 0) { - VIR_AUTOFREE(char *) saddr = virSocketAddrFormatFull(src->target.addr, true, ":"); - VIR_AUTOFREE(char *) daddr = virSocketAddrFormatFull(dst->target.addr, true, ":"); + g_autofree char *saddr = virSocketAddrFormatFull(src->target.addr, true, ":"); + g_autofree char *daddr = virSocketAddrFormatFull(dst->target.addr, true, ":"); virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Target channel addr %s does not match source %s"), NULLSTR(daddr), NULLSTR(saddr)); @@ -23160,8 +23160,8 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr src, { size_t i; virErrorPtr err; - VIR_AUTOFREE(char *) strSrc = NULL; - VIR_AUTOFREE(char *) strDst = NULL; + g_autofree char *strSrc = NULL; + g_autofree char *strDst = NULL; if (src->virtType != dst->virtType) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -24089,7 +24089,7 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf, unsigned int flags) { size_t n; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; virBufferAsprintf(attrBuf, " protocol='%s'", virStorageNetProtocolTypeToString(src->protocol)); @@ -25684,9 +25684,9 @@ virDomainNetDefFormat(virBufferPtr buf, virDomainNetGetModelString(def)); if (virDomainNetIsVirtioModel(def)) { int rc = 0; - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) gueststr = NULL; - VIR_AUTOFREE(char *) hoststr = NULL; + g_autofree char *str = NULL; + g_autofree char *gueststr = NULL; + g_autofree char *hoststr = NULL; if (virDomainVirtioNetDriverFormat(&str, def) < 0 || virDomainVirtioNetGuestOptsFormat(&gueststr, def) < 0 || @@ -25926,7 +25926,7 @@ virDomainChrTargetDefFormat(virBufferPtr buf, switch (def->targetType) { case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD: { int port = virSocketAddrGetPort(def->target.addr); - VIR_AUTOFREE(char *) addr = NULL; + g_autofree char *addr = NULL; if (port < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unable to format guestfwd port")); @@ -26463,7 +26463,7 @@ static int virDomainMemorySourceDefFormat(virBufferPtr buf, virDomainMemoryDefPtr def) { - VIR_AUTOFREE(char *) bitmap = NULL; + g_autofree char *bitmap = NULL; if (!def->pagesize && !def->sourceNodes && !def->nvdimmPath) return 0; @@ -27428,7 +27428,7 @@ virDomainHugepagesFormatBuf(virBufferPtr buf, hugepage->size); if (hugepage->nodemask) { - VIR_AUTOFREE(char *) nodeset = NULL; + g_autofree char *nodeset = NULL; if (!(nodeset = virBitmapFormat(hugepage->nodemask))) return -1; virBufferAsprintf(buf, " nodeset='%s'", nodeset); @@ -27629,7 +27629,7 @@ virDomainResctrlMonDefFormatHelper(virDomainResctrlMonDefPtr domresmon, virResctrlMonitorType tag, virBufferPtr buf) { - VIR_AUTOFREE(char *) vcpus = NULL; + g_autofree char *vcpus = NULL; if (domresmon->tag != tag) return 0; @@ -27659,7 +27659,7 @@ virDomainCachetuneDefFormat(virBufferPtr buf, g_auto(virBuffer) childrenBuf = VIR_BUFFER_INITIALIZER; size_t i = 0; int ret = -1; - VIR_AUTOFREE(char *) vcpus = NULL; + g_autofree char *vcpus = NULL; virBufferSetChildIndent(&childrenBuf, buf); if (virResctrlAllocForeachCache(resctrl->alloc, @@ -27727,7 +27727,7 @@ virDomainMemorytuneDefFormat(virBufferPtr buf, { g_auto(virBuffer) childrenBuf = VIR_BUFFER_INITIALIZER; int ret = -1; - VIR_AUTOFREE(char *) vcpus = NULL; + g_autofree char *vcpus = NULL; virBufferSetChildIndent(&childrenBuf, buf); if (virResctrlAllocForeachMemory(resctrl->alloc, @@ -27902,7 +27902,7 @@ virDomainCpuDefFormat(virBufferPtr buf, { virDomainVcpuDefPtr vcpu; size_t i; - VIR_AUTOFREE(char *) cpumask = NULL; + g_autofree char *cpumask = NULL; virBufferAddLit(buf, "<vcpu"); virBufferAsprintf(buf, " placement='%s'", @@ -29160,7 +29160,7 @@ virDomainSaveXML(const char *configDir, const char *xml) { char uuidstr[VIR_UUID_STRING_BUFLEN]; - VIR_AUTOFREE(char *) configFile = NULL; + g_autofree char *configFile = NULL; if (!configDir) return 0; @@ -29186,7 +29186,7 @@ virDomainSaveConfig(const char *configDir, virCapsPtr caps, virDomainDefPtr def) { - VIR_AUTOFREE(char *) xml = NULL; + g_autofree char *xml = NULL; if (!(xml = virDomainDefFormat(def, caps, VIR_DOMAIN_DEF_FORMAT_SECURE))) return -1; @@ -29206,7 +29206,7 @@ virDomainSaveStatus(virDomainXMLOptionPtr xmlopt, VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES | VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST); - VIR_AUTOFREE(char *) xml = NULL; + g_autofree char *xml = NULL; if (!(xml = virDomainObjFormat(xmlopt, obj, caps, flags))) return -1; @@ -29220,8 +29220,8 @@ virDomainDeleteConfig(const char *configDir, const char *autostartDir, virDomainObjPtr dom) { - VIR_AUTOFREE(char *) configFile = NULL; - VIR_AUTOFREE(char *) autostartLink = NULL; + g_autofree char *configFile = NULL; + g_autofree char *autostartLink = NULL; if ((configFile = virDomainConfigFile(configDir, dom->def->name)) == NULL) return -1; @@ -29506,7 +29506,7 @@ virDomainDefCopy(virDomainDefPtr src, unsigned int format_flags = VIR_DOMAIN_DEF_FORMAT_SECURE; unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE; - VIR_AUTOFREE(char *) xml = NULL; + g_autofree char *xml = NULL; if (migratable) format_flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_FORMAT_MIGRATABLE; @@ -29983,7 +29983,7 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, int flags = VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_FORMAT_SECURE; int rc = -1; char *netprefix; - VIR_AUTOFREE(char *) xmlStr = NULL; + g_autofree char *xmlStr = NULL; switch ((virDomainDeviceType) src->type) { case VIR_DOMAIN_DEVICE_DISK: @@ -30397,7 +30397,7 @@ virDomainDefGetShortName(const virDomainDef *def) wchar_t wshortname[VIR_DOMAIN_SHORT_NAME_MAX + 1] = {0}; size_t len = 0; char *ret = NULL; - VIR_AUTOFREE(char *) shortname = NULL; + g_autofree char *shortname = NULL; /* No need to do the whole conversion thing when there are no multibyte * characters. The same applies for illegal sequences as they can occur @@ -30939,7 +30939,7 @@ virDomainNetCreatePort(virConnectPtr conn, VIR_AUTOUNREF(virNetworkPtr) net = NULL; VIR_AUTOPTR(virNetworkPortDef) portdef = NULL; VIR_AUTOUNREF(virNetworkPortPtr) port = NULL; - VIR_AUTOFREE(char *) portxml = NULL; + g_autofree char *portxml = NULL; if (!(net = virNetworkLookupByName(conn, iface->data.network.name))) return -1; @@ -31155,7 +31155,7 @@ virDomainNetResolveActualType(virDomainNetDefPtr iface) { virNetworkDefPtr def = NULL; int ret = -1; - VIR_AUTOFREE(char *) xml = NULL; + g_autofree char *xml = NULL; VIR_AUTOUNREF(virConnectPtr) conn = NULL; VIR_AUTOUNREF(virNetworkPtr) net = NULL; @@ -31343,7 +31343,7 @@ virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def) { virStorageVolInfo info; VIR_AUTOPTR(virStoragePoolDef) pooldef = NULL; - VIR_AUTOFREE(char *) poolxml = NULL; + g_autofree char *poolxml = NULL; VIR_AUTOUNREF(virConnectPtr) conn = NULL; VIR_AUTOUNREF(virStoragePoolPtr) pool = NULL; VIR_AUTOUNREF(virStorageVolPtr) vol = NULL; diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c index da61c6917e..cb2aeea172 100644 --- a/src/conf/secret_conf.c +++ b/src/conf/secret_conf.c @@ -133,8 +133,8 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root) { VIR_AUTOPTR(xmlXPathContext) ctxt = NULL; VIR_AUTOPTR(virSecretDef) def = NULL; - VIR_AUTOFREE(char *) prop = NULL; - VIR_AUTOFREE(char *) uuidstr = NULL; + g_autofree char *prop = NULL; + g_autofree char *uuidstr = NULL; if (!virXMLNodeNameEqual(root, "secret")) { virReportError(VIR_ERR_XML_ERROR, diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index a77f521302..184dec5e77 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -437,7 +437,7 @@ virDomainSnapshotDefParseNode(xmlDocPtr xml, } if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE) { - VIR_AUTOFREE(char *) schema = NULL; + g_autofree char *schema = NULL; schema = virFileFindResource("domainsnapshot.rng", abs_top_srcdir "/docs/schemas", diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 2658f80e33..b0bb9d2b8e 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -535,10 +535,10 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, virStoragePoolOptionsPtr options; int n; VIR_AUTOPTR(virStorageAuthDef) authdef = NULL; - VIR_AUTOFREE(char *) port = NULL; - VIR_AUTOFREE(char *) ver = NULL; - VIR_AUTOFREE(xmlNodePtr *) nodeset = NULL; - VIR_AUTOFREE(char *) sourcedir = NULL; + g_autofree char *port = NULL; + g_autofree char *ver = NULL; + g_autofree xmlNodePtr *nodeset = NULL; + g_autofree char *sourcedir = NULL; relnode = ctxt->node; ctxt->node = node; @@ -554,7 +554,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, } if (options->formatFromString) { - VIR_AUTOFREE(char *) format = NULL; + g_autofree char *format = NULL; format = virXPathString("string(./format/@type)", ctxt); if (format == NULL) @@ -607,7 +607,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, goto cleanup; for (i = 0; i < nsource; i++) { - VIR_AUTOFREE(char *) partsep = NULL; + g_autofree char *partsep = NULL; virStoragePoolSourceDevice dev = { .path = NULL }; dev.path = virXMLPropString(nodeset[i], "path"); @@ -731,7 +731,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt, int ret = -1; xmlNodePtr relnode; xmlNodePtr node; - VIR_AUTOFREE(char *) mode = NULL; + g_autofree char *mode = NULL; node = virXPathNode(permxpath, ctxt); if (node == NULL) { @@ -802,8 +802,8 @@ static int virStoragePoolDefRefreshParse(xmlXPathContextPtr ctxt, virStoragePoolDefPtr def) { - VIR_AUTOFREE(virStoragePoolDefRefreshPtr) refresh = NULL; - VIR_AUTOFREE(char *) allocation = NULL; + g_autofree virStoragePoolDefRefreshPtr refresh = NULL; + g_autofree char *allocation = NULL; int tmp; allocation = virXPathString("string(./refresh/volume/@allocation)", ctxt); @@ -850,9 +850,9 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) virStoragePoolDefPtr ret = NULL; xmlNodePtr source_node; VIR_AUTOPTR(virStoragePoolDef) def = NULL; - VIR_AUTOFREE(char *) type = NULL; - VIR_AUTOFREE(char *) uuid = NULL; - VIR_AUTOFREE(char *) target_path = NULL; + g_autofree char *type = NULL; + g_autofree char *uuid = NULL; + g_autofree char *target_path = NULL; if (VIR_ALLOC(def) < 0) return NULL; @@ -1279,12 +1279,12 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool, size_t i; int n; VIR_AUTOPTR(virStorageVolDef) def = NULL; - VIR_AUTOFREE(char *) type = NULL; - VIR_AUTOFREE(char *) allocation = NULL; - VIR_AUTOFREE(char *) capacity = NULL; - VIR_AUTOFREE(char *) unit = NULL; - VIR_AUTOFREE(char *) backingStore = NULL; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree char *type = NULL; + g_autofree char *allocation = NULL; + g_autofree char *capacity = NULL; + g_autofree char *unit = NULL; + g_autofree char *backingStore = NULL; + g_autofree xmlNodePtr *nodes = NULL; virCheckFlags(VIR_VOL_XML_PARSE_NO_CAPACITY | VIR_VOL_XML_PARSE_OPT_CAPACITY, NULL); @@ -1328,7 +1328,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool, backingStore = NULL; if (options->formatFromString) { - VIR_AUTOFREE(char *) format = NULL; + g_autofree char *format = NULL; format = virXPathString("string(./backingStore/format/@type)", ctxt); if (format == NULL) @@ -1375,7 +1375,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool, def->target.path = virXPathString("string(./target/path)", ctxt); if (options->formatFromString) { - VIR_AUTOFREE(char *) format = NULL; + g_autofree char *format = NULL; format = virXPathString("string(./target/format/@type)", ctxt); if (format == NULL) @@ -1708,7 +1708,7 @@ virStoragePoolSaveState(const char *stateFile, virStoragePoolDefPtr def) { virBuffer buf = VIR_BUFFER_INITIALIZER; - VIR_AUTOFREE(char *) xml = NULL; + g_autofree char *xml = NULL; virBufferAddLit(&buf, "<poolstate>\n"); virBufferAdjustIndent(&buf, 2); @@ -1736,7 +1736,7 @@ int virStoragePoolSaveConfig(const char *configFile, virStoragePoolDefPtr def) { - VIR_AUTOFREE(char *) xml = NULL; + g_autofree char *xml = NULL; if (!(xml = virStoragePoolDefFormat(def))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index 966956e719..94e598ddea 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -1640,7 +1640,7 @@ virNetworkObjAddPort(virNetworkObjPtr net, const char *stateDir) { char uuidstr[VIR_UUID_STRING_BUFLEN]; - VIR_AUTOFREE(char *) dir = NULL; + g_autofree char *dir = NULL; virUUIDFormat(portdef->uuid, uuidstr); @@ -1693,7 +1693,7 @@ virNetworkObjDeletePort(virNetworkObjPtr net, const char *stateDir) { char uuidstr[VIR_UUID_STRING_BUFLEN]; - VIR_AUTOFREE(char *) dir = NULL; + g_autofree char *dir = NULL; virNetworkPortDefPtr portdef; virUUIDFormat(uuid, uuidstr); @@ -1722,7 +1722,7 @@ int virNetworkObjDeleteAllPorts(virNetworkObjPtr net, const char *stateDir) { - VIR_AUTOFREE(char *) dir = NULL; + g_autofree char *dir = NULL; DIR *dh = NULL; struct dirent *de; int rc; @@ -1881,7 +1881,7 @@ static int virNetworkObjLoadAllPorts(virNetworkObjPtr net, const char *stateDir) { - VIR_AUTOFREE(char *) dir = NULL; + g_autofree char *dir = NULL; DIR *dh = NULL; struct dirent *de; int ret = -1; diff --git a/src/conf/virnetworkportdef.c b/src/conf/virnetworkportdef.c index 3e43da064e..43140198f8 100644 --- a/src/conf/virnetworkportdef.c +++ b/src/conf/virnetworkportdef.c @@ -76,18 +76,18 @@ static virNetworkPortDefPtr virNetworkPortDefParseXML(xmlXPathContextPtr ctxt) { VIR_AUTOPTR(virNetworkPortDef) def = NULL; - VIR_AUTOFREE(char *) uuid = NULL; + g_autofree char *uuid = NULL; xmlNodePtr virtPortNode; xmlNodePtr vlanNode; xmlNodePtr bandwidthNode; xmlNodePtr addressNode; - VIR_AUTOFREE(char *) trustGuestRxFilters = NULL; - VIR_AUTOFREE(char *) mac = NULL; - VIR_AUTOFREE(char *) macmgr = NULL; - VIR_AUTOFREE(char *) mode = NULL; - VIR_AUTOFREE(char *) plugtype = NULL; - VIR_AUTOFREE(char *) managed = NULL; - VIR_AUTOFREE(char *) driver = NULL; + g_autofree char *trustGuestRxFilters = NULL; + g_autofree char *mac = NULL; + g_autofree char *macmgr = NULL; + g_autofree char *mode = NULL; + g_autofree char *plugtype = NULL; + g_autofree char *managed = NULL; + g_autofree char *driver = NULL; if (VIR_ALLOC(def) < 0) return NULL; diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 70159a6613..7a52ab5d4f 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -1350,7 +1350,7 @@ x86ModelParseAncestor(virCPUx86ModelPtr model, xmlXPathContextPtr ctxt, virCPUx86MapPtr map) { - VIR_AUTOFREE(char *) name = NULL; + g_autofree char *name = NULL; virCPUx86ModelPtr ancestor; int rc; @@ -1385,7 +1385,7 @@ static int x86ModelParseSignatures(virCPUx86ModelPtr model, xmlXPathContextPtr ctxt) { - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; xmlNodePtr root = ctxt->node; size_t i; int n; @@ -1436,7 +1436,7 @@ x86ModelParseVendor(virCPUx86ModelPtr model, xmlXPathContextPtr ctxt, virCPUx86MapPtr map) { - VIR_AUTOFREE(char *) vendor = NULL; + g_autofree char *vendor = NULL; int rc; if ((rc = virXPathBoolean("boolean(./vendor)", ctxt)) <= 0) @@ -1466,7 +1466,7 @@ x86ModelParseFeatures(virCPUx86ModelPtr model, xmlXPathContextPtr ctxt, virCPUx86MapPtr map) { - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; size_t i; int n; @@ -1474,7 +1474,7 @@ x86ModelParseFeatures(virCPUx86ModelPtr model, return n; for (i = 0; i < n; i++) { - VIR_AUTOFREE(char *) ftname = NULL; + g_autofree char *ftname = NULL; virCPUx86FeaturePtr feature; if (!(ftname = virXMLPropString(nodes[i], "name"))) { @@ -2120,7 +2120,7 @@ x86Decode(virCPUDefPtr cpu, virCPUx86Data features = VIR_CPU_X86_DATA_INIT; virCPUx86VendorPtr vendor; virDomainCapsCPUModelPtr hvModel = NULL; - VIR_AUTOFREE(char *) sigs = NULL; + g_autofree char *sigs = NULL; uint32_t signature; ssize_t i; int rc; diff --git a/src/driver.c b/src/driver.c index 4b526a73ae..125cf02890 100644 --- a/src/driver.c +++ b/src/driver.c @@ -86,7 +86,7 @@ int virDriverShouldAutostart(const char *dir, bool *autostart) { - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; *autostart = false; @@ -149,7 +149,7 @@ virGetConnectGeneric(virThreadLocalPtr threadPtr, const char *name) VIR_DEBUG("Return cached %s connection %p", name, conn); virObjectRef(conn); } else { - VIR_AUTOFREE(char *) uri = NULL; + g_autofree char *uri = NULL; const char *uriPath = geteuid() == 0 ? "/system" : "/session"; if (virAsprintf(&uri, "%s://%s", name, uriPath) < 0) diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interface_backend_netcf.c index a45d429973..00b5c00822 100644 --- a/src/interface/interface_backend_netcf.c +++ b/src/interface/interface_backend_netcf.c @@ -105,7 +105,7 @@ netcfStateInitialize(bool privileged, "%s/libvirt/interface", RUNSTATEDIR) < 0) goto error; } else { - VIR_AUTOFREE(char *) rundir = NULL; + g_autofree char *rundir = NULL; if (!(rundir = virGetUserRuntimeDirectory())) goto error; diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c index 1e5bf067fe..dcf22af440 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -1184,7 +1184,7 @@ udevStateInitialize(bool privileged, "%s/libvirt/interface", RUNSTATEDIR) < 0) goto cleanup; } else { - VIR_AUTOFREE(char *) rundir = NULL; + g_autofree char *rundir = NULL; if (!(rundir = virGetUserRuntimeDirectory())) goto cleanup; diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c index 091473e698..adb783395a 100644 --- a/src/libvirt-admin.c +++ b/src/libvirt-admin.c @@ -122,7 +122,7 @@ getSocketPath(virURIPtr uri) } if (!sock_path) { - VIR_AUTOFREE(char *) sockbase = NULL; + g_autofree char *sockbase = NULL; bool legacy = false; if (!uri->scheme) { diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index 9632604807..88d6189eae 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -180,7 +180,7 @@ xenConfigCopyStringOpt(virConfPtr conf, const char *name, char **value) static int xenConfigGetUUID(virConfPtr conf, const char *name, unsigned char *uuid) { - VIR_AUTOFREE(char *) string = NULL; + g_autofree char *string = NULL; int rc; if (!uuid || !name || !conf) { @@ -339,9 +339,9 @@ xenParseTimeOffset(virConfPtr conf, virDomainDefPtr def) static int xenParseEventsActions(virConfPtr conf, virDomainDefPtr def) { - VIR_AUTOFREE(char *) on_poweroff = NULL; - VIR_AUTOFREE(char *) on_reboot = NULL; - VIR_AUTOFREE(char *) on_crash = NULL; + g_autofree char *on_poweroff = NULL; + g_autofree char *on_reboot = NULL; + g_autofree char *on_crash = NULL; if (xenConfigGetString(conf, "on_poweroff", &on_poweroff, "destroy") < 0) return -1; @@ -504,8 +504,8 @@ xenParseCPUFeatures(virConfPtr conf, virDomainXMLOptionPtr xmlopt) { unsigned long count = 0; - VIR_AUTOFREE(char *) cpus = NULL; - VIR_AUTOFREE(char *) tsc_mode = NULL; + g_autofree char *cpus = NULL; + g_autofree char *tsc_mode = NULL; int val = 0; virDomainTimerDefPtr timer; @@ -915,7 +915,7 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr def, const char *nativeFormat) virDomainChrDefPtr chr = NULL; if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { - VIR_AUTOFREE(char *) parallel = NULL; + g_autofree char *parallel = NULL; int rc; if (xenConfigGetString(conf, "parallel", ¶llel, NULL) < 0) @@ -960,7 +960,7 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr def, const char *nativeFormat) goto cleanup; } } else { - VIR_AUTOFREE(char *) serial = NULL; + g_autofree char *serial = NULL; if (xenHandleConfGetValueStringListErrors(rc) < 0) goto cleanup; @@ -1428,7 +1428,7 @@ xenParseSxprSound(virDomainDefPtr def, static int xenParseEmulatedDevices(virConfPtr conf, virDomainDefPtr def) { - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { if (xenConfigGetString(conf, "soundhw", &str, NULL) < 0) @@ -1447,7 +1447,7 @@ static int xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps) { virCapsDomainDataPtr capsdata = NULL; - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; int ret = -1; if (xenConfigCopyString(conf, "name", &def->name) < 0) @@ -2375,7 +2375,7 @@ xenFormatSound(virConfPtr conf, virDomainDefPtr def) { g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; const char * model; - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; size_t i; if (def->os.type != VIR_DOMAIN_OSTYPE_HVM || diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 9e3d307078..65c7a6c2d8 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -64,9 +64,9 @@ extern int xlu_disk_parse(XLU_Config *cfg, static int xenParseCmdline(virConfPtr conf, char **r_cmdline) { char *cmdline = NULL; - VIR_AUTOFREE(char *) root = NULL; - VIR_AUTOFREE(char *) extra = NULL; - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *root = NULL; + g_autofree char *extra = NULL; + g_autofree char *buf = NULL; if (xenConfigGetString(conf, "cmdline", &buf, NULL) < 0) return -1; @@ -105,8 +105,8 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps) size_t i; if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { - VIR_AUTOFREE(char *) bios = NULL; - VIR_AUTOFREE(char *) boot = NULL; + g_autofree char *bios = NULL; + g_autofree char *boot = NULL; int val = 0; if (xenConfigGetString(conf, "bios", &bios, NULL) < 0) @@ -259,7 +259,7 @@ xenTranslateCPUFeature(const char *feature_name, bool from_libxl) static int xenParseXLCPUID(virConfPtr conf, virDomainDefPtr def) { - VIR_AUTOFREE(char *) cpuid_str = NULL; + g_autofree char *cpuid_str = NULL; char **cpuid_pairs = NULL; char **name_and_value = NULL; size_t i; diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c index 0296e78ddc..086e438cbc 100644 --- a/src/libxl/xen_xm.c +++ b/src/libxl/xen_xm.c @@ -41,7 +41,7 @@ xenParseXMOS(virConfPtr conf, virDomainDefPtr def) size_t i; if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { - VIR_AUTOFREE(char *) boot = NULL; + g_autofree char *boot = NULL; if (VIR_ALLOC(def->os.loader) < 0 || xenConfigCopyString(conf, "kernel", &def->os.loader->path) < 0) @@ -69,8 +69,8 @@ xenParseXMOS(virConfPtr conf, virDomainDefPtr def) def->os.nBootDevs++; } } else { - VIR_AUTOFREE(char *) extra = NULL; - VIR_AUTOFREE(char *) root = NULL; + g_autofree char *extra = NULL; + g_autofree char *root = NULL; if (xenConfigCopyStringOpt(conf, "bootloader", &def->os.bootloader) < 0) return -1; @@ -415,7 +415,7 @@ xenFormatXMDisks(virConfPtr conf, virDomainDefPtr def) static int xenParseXMInputDevs(virConfPtr conf, virDomainDefPtr def) { - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { if (xenConfigGetString(conf, "usbdevice", &str, NULL) < 0) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index f9d43a1b3e..7a3d1cc00e 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -211,7 +211,7 @@ lxcSetRootfs(virDomainDefPtr def, virConfPtr properties) { int type = VIR_DOMAIN_FS_TYPE_MOUNT; - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *value = NULL; if (virConfGetValueString(properties, "lxc.rootfs.path", &value) <= 0) { virResetLastError(); @@ -756,7 +756,7 @@ lxcConvertNetworkSettings(virDomainDefPtr def, virConfPtr properties) static int lxcCreateConsoles(virDomainDefPtr def, virConfPtr properties) { - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *value = NULL; int nbttys = 0; virDomainChrDefPtr console; size_t i; @@ -841,7 +841,7 @@ lxcIdmapWalkCallback(const char *name, virConfValuePtr value, void *data) static int lxcSetMemTune(virDomainDefPtr def, virConfPtr properties) { - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *value = NULL; unsigned long long size = 0; if (virConfGetValueString(properties, @@ -877,7 +877,7 @@ lxcSetMemTune(virDomainDefPtr def, virConfPtr properties) static int lxcSetCpuTune(virDomainDefPtr def, virConfPtr properties) { - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *value = NULL; if (virConfGetValueString(properties, "lxc.cgroup.cpu.shares", &value) > 0) { @@ -911,7 +911,7 @@ lxcSetCpuTune(virDomainDefPtr def, virConfPtr properties) static int lxcSetCpusetTune(virDomainDefPtr def, virConfPtr properties) { - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *value = NULL; virBitmapPtr nodeset = NULL; if (virConfGetValueString(properties, "lxc.cgroup.cpuset.cpus", @@ -1033,7 +1033,7 @@ lxcBlkioDeviceWalkCallback(const char *name, virConfValuePtr value, void *data) static int lxcSetBlkioTune(virDomainDefPtr def, virConfPtr properties) { - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *value = NULL; if (virConfGetValueString(properties, "lxc.cgroup.blkio.weight", &value) > 0) { @@ -1053,7 +1053,7 @@ lxcSetBlkioTune(virDomainDefPtr def, virConfPtr properties) static void lxcSetCapDrop(virDomainDefPtr def, virConfPtr properties) { - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *value = NULL; char **toDrop = NULL; const char *capString; size_t i; @@ -1080,7 +1080,7 @@ lxcParseConfigString(const char *config, { virDomainDefPtr vmdef = NULL; VIR_AUTOPTR(virConf) properties = NULL; - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *value = NULL; if (!(properties = virConfReadString(config, VIR_CONF_FLAG_LXC_FORMAT))) return NULL; diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index fe47668d4d..b3b4e8ab2c 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -154,7 +154,7 @@ static int networkDnsmasqDefNamespaceParseOptions(networkDnsmasqXmlNsDefPtr nsdef, xmlXPathContextPtr ctxt) { - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; ssize_t nnodes; size_t i; @@ -676,9 +676,9 @@ firewalld_dbus_filter_bridge(DBusConnection *connection G_GNUC_UNUSED, } else if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) { - VIR_AUTOFREE(char *) name = NULL; - VIR_AUTOFREE(char *) old_owner = NULL; - VIR_AUTOFREE(char *) new_owner = NULL; + g_autofree char *name = NULL; + g_autofree char *old_owner = NULL; + g_autofree char *new_owner = NULL; if (virDBusMessageDecode(message, "sss", &name, &old_owner, &new_owner) < 0) { VIR_WARN("Failed to decode DBus NameOwnerChanged message"); @@ -1470,7 +1470,7 @@ networkDnsmasqConfContents(virNetworkObjPtr obj, } else { /* IPv4 - dnsmasq requires a netmask rather than prefix */ virSocketAddr netmask; - VIR_AUTOFREE(char *) netmaskStr = NULL; + g_autofree char *netmaskStr = NULL; if (virSocketAddrPrefixToNetmask(prefix, &netmask, AF_INET) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c index 32e99bc830..4b5d806fa6 100644 --- a/src/node_device/node_device_hal.c +++ b/src/node_device/node_device_hal.c @@ -622,7 +622,7 @@ nodeStateInitialize(bool privileged G_GNUC_UNUSED, "%s/libvirt/nodedev", RUNSTATEDIR) < 0) goto failure; } else { - VIR_AUTOFREE(char *) rundir = NULL; + g_autofree char *rundir = NULL; if (!(rundir = virGetUserRuntimeDirectory())) goto failure; diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 75cf576c3c..f6729308d7 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1833,7 +1833,7 @@ nodeStateInitialize(bool privileged, "%s/libvirt/nodedev", RUNSTATEDIR) < 0) goto cleanup; } else { - VIR_AUTOFREE(char *) rundir = NULL; + g_autofree char *rundir = NULL; if (!(rundir = virGetUserRuntimeDirectory())) goto cleanup; diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 599ca629e0..17e2ccc98f 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -279,7 +279,7 @@ qemuBlockDiskDetectNodes(virDomainDiskDefPtr disk, { qemuBlockNodeNameBackingChainDataPtr entry = NULL; virStorageSourcePtr src = disk->src; - VIR_AUTOFREE(char *) alias = NULL; + g_autofree char *alias = NULL; int ret = -1; /* don't attempt the detection if the top level already has node names */ @@ -473,7 +473,7 @@ qemuBlockStorageSourceBuildJSONSocketAddress(virStorageNetHostDefPtr host, VIR_AUTOPTR(virJSONValue) server = NULL; const char *transport; const char *field; - VIR_AUTOFREE(char *) port = NULL; + g_autofree char *port = NULL; switch ((virStorageNetHostTransport) host->transport) { case VIR_STORAGE_NET_HOST_TRANS_TCP: @@ -567,7 +567,7 @@ static virJSONValuePtr qemuBlockStorageSourceBuildJSONInetSocketAddress(virStorageNetHostDefPtr host) { virJSONValuePtr ret = NULL; - VIR_AUTOFREE(char *) port = NULL; + g_autofree char *port = NULL; if (host->transport != VIR_STORAGE_NET_HOST_TRANS_TCP) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -697,7 +697,7 @@ qemuBlockStorageSourceGetCURLProps(virStorageSourcePtr src, const char *username = NULL; virJSONValuePtr ret = NULL; VIR_AUTOPTR(virURI) uri = NULL; - VIR_AUTOFREE(char *) uristr = NULL; + g_autofree char *uristr = NULL; /** * Common options: @@ -738,11 +738,11 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr src, bool onlytarget) { qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src); - VIR_AUTOFREE(char *) target = NULL; + g_autofree char *target = NULL; char *lunStr = NULL; char *username = NULL; char *objalias = NULL; - VIR_AUTOFREE(char *) portal = NULL; + g_autofree char *portal = NULL; unsigned int lun = 0; virJSONValuePtr ret = NULL; @@ -1870,8 +1870,8 @@ qemuBlockSnapshotAddLegacy(virJSONValuePtr actions, bool reuse) { const char *format = virStorageFileFormatTypeToString(newsrc->format); - VIR_AUTOFREE(char *) device = NULL; - VIR_AUTOFREE(char *) source = NULL; + g_autofree char *device = NULL; + g_autofree char *source = NULL; if (!(device = qemuAliasDiskDriveFromDisk(disk))) return -1; @@ -1930,7 +1930,7 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr src) int actualType = virStorageSourceGetActualType(src); VIR_AUTOPTR(virJSONValue) backingProps = NULL; VIR_AUTOPTR(virURI) uri = NULL; - VIR_AUTOFREE(char *) backingJSON = NULL; + g_autofree char *backingJSON = NULL; char *ret = NULL; if (virStorageSourceIsLocalStorage(src)) { @@ -1989,7 +1989,7 @@ qemuBlockStorageSourceCreateAddBacking(virStorageSourcePtr backing, virJSONValuePtr props, bool format) { - VIR_AUTOFREE(char *) backingFileStr = NULL; + g_autofree char *backingFileStr = NULL; const char *backingFormatStr = NULL; if (!virStorageSourceIsBacking(backing)) @@ -2046,7 +2046,7 @@ qemuBlockStorageSourceCreateGetEncryptionLUKS(virStorageSourcePtr src, { qemuDomainStorageSourcePrivatePtr srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src); VIR_AUTOPTR(virJSONValue) props = NULL; - VIR_AUTOFREE(char *) cipheralg = NULL; + g_autofree char *cipheralg = NULL; const char *keysecret = NULL; if (srcpriv && diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 89c28986b0..3d52cfe0ef 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -225,7 +225,7 @@ qemuBlockJobDiskNewPull(virDomainObjPtr vm, { qemuDomainObjPrivatePtr priv = vm->privateData; VIR_AUTOUNREF(qemuBlockJobDataPtr) job = NULL; - VIR_AUTOFREE(char *) jobname = NULL; + g_autofree char *jobname = NULL; if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) { if (virAsprintf(&jobname, "pull-%s-%s", disk->dst, disk->src->nodeformat) < 0) @@ -256,7 +256,7 @@ qemuBlockJobDiskNewCommit(virDomainObjPtr vm, { qemuDomainObjPrivatePtr priv = vm->privateData; VIR_AUTOUNREF(qemuBlockJobDataPtr) job = NULL; - VIR_AUTOFREE(char *) jobname = NULL; + g_autofree char *jobname = NULL; qemuBlockJobType jobtype = QEMU_BLOCKJOB_TYPE_COMMIT; if (topparent == NULL) @@ -291,7 +291,7 @@ qemuBlockJobNewCreate(virDomainObjPtr vm, bool storage) { VIR_AUTOUNREF(qemuBlockJobDataPtr) job = NULL; - VIR_AUTOFREE(char *) jobname = NULL; + g_autofree char *jobname = NULL; const char *nodename = src->nodeformat; if (storage) @@ -324,7 +324,7 @@ qemuBlockJobDiskNewCopy(virDomainObjPtr vm, { qemuDomainObjPrivatePtr priv = vm->privateData; VIR_AUTOUNREF(qemuBlockJobDataPtr) job = NULL; - VIR_AUTOFREE(char *) jobname = NULL; + g_autofree char *jobname = NULL; if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) { if (virAsprintf(&jobname, "copy-%s-%s", disk->dst, disk->src->nodeformat) < 0) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index efd71d69c5..00ac2aed0e 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2415,7 +2415,7 @@ virQEMUCapsProbeQMPMachineProps(virQEMUCapsPtr qemuCaps, for (i = 0; i < G_N_ELEMENTS(virQEMUCapsMachineProps); i++) { virQEMUCapsObjectTypeProps props = virQEMUCapsMachineProps[i]; const char *canon = virQEMUCapsGetCanonicalMachine(qemuCaps, props.type); - VIR_AUTOFREE(char *) type = NULL; + g_autofree char *type = NULL; if (!virQEMUCapsIsMachineSupported(qemuCaps, canon)) continue; @@ -4151,7 +4151,7 @@ virQEMUCapsKVMSupportsNesting(void) { static char const * const kmod[] = {"kvm_intel", "kvm_amd", "kvm_hv", "kvm"}; - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *value = NULL; int rc; size_t i; @@ -4541,7 +4541,7 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, qemuMonitorPtr mon) { int major, minor, micro; - VIR_AUTOFREE(char *) package = NULL; + g_autofree char *package = NULL; /* @mon is supposed to be locked by callee */ diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index 0c4385083b..5f2372779a 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -84,9 +84,9 @@ qemuCheckpointWriteMetadata(virDomainObjPtr vm, { unsigned int flags = VIR_DOMAIN_CHECKPOINT_FORMAT_SECURE; virDomainCheckpointDefPtr def = virDomainCheckpointObjGetDef(checkpoint); - VIR_AUTOFREE(char *) newxml = NULL; - VIR_AUTOFREE(char *) chkDir = NULL; - VIR_AUTOFREE(char *) chkFile = NULL; + g_autofree char *newxml = NULL; + g_autofree char *chkDir = NULL; + g_autofree char *chkFile = NULL; newxml = virDomainCheckpointDefFormat(def, caps, xmlopt, flags); if (newxml == NULL) @@ -119,7 +119,7 @@ qemuCheckpointDiscard(virQEMUDriverPtr driver, virDomainCheckpointDefPtr parentdef = NULL; size_t i, j; VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver); - VIR_AUTOFREE(char *) chkFile = NULL; + g_autofree char *chkFile = NULL; if (!metadata_only && !virDomainObjIsActive(vm)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f4563eac37..130476b9e5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -207,8 +207,8 @@ static int qemuBuildMasterKeyCommandLine(virCommandPtr cmd, qemuDomainObjPrivatePtr priv) { - VIR_AUTOFREE(char *) alias = NULL; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *alias = NULL; + g_autofree char *path = NULL; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; /* If the -object secret does not exist, then just return. This just @@ -299,7 +299,7 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, virDomainDeviceInfoPtr info, virQEMUCapsPtr qemuCaps) { - VIR_AUTOFREE(char *) devStr = NULL; + g_autofree char *devStr = NULL; const char *contAlias = NULL; bool contIsPHB = false; int contTargetIndex = 0; @@ -698,7 +698,7 @@ qemuBuildSecretInfoProps(qemuDomainSecretInfoPtr secinfo, virJSONValuePtr *propsret) { int ret = -1; - VIR_AUTOFREE(char *) keyid = NULL; + g_autofree char *keyid = NULL; if (!(keyid = qemuDomainGetMasterKeyAlias())) return -1; @@ -1483,7 +1483,7 @@ bool qemuCheckFips(void) { if (virFileExists("/proc/sys/crypto/fips_enabled")) { - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *buf = NULL; if (virFileReadAll("/proc/sys/crypto/fips_enabled", 10, &buf) < 0) return false; @@ -1574,7 +1574,7 @@ static int qemuBuildDriveSourcePR(virBufferPtr buf, virDomainDiskDefPtr disk) { - VIR_AUTOFREE(char *) alias = NULL; + g_autofree char *alias = NULL; const char *defaultAlias = NULL; if (!disk->src->pr) @@ -1601,7 +1601,7 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, qemuDomainSecretInfoPtr secinfo = NULL; qemuDomainSecretInfoPtr encinfo = NULL; VIR_AUTOPTR(virJSONValue) srcprops = NULL; - VIR_AUTOFREE(char *) source = NULL; + g_autofree char *source = NULL; bool rawluks = false; if (srcpriv) { @@ -1794,7 +1794,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, goto error; if (!qemuDiskBusNeedsDriveArg(disk->bus)) { - VIR_AUTOFREE(char *) drivealias = qemuAliasDiskDriveFromDisk(disk); + g_autofree char *drivealias = qemuAliasDiskDriveFromDisk(disk); if (!drivealias) goto error; @@ -1954,8 +1954,8 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER; const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus); const char *contAlias; - VIR_AUTOFREE(char *) backendAlias = NULL; - VIR_AUTOFREE(char *) scsiVPDDeviceId = NULL; + g_autofree char *backendAlias = NULL; + g_autofree char *scsiVPDDeviceId = NULL; int controllerModel; if (qemuCheckDiskConfig(disk, qemuCaps) < 0) @@ -2312,7 +2312,7 @@ static int qemuCommandAddZPCIDevice(virCommandPtr cmd, virDomainDeviceInfoPtr dev) { - VIR_AUTOFREE(char *) devstr = NULL; + g_autofree char *devstr = NULL; virCommandAddArg(cmd, "-device"); @@ -2355,9 +2355,9 @@ qemuBuildFloppyCommandLineControllerOptions(virCommandPtr cmd, virBufferAddLit(&fdc_opts, "isa-fdc,"); for (i = 0; i < def->ndisks; i++) { - VIR_AUTOFREE(char *) backendAlias = NULL; - VIR_AUTOFREE(char *) backendStr = NULL; - VIR_AUTOFREE(char *) bootindexStr = NULL; + g_autofree char *backendAlias = NULL; + g_autofree char *backendStr = NULL; + g_autofree char *bootindexStr = NULL; virDomainDiskDefPtr disk = def->disks[i]; if (disk->bus != VIR_DOMAIN_DISK_BUS_FDC) @@ -2479,7 +2479,7 @@ qemuBuildDiskSourceCommandLine(virCommandPtr cmd, { VIR_AUTOPTR(qemuBlockStorageSourceChainData) data = NULL; VIR_AUTOPTR(virJSONValue) copyOnReadProps = NULL; - VIR_AUTOFREE(char *) copyOnReadPropsStr = NULL; + g_autofree char *copyOnReadPropsStr = NULL; size_t i; if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) { @@ -2522,7 +2522,7 @@ qemuBuildDiskCommandLine(virCommandPtr cmd, virQEMUCapsPtr qemuCaps, unsigned int bootindex) { - VIR_AUTOFREE(char *) optstr = NULL; + g_autofree char *optstr = NULL; if (qemuBuildDiskSourceCommandLine(cmd, disk, qemuCaps) < 0) return -1; @@ -2688,8 +2688,8 @@ qemuBuildFSDevCommandLine(virCommandPtr cmd, const virDomainDef *def, virQEMUCapsPtr qemuCaps) { - VIR_AUTOFREE(char *) fsdevstr = NULL; - VIR_AUTOFREE(char *) devicestr = NULL; + g_autofree char *fsdevstr = NULL; + g_autofree char *devicestr = NULL; virCommandAddArg(cmd, "-fsdev"); if (!(fsdevstr = qemuBuildFSStr(fs))) @@ -3152,7 +3152,7 @@ qemuBuildControllersByTypeCommandLine(virCommandPtr cmd, for (i = 0; i < def->ncontrollers; i++) { virDomainControllerDefPtr cont = def->controllers[i]; - VIR_AUTOFREE(char *) devstr = NULL; + g_autofree char *devstr = NULL; if (cont->type != type) continue; @@ -3326,7 +3326,7 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps, const long system_page_size = virGetSystemPageSizeKB(); virDomainMemoryAccess memAccess = mem->access; size_t i; - VIR_AUTOFREE(char *) memPath = NULL; + g_autofree char *memPath = NULL; bool prealloc = false; virBitmapPtr nodemask = NULL; int rc; @@ -3585,7 +3585,7 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def, virBufferPtr buf) { VIR_AUTOPTR(virJSONValue) props = NULL; - VIR_AUTOFREE(char *) alias = NULL; + g_autofree char *alias = NULL; int rc; virDomainMemoryDef mem = { 0 }; unsigned long long memsize = virDomainNumaGetNodeMemorySize(def->numa, @@ -3617,7 +3617,7 @@ qemuBuildMemoryDimmBackendStr(virBufferPtr buf, qemuDomainObjPrivatePtr priv) { VIR_AUTOPTR(virJSONValue) props = NULL; - VIR_AUTOFREE(char *) alias = NULL; + g_autofree char *alias = NULL; if (!mem->info.alias) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -3974,7 +3974,7 @@ qemuBuildHostNetStr(virDomainNetDefPtr net, virBufferAddLit(&buf, "user,"); for (i = 0; i < net->guestIP.nips; i++) { const virNetDevIPAddr *ip = net->guestIP.ips[i]; - VIR_AUTOFREE(char *) addr = NULL; + g_autofree char *addr = NULL; const char *prefix = ""; if (!(addr = virSocketAddrFormat(&ip->address))) @@ -4072,7 +4072,7 @@ qemuBuildWatchdogCommandLine(virCommandPtr cmd, virQEMUCapsPtr qemuCaps) { virDomainWatchdogDefPtr watchdog = def->watchdog; - VIR_AUTOFREE(char *) optstr = NULL; + g_autofree char *optstr = NULL; const char *action; int actualAction; @@ -4184,7 +4184,7 @@ qemuBuildNVRAMCommandLine(virCommandPtr cmd, return -1; } - VIR_AUTOFREE(char *) optstr = NULL; + g_autofree char *optstr = NULL; virCommandAddArg(cmd, "-global"); optstr = qemuBuildNVRAMDevStr(def->nvram); if (!optstr) @@ -4322,7 +4322,7 @@ qemuBuildInputCommandLine(virCommandPtr cmd, for (i = 0; i < def->ninputs; i++) { virDomainInputDefPtr input = def->inputs[i]; - VIR_AUTOFREE(char *) devstr = NULL; + g_autofree char *devstr = NULL; if (qemuCommandAddExtDevice(cmd, &input->info) < 0) return -1; @@ -4450,7 +4450,7 @@ qemuBuildSoundCommandLine(virCommandPtr cmd, for (i = 0; i < def->nsounds; i++) { virDomainSoundDefPtr sound = def->sounds[i]; - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; /* Sadly pcspk device doesn't use -device syntax. Fortunately * we don't need to set any PCI address on it, so we don't @@ -4470,7 +4470,7 @@ qemuBuildSoundCommandLine(virCommandPtr cmd, sound->model == VIR_DOMAIN_SOUND_MODEL_ICH9) { for (j = 0; j < sound->ncodecs; j++) { - VIR_AUTOFREE(char *) codecstr = NULL; + g_autofree char *codecstr = NULL; virCommandAddArg(cmd, "-device"); if (!(codecstr = qemuBuildSoundCodecStr(sound, sound->codecs[j], @@ -4481,7 +4481,7 @@ qemuBuildSoundCommandLine(virCommandPtr cmd, virCommandAddArg(cmd, codecstr); } if (j == 0) { - VIR_AUTOFREE(char *) codecstr = NULL; + g_autofree char *codecstr = NULL; virDomainSoundCodecDef codec = { VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX, 0 @@ -4724,7 +4724,7 @@ qemuBuildVideoCommandLine(virCommandPtr cmd, size_t i; for (i = 0; i < def->nvideos; i++) { - VIR_AUTOFREE(char *) chardev = NULL; + g_autofree char *chardev = NULL; virDomainVideoDefPtr video = def->videos[i]; if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) { @@ -4738,7 +4738,7 @@ qemuBuildVideoCommandLine(virCommandPtr cmd, } for (i = 0; i < def->nvideos; i++) { - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; virDomainVideoDefPtr video = def->videos[i]; if (video->type == VIR_DOMAIN_VIDEO_TYPE_NONE) @@ -4902,7 +4902,7 @@ qemuBuildHubCommandLine(virCommandPtr cmd, for (i = 0; i < def->nhubs; i++) { virDomainHubDefPtr hub = def->hubs[i]; - VIR_AUTOFREE(char *) optstr = NULL; + g_autofree char *optstr = NULL; virCommandAddArg(cmd, "-device"); if (!(optstr = qemuBuildHubDevStr(def, hub, qemuCaps))) @@ -4932,7 +4932,7 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, virQEMUCapsPtr qemuCaps) { g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - VIR_AUTOFREE(char *) netsource = NULL; + g_autofree char *netsource = NULL; VIR_AUTOPTR(virJSONValue) srcprops = NULL; virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi; virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi; @@ -5000,8 +5000,8 @@ qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, virQEMUCapsPtr qemuCaps) { g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - VIR_AUTOFREE(char *) source = NULL; - VIR_AUTOFREE(char *) drivealias = NULL; + g_autofree char *source = NULL; + g_autofree char *drivealias = NULL; virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi; if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) { @@ -5033,7 +5033,7 @@ qemuBuildSCSIHostdevDevStr(const virDomainDef *def, { g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; int model = -1; - VIR_AUTOFREE(char *) driveAlias = NULL; + g_autofree char *driveAlias = NULL; const char *contAlias; model = qemuDomainFindSCSIControllerModel(def, dev->info); @@ -5097,8 +5097,8 @@ qemuBuildChrChardevFileStr(virLogManagerPtr logManager, const char *appendarg, int appendval) { if (logManager) { - VIR_AUTOFREE(char *) fdset = NULL; - VIR_AUTOFREE(char *) fdpath = NULL; + g_autofree char *fdset = NULL; + g_autofree char *fdpath = NULL; int flags = 0; int logfd; @@ -5230,7 +5230,7 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, qemuDomainChrSourcePrivatePtr chrSourcePriv = QEMU_DOMAIN_CHR_SOURCE_PRIVATE(dev); g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; bool telnet; - VIR_AUTOFREE(char *) charAlias = NULL; + g_autofree char *charAlias = NULL; if (!(charAlias = qemuAliasChardevFromDevAlias(alias))) return NULL; @@ -5320,7 +5320,7 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, qemuBuildChrChardevReconnectStr(&buf, &dev->data.tcp.reconnect); if (dev->data.tcp.haveTLS == VIR_TRISTATE_BOOL_YES) { - VIR_AUTOFREE(char *) objalias = NULL; + g_autofree char *objalias = NULL; const char *tlsCertEncSecAlias = NULL; /* Add the secret object first if necessary. The @@ -5424,7 +5424,7 @@ qemuBuildHostdevMediatedDevStr(const virDomainDef *def, { g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; virDomainHostdevSubsysMediatedDevPtr mdevsrc = &dev->source.subsys.u.mdev; - VIR_AUTOFREE(char *) mdevPath = NULL; + g_autofree char *mdevPath = NULL; const char *dev_str = NULL; if (!(mdevPath = virMediatedDeviceGetSysfsPath(mdevsrc->uuidstr))) @@ -5465,7 +5465,7 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd, for (i = 0; i < def->nhostdevs; i++) { virDomainHostdevDefPtr hostdev = def->hostdevs[i]; virDomainHostdevSubsysPtr subsys = &hostdev->source.subsys; - VIR_AUTOFREE(char *) devstr = NULL; + g_autofree char *devstr = NULL; /* USB */ if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && @@ -5516,7 +5516,7 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd, if (virHostdevIsSCSIDevice(hostdev)) { virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi; - VIR_AUTOFREE(char *) drvstr = NULL; + g_autofree char *drvstr = NULL; if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) { virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = @@ -5546,7 +5546,7 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd, subsys->type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST) { if (hostdev->source.subsys.u.scsi_host.protocol == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_VHOST) { - VIR_AUTOFREE(char *) vhostfdName = NULL; + g_autofree char *vhostfdName = NULL; int vhostfd = -1; if (virSCSIVHostOpenVhostSCSI(&vhostfd) < 0) @@ -5628,7 +5628,7 @@ qemuBuildMonitorCommandLine(virLogManagerPtr logManager, virDomainDefPtr def, qemuDomainObjPrivatePtr priv) { - VIR_AUTOFREE(char *) chrdev = NULL; + g_autofree char *chrdev = NULL; unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT | QEMU_BUILD_CHARDEV_UNIX_FD_PASS; if (priv->chardevStdioLogd) @@ -5786,8 +5786,8 @@ qemuBuildRNGBackendProps(virDomainRNGDefPtr rng, virQEMUCapsPtr qemuCaps, virJSONValuePtr *props) { - VIR_AUTOFREE(char *) objAlias = NULL; - VIR_AUTOFREE(char *) charBackendAlias = NULL; + g_autofree char *objAlias = NULL; + g_autofree char *charBackendAlias = NULL; if (virAsprintf(&objAlias, "obj%s", rng->info.alias) < 0) return -1; @@ -5890,8 +5890,8 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager, VIR_AUTOPTR(virJSONValue) props = NULL; virBuffer buf = VIR_BUFFER_INITIALIZER; virDomainRNGDefPtr rng = def->rngs[i]; - VIR_AUTOFREE(char *) chardev = NULL; - VIR_AUTOFREE(char *) devstr = NULL; + g_autofree char *chardev = NULL; + g_autofree char *devstr = NULL; int rc; if (!rng->info.alias) { @@ -6387,7 +6387,7 @@ qemuBuildClockCommandLine(virCommandPtr cmd, virQEMUCapsPtr qemuCaps) { size_t i; - VIR_AUTOFREE(char *) rtcopt = NULL; + g_autofree char *rtcopt = NULL; virCommandAddArg(cmd, "-rtc"); if (!(rtcopt = qemuBuildClockArgStr(&def->clock))) @@ -6548,7 +6548,7 @@ qemuBuildBootCommandLine(virCommandPtr cmd, virQEMUCapsPtr qemuCaps) { g_auto(virBuffer) boot_buf = VIR_BUFFER_INITIALIZER; - VIR_AUTOFREE(char *) boot_opts_str = NULL; + g_autofree char *boot_opts_str = NULL; if (def->os.bootmenu) { if (def->os.bootmenu == VIR_TRISTATE_BOOL_YES) @@ -6839,8 +6839,8 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, virQEMUCapsPtr qemuCaps) { virArch hostarch = virArchFromHost(); - VIR_AUTOFREE(char *) cpu = NULL; - VIR_AUTOFREE(char *) cpu_flags = NULL; + g_autofree char *cpu = NULL; + g_autofree char *cpu_flags = NULL; g_auto(virBuffer) cpu_buf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; size_t i; @@ -7516,7 +7516,7 @@ qemuBuildMemPathStr(virQEMUDriverConfigPtr cfg, qemuDomainObjPrivatePtr priv) { const long system_page_size = virGetSystemPageSizeKB(); - VIR_AUTOFREE(char *) mem_path = NULL; + g_autofree char *mem_path = NULL; /* There are two cases where we want to put -mem-path onto * the command line: First one is when there are no guest @@ -8386,16 +8386,16 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, { virDomainDefPtr def = vm->def; int ret = -1; - VIR_AUTOFREE(char *) nic = NULL; - VIR_AUTOFREE(char *) host = NULL; - VIR_AUTOFREE(char *) chardev = NULL; + g_autofree char *nic = NULL; + g_autofree char *host = NULL; + g_autofree char *chardev = NULL; int *tapfd = NULL; size_t tapfdSize = 0; int *vhostfd = NULL; size_t vhostfdSize = 0; char **tapfdName = NULL; char **vhostfdName = NULL; - VIR_AUTOFREE(char *) slirpfdName = NULL; + g_autofree char *slirpfdName = NULL; virDomainNetType actualType = virDomainNetGetActualType(net); virNetDevBandwidthPtr actualBandwidth; bool requireNicdev = false; @@ -8776,7 +8776,7 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager, { size_t i; virDomainSmartcardDefPtr smartcard; - VIR_AUTOFREE(char *) devstr = NULL; + g_autofree char *devstr = NULL; g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER; const char *database; const char *contAlias = NULL; @@ -8970,8 +8970,8 @@ qemuBuildShmemDevStr(virDomainDefPtr def, virJSONValuePtr qemuBuildShmemBackendMemProps(virDomainShmemDefPtr shmem) { - VIR_AUTOFREE(char *) mem_alias = NULL; - VIR_AUTOFREE(char *) mem_path = NULL; + g_autofree char *mem_alias = NULL; + g_autofree char *mem_path = NULL; virJSONValuePtr ret = NULL; if (virAsprintf(&mem_path, "/dev/shm/%s", shmem->name) < 0) @@ -9002,8 +9002,8 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager, { VIR_AUTOPTR(virJSONValue) memProps = NULL; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - VIR_AUTOFREE(char *) devstr = NULL; - VIR_AUTOFREE(char *) chardev = NULL; + g_autofree char *devstr = NULL; + g_autofree char *chardev = NULL; int rc; unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT | QEMU_BUILD_CHARDEV_UNIX_FD_PASS; @@ -9120,7 +9120,7 @@ qemuBuildChrDeviceCommandLine(virCommandPtr cmd, virDomainChrDefPtr chr, virQEMUCapsPtr qemuCaps) { - VIR_AUTOFREE(char *) devstr = NULL; + g_autofree char *devstr = NULL; if (qemuBuildChrDeviceStr(&devstr, def, chr, qemuCaps) < 0) return -1; @@ -9193,7 +9193,7 @@ qemuBuildSerialCommandLine(virLogManagerPtr logManager, for (i = 0; i < def->nserials; i++) { virDomainChrDefPtr serial = def->serials[i]; - VIR_AUTOFREE(char *) devstr = NULL; + g_autofree char *devstr = NULL; if (serial->source->type == VIR_DOMAIN_CHR_TYPE_SPICEPORT && !havespice) continue; @@ -9249,7 +9249,7 @@ qemuBuildParallelsCommandLine(virLogManagerPtr logManager, for (i = 0; i < def->nparallels; i++) { virDomainChrDefPtr parallel = def->parallels[i]; - VIR_AUTOFREE(char *) devstr = NULL; + g_autofree char *devstr = NULL; if (!(devstr = qemuBuildChrChardevStr(logManager, secManager, cmd, cfg, def, @@ -9671,9 +9671,9 @@ qemuBuildTPMBackendStr(const virDomainDef *def, { const virDomainTPMDef *tpm = def->tpm; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - VIR_AUTOFREE(char *) cancel_path = NULL; - VIR_AUTOFREE(char *) devset = NULL; - VIR_AUTOFREE(char *) cancelset = NULL; + g_autofree char *cancel_path = NULL; + g_autofree char *devset = NULL; + g_autofree char *cancelset = NULL; const char *tpmdev; *tpmfd = -1; @@ -9730,7 +9730,7 @@ qemuBuildTPMCommandLine(virCommandPtr cmd, virQEMUCapsPtr qemuCaps) { char *optstr; - VIR_AUTOFREE(char *) chardev = NULL; + g_autofree char *chardev = NULL; int tpmfd = -1; int cancelfd = -1; char *fdset; @@ -9962,7 +9962,7 @@ qemuBuildPRManagerInfoPropsInternal(const char *alias, virJSONValuePtr qemuBuildPRManagedManagerInfoProps(qemuDomainObjPrivatePtr priv) { - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; if (!(path = qemuDomainGetManagedPRSocketPath(priv))) return NULL; @@ -10028,7 +10028,7 @@ virJSONValuePtr qemuBuildDBusVMStateInfoProps(const char *id, const char *addr) { - VIR_AUTOFREE(char *) alias = qemuAliasDBusVMStateFromId(id); + g_autofree char *alias = qemuAliasDBusVMStateFromId(id); if (!alias) return NULL; @@ -10240,7 +10240,7 @@ qemuBuildVsockCommandLine(virCommandPtr cmd, virQEMUCapsPtr qemuCaps) { qemuDomainVsockPrivatePtr priv = (qemuDomainVsockPrivatePtr)vsock->privateData; - VIR_AUTOFREE(char *) devstr = NULL; + g_autofree char *devstr = NULL; if (!(devstr = qemuBuildVsockDevStr(def, vsock, qemuCaps, ""))) return -1; @@ -10612,7 +10612,7 @@ qemuBuildChannelChrDeviceStr(char **deviceStr, virDomainChrDefPtr chr) { int ret = -1; - VIR_AUTOFREE(char *) addr = NULL; + g_autofree char *addr = NULL; int port; switch ((virDomainChrChannelTargetType)chr->targetType) { diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 08cd784054..de03069036 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -181,8 +181,8 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged) virGetGroupID("tss", &cfg->swtpm_group) < 0) cfg->swtpm_group = 0; /* fall back to root */ } else { - VIR_AUTOFREE(char *) rundir = NULL; - VIR_AUTOFREE(char *) cachedir = NULL; + g_autofree char *rundir = NULL; + g_autofree char *cachedir = NULL; cachedir = virGetUserCacheDirectory(); if (!cachedir) @@ -618,8 +618,8 @@ virQEMUDriverConfigLoadProcessEntry(virQEMUDriverConfigPtr cfg, virConfPtr conf) { VIR_AUTOSTRINGLIST hugetlbfs = NULL; - VIR_AUTOFREE(char *) stdioHandler = NULL; - VIR_AUTOFREE(char *) corestr = NULL; + g_autofree char *stdioHandler = NULL; + g_autofree char *corestr = NULL; size_t i; if (virConfGetValueStringList(conf, "hugetlbfs_mount", true, @@ -848,8 +848,8 @@ virQEMUDriverConfigLoadSecurityEntry(virQEMUDriverConfigPtr cfg, { VIR_AUTOSTRINGLIST controllers = NULL; VIR_AUTOSTRINGLIST namespaces = NULL; - VIR_AUTOFREE(char *) user = NULL; - VIR_AUTOFREE(char *) group = NULL; + g_autofree char *user = NULL; + g_autofree char *group = NULL; size_t i, j; if (virConfGetValueStringList(conf, "security_driver", true, &cfg->securityDriverNames) < 0) @@ -967,8 +967,8 @@ static int virQEMUDriverConfigLoadSWTPMEntry(virQEMUDriverConfigPtr cfg, virConfPtr conf) { - VIR_AUTOFREE(char *) swtpm_user = NULL; - VIR_AUTOFREE(char *) swtpm_group = NULL; + g_autofree char *swtpm_user = NULL; + g_autofree char *swtpm_group = NULL; if (virConfGetValueString(conf, "swtpm_user", &swtpm_user) < 0) return -1; @@ -1244,7 +1244,7 @@ virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDriverPtr driver) { size_t i, j; VIR_AUTOUNREF(virCapsPtr) caps = NULL; - VIR_AUTOFREE(virSecurityManagerPtr) *sec_managers = NULL; + g_autofree virSecurityManagerPtr *sec_managers = NULL; /* Security driver data */ const char *doi, *model, *lbl, *type; const int virtTypes[] = {VIR_DOMAIN_VIRT_KVM, @@ -1457,8 +1457,8 @@ qemuCheckUnprivSGIO(virHashTablePtr sharedDevices, const char *device_path, int sgio) { - VIR_AUTOFREE(char *) sysfs_path = NULL; - VIR_AUTOFREE(char *) key = NULL; + g_autofree char *sysfs_path = NULL; + g_autofree char *key = NULL; int val; if (!(sysfs_path = virGetUnprivSGIOSysfsPath(device_path, NULL))) @@ -1637,7 +1637,7 @@ qemuSharedDiskAddRemoveInternal(virQEMUDriverPtr driver, const char *name, bool addDisk) { - VIR_AUTOFREE(char *) key = NULL; + g_autofree char *key = NULL; int ret = -1; if (virStorageSourceIsEmpty(disk->src) || @@ -1701,7 +1701,7 @@ qemuGetHostdevPath(virDomainHostdevDefPtr hostdev) { virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi; virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host; - VIR_AUTOFREE(char *) dev_name = NULL; + g_autofree char *dev_name = NULL; char *dev_path = NULL; if (!(dev_name = virSCSIDeviceGetDevName(NULL, @@ -1722,8 +1722,8 @@ qemuSharedHostdevAddRemoveInternal(virQEMUDriverPtr driver, const char *name, bool addDevice) { - VIR_AUTOFREE(char *) dev_path = NULL; - VIR_AUTOFREE(char *) key = NULL; + g_autofree char *dev_path = NULL; + g_autofree char *key = NULL; int ret = -1; if (!qemuIsSharedHostdev(hostdev)) @@ -1816,7 +1816,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) { virDomainDiskDefPtr disk = NULL; virDomainHostdevDefPtr hostdev = NULL; - VIR_AUTOFREE(char *) sysfs_path = NULL; + g_autofree char *sysfs_path = NULL; const char *path = NULL; int val = -1; @@ -1899,8 +1899,8 @@ char * qemuGetDomainHugepagePath(const virDomainDef *def, virHugeTLBFSPtr hugepage) { - VIR_AUTOFREE(char *) base = qemuGetBaseHugepagePath(hugepage); - VIR_AUTOFREE(char *) domPath = virDomainDefGetShortName(def); + g_autofree char *base = qemuGetBaseHugepagePath(hugepage); + g_autofree char *domPath = virDomainDefGetShortName(def); char *ret = NULL; if (base && domPath) @@ -1965,8 +1965,8 @@ qemuGetMemoryBackingDomainPath(const virDomainDef *def, virQEMUDriverConfigPtr cfg, char **path) { - VIR_AUTOFREE(char *) shortName = NULL; - VIR_AUTOFREE(char *) base = NULL; + g_autofree char *shortName = NULL; + g_autofree char *base = NULL; if (!(shortName = virDomainDefGetShortName(def)) || qemuGetMemoryBackingBasePath(cfg, &base) < 0 || @@ -1995,7 +1995,7 @@ qemuGetMemoryBackingPath(const virDomainDef *def, const char *alias, char **memPath) { - VIR_AUTOFREE(char *) domainPath = NULL; + g_autofree char *domainPath = NULL; if (!alias) { /* This should never happen (TM) */ diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 734ea7a764..5b3e1d8fcb 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3012,9 +3012,9 @@ qemuDomainObjPrivateXMLParseBlockjobChain(xmlNodePtr node, { VIR_XPATH_NODE_AUTORESTORE(ctxt); - VIR_AUTOFREE(char *) format = NULL; - VIR_AUTOFREE(char *) type = NULL; - VIR_AUTOFREE(char *) index = NULL; + g_autofree char *format = NULL; + g_autofree char *type = NULL; + g_autofree char *index = NULL; VIR_AUTOUNREF(virStorageSourcePtr) src = NULL; xmlNodePtr sourceNode; unsigned int xmlflags = VIR_DOMAIN_DEF_PARSE_STATUS; @@ -3049,7 +3049,7 @@ qemuDomainObjPrivateXMLParseBlockjobNodename(qemuBlockJobDataPtr job, virStorageSourcePtr *src, xmlXPathContextPtr ctxt) { - VIR_AUTOFREE(char *) nodename = NULL; + g_autofree char *nodename = NULL; *src = NULL; @@ -3080,8 +3080,8 @@ qemuDomainObjPrivateXMLParseBlockjobDataSpecific(qemuBlockJobDataPtr job, xmlXPathContextPtr ctxt, virDomainXMLOptionPtr xmlopt) { - VIR_AUTOFREE(char *) createmode = NULL; - VIR_AUTOFREE(char *) shallownew = NULL; + g_autofree char *createmode = NULL; + g_autofree char *shallownew = NULL; xmlNodePtr tmp; switch ((qemuBlockJobType) job->type) { @@ -3162,14 +3162,14 @@ qemuDomainObjPrivateXMLParseBlockjobData(virDomainObjPtr vm, VIR_XPATH_NODE_AUTORESTORE(ctxt); virDomainDiskDefPtr disk = NULL; VIR_AUTOUNREF(qemuBlockJobDataPtr) job = NULL; - VIR_AUTOFREE(char *) name = NULL; - VIR_AUTOFREE(char *) typestr = NULL; + g_autofree char *name = NULL; + g_autofree char *typestr = NULL; int type; - VIR_AUTOFREE(char *) statestr = NULL; + g_autofree char *statestr = NULL; int state = QEMU_BLOCKJOB_STATE_FAILED; - VIR_AUTOFREE(char *) diskdst = NULL; - VIR_AUTOFREE(char *) newstatestr = NULL; - VIR_AUTOFREE(char *) mirror = NULL; + g_autofree char *diskdst = NULL; + g_autofree char *newstatestr = NULL; + g_autofree char *mirror = NULL; int newstate = -1; bool invalidData = false; xmlNodePtr tmp; @@ -3245,9 +3245,9 @@ qemuDomainObjPrivateXMLParseBlockjobs(virDomainObjPtr vm, qemuDomainObjPrivatePtr priv, xmlXPathContextPtr ctxt) { - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; ssize_t nnodes = 0; - VIR_AUTOFREE(char *) active = NULL; + g_autofree char *active = NULL; int tmp; size_t i; @@ -3311,8 +3311,8 @@ qemuDomainObjPrivateXMLParseJobNBDSource(xmlNodePtr node, { VIR_XPATH_NODE_AUTORESTORE(ctxt); qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); - VIR_AUTOFREE(char *) format = NULL; - VIR_AUTOFREE(char *) type = NULL; + g_autofree char *format = NULL; + g_autofree char *type = NULL; VIR_AUTOUNREF(virStorageSourcePtr) migrSource = NULL; xmlNodePtr sourceNode; @@ -3469,7 +3469,7 @@ qemuDomainObjPrivateXMLParseSlirpFeatures(xmlNodePtr featuresNode, qemuSlirpPtr slirp) { VIR_XPATH_NODE_AUTORESTORE(ctxt); - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; size_t i; int n; @@ -3482,7 +3482,7 @@ qemuDomainObjPrivateXMLParseSlirpFeatures(xmlNodePtr featuresNode, } for (i = 0; i < n; i++) { - VIR_AUTOFREE(char *) str = virXMLPropString(nodes[i], "name"); + g_autofree char *str = virXMLPropString(nodes[i], "name"); int feature; if (!str) @@ -3646,8 +3646,8 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, goto error; } for (i = 0; i < n; i++) { - VIR_AUTOFREE(char *) alias = virXMLPropString(nodes[i], "alias"); - VIR_AUTOFREE(char *) pid = virXMLPropString(nodes[i], "pid"); + g_autofree char *alias = virXMLPropString(nodes[i], "alias"); + g_autofree char *pid = virXMLPropString(nodes[i], "pid"); VIR_AUTOPTR(qemuSlirp) slirp = qemuSlirpNew(); virDomainDeviceDef dev; @@ -3778,7 +3778,7 @@ static int qemuDomainDefNamespaceParseCommandlineArgs(qemuDomainXmlNsDefPtr nsdef, xmlXPathContextPtr ctxt) { - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; ssize_t nnodes; size_t i; @@ -3826,7 +3826,7 @@ static int qemuDomainDefNamespaceParseCommandlineEnv(qemuDomainXmlNsDefPtr nsdef, xmlXPathContextPtr ctxt) { - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; ssize_t nnodes; size_t i; @@ -3863,9 +3863,9 @@ static int qemuDomainDefNamespaceParseCaps(qemuDomainXmlNsDefPtr nsdef, xmlXPathContextPtr ctxt) { - VIR_AUTOFREE(xmlNodePtr *) nodesadd = NULL; + g_autofree xmlNodePtr *nodesadd = NULL; ssize_t nnodesadd; - VIR_AUTOFREE(xmlNodePtr *) nodesdel = NULL; + g_autofree xmlNodePtr *nodesdel = NULL; ssize_t nnodesdel; size_t i; @@ -9820,8 +9820,8 @@ qemuDomainRemoveInactiveCommon(virQEMUDriverPtr driver, virDomainObjPtr vm) { virQEMUDriverConfigPtr cfg; - VIR_AUTOFREE(char *) snapDir = NULL; - VIR_AUTOFREE(char *) chkDir = NULL; + g_autofree char *snapDir = NULL; + g_autofree char *chkDir = NULL; cfg = virQEMUDriverGetConfig(driver); @@ -11713,7 +11713,7 @@ ppc64VFIODeviceIsNV2Bridge(const char *device) size_t i; for (i = 0; i < G_N_ELEMENTS(nvlink2Files); i++) { - VIR_AUTOFREE(char *) file = NULL; + g_autofree char *file = NULL; if ((virAsprintf(&file, "/sys/bus/pci/devices/%s/of_node/%s", device, nvlink2Files[i])) < 0) @@ -11766,7 +11766,7 @@ getPPC64MemLockLimitBytes(virDomainDefPtr def) pciAddr = &dev->source.subsys.u.pci.addr; if (virPCIDeviceAddressIsValid(pciAddr, false)) { - VIR_AUTOFREE(char *) pciAddrStr = NULL; + g_autofree char *pciAddrStr = NULL; pciAddrStr = virPCIDeviceAddressAsString(pciAddr); if (ppc64VFIODeviceIsNV2Bridge(pciAddrStr)) { diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 438fa72262..fa40ba4f7d 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1525,7 +1525,7 @@ qemuDomainCollectPCIAddress(virDomainDefPtr def G_GNUC_UNUSED, * inappropriate address types. */ if (!info->pciConnectFlags) { - VIR_AUTOFREE(char *) addrStr = virPCIDeviceAddressAsString(&info->addr.pci); + g_autofree char *addrStr = virPCIDeviceAddressAsString(&info->addr.pci); VIR_WARN("qemuDomainDeviceCalculatePCIConnectFlags() thinks that the " "device with PCI address %s should not have a PCI address", @@ -1723,7 +1723,7 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr def, size_t i; virPCIDeviceAddress tmp_addr; bool qemuDeviceVideoUsable = virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY); - VIR_AUTOFREE(char *) addrStr = NULL; + g_autofree char *addrStr = NULL; virDomainPCIConnectFlags flags = (VIR_PCI_CONNECT_HOTPLUGGABLE | VIR_PCI_CONNECT_TYPE_PCI_DEVICE); @@ -1864,7 +1864,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def, size_t i; virPCIDeviceAddress tmp_addr; bool qemuDeviceVideoUsable = virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY); - VIR_AUTOFREE(char *) addrStr = NULL; + g_autofree char *addrStr = NULL; virDomainPCIConnectFlags flags = VIR_PCI_CONNECT_TYPE_PCIE_DEVICE; for (i = 0; i < def->ncontrollers; i++) { diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6ce6348593..69919ac203 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4921,7 +4921,7 @@ processRdmaGidStatusChangedEvent(virDomainObjPtr vm, { unsigned int prefix_len; virSocketAddr addr; - VIR_AUTOFREE(char *) addrStr = NULL; + g_autofree char *addrStr = NULL; int rc; if (!virDomainObjIsActive(vm)) @@ -7520,7 +7520,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn, for (i = 0; i < vm->def->nnets; i++) { virDomainNetDefPtr net = vm->def->nets[i]; unsigned int bootIndex = net->info.bootIndex; - VIR_AUTOFREE(char *) model = NULL; + g_autofree char *model = NULL; virMacAddr mac = net->mac; char *script = net->script; @@ -15777,14 +15777,14 @@ qemuDomainSnapshotCreateActiveExternal(virQEMUDriverPtr driver, bool resume = false; int ret = -1; qemuDomainObjPrivatePtr priv = vm->privateData; - VIR_AUTOFREE(char *) xml = NULL; + g_autofree char *xml = NULL; virDomainSnapshotDefPtr snapdef = virDomainSnapshotObjGetDef(snap); bool memory = snapdef->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; bool memory_unlink = false; int thaw = 0; /* 1 if freeze succeeded, -1 if freeze failed */ bool pmsuspended = false; int compressed; - VIR_AUTOFREE(char *) compressedpath = NULL; + g_autofree char *compressedpath = NULL; virQEMUSaveDataPtr data = NULL; /* If quiesce was requested, then issue a freeze command, and a @@ -17682,8 +17682,8 @@ qemuDomainBlockPullCommon(virDomainObjPtr vm, virDomainDiskDefPtr disk; virStorageSourcePtr baseSource = NULL; unsigned int baseIndex = 0; - VIR_AUTOFREE(char *) basePath = NULL; - VIR_AUTOFREE(char *) backingPath = NULL; + g_autofree char *basePath = NULL; + g_autofree char *backingPath = NULL; unsigned long long speed = bandwidth; qemuBlockJobDataPtr job = NULL; bool persistjob = false; @@ -18693,9 +18693,9 @@ qemuDomainBlockCommit(virDomainPtr dom, unsigned int baseIndex = 0; virStorageSourcePtr top_parent = NULL; bool clean_access = false; - VIR_AUTOFREE(char *) topPath = NULL; - VIR_AUTOFREE(char *) basePath = NULL; - VIR_AUTOFREE(char *) backingPath = NULL; + g_autofree char *topPath = NULL; + g_autofree char *basePath = NULL; + g_autofree char *backingPath = NULL; unsigned long long speed = bandwidth; qemuBlockJobDataPtr job = NULL; VIR_AUTOUNREF(virStorageSourcePtr) mirror = NULL; @@ -21585,7 +21585,7 @@ qemuDomainGetStats(virConnectPtr conn, virDomainStatsRecordPtr *record, unsigned int flags) { - VIR_AUTOFREE(virDomainStatsRecordPtr) tmp = NULL; + g_autofree virDomainStatsRecordPtr tmp = NULL; VIR_AUTOPTR(virTypedParamList) params = NULL; size_t i; @@ -22841,7 +22841,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom, qemuAgentPtr agent; int ret = -1; int maxparams = 0; - VIR_AUTOFREE(char *) hostname = NULL; + g_autofree char *hostname = NULL; unsigned int supportedTypes = types; int rc; diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index abcaa9fca2..463f76c21a 100644 --- a/src/qemu/qemu_extdevice.c +++ b/src/qemu/qemu_extdevice.c @@ -43,8 +43,8 @@ qemuExtDeviceLogCommand(virQEMUDriverPtr driver, virCommandPtr cmd, const char *info) { - VIR_AUTOFREE(char *) timestamp = virTimeStringNow(); - VIR_AUTOFREE(char *) cmds = virCommandToString(cmd, false); + g_autofree char *timestamp = virTimeStringNow(); + g_autofree char *cmds = virCommandToString(cmd, false); if (!timestamp || !cmds) return -1; diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index 6d3faadd23..d043b46e6c 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -545,7 +545,7 @@ qemuFirmwareTargetParse(const char *path, for (j = 0; j < nmachines; j++) { virJSONValuePtr machine = virJSONValueArrayGet(machines, j); - VIR_AUTOFREE(char *) machineStr = NULL; + g_autofree char *machineStr = NULL; if (VIR_STRDUP(machineStr, virJSONValueGetString(machine)) < 0) goto cleanup; @@ -618,7 +618,7 @@ qemuFirmwareFeatureParse(const char *path, qemuFirmwarePtr qemuFirmwareParse(const char *path) { - VIR_AUTOFREE(char *) cont = NULL; + g_autofree char *cont = NULL; VIR_AUTOPTR(virJSONValue) doc = NULL; VIR_AUTOPTR(qemuFirmware) fw = NULL; qemuFirmwarePtr ret = NULL; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index fcb206a8af..f22b509ffa 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -136,7 +136,7 @@ static int qemuDomainAttachZPCIDevice(qemuMonitorPtr mon, virDomainDeviceInfoPtr info) { - VIR_AUTOFREE(char *) devstr_zpci = NULL; + g_autofree char *devstr_zpci = NULL; if (!(devstr_zpci = qemuBuildZPCIDevStr(info))) return -1; @@ -152,7 +152,7 @@ static int qemuDomainDetachZPCIDevice(qemuMonitorPtr mon, virDomainDeviceInfoPtr info) { - VIR_AUTOFREE(char *) zpciAlias = NULL; + g_autofree char *zpciAlias = NULL; if (virAsprintf(&zpciAlias, "zpci%d", info->addr.pci.zpci.uid) < 0) return -1; @@ -249,11 +249,11 @@ qemuDomainChangeMediaLegacy(virQEMUDriverPtr driver, bool force) { int rc; - VIR_AUTOFREE(char *) driveAlias = NULL; + g_autofree char *driveAlias = NULL; qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); const char *format = NULL; - VIR_AUTOFREE(char *) sourcestr = NULL; + g_autofree char *sourcestr = NULL; if (!disk->info.alias) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -463,7 +463,7 @@ qemuDomainDetachDBusVMState(virQEMUDriverPtr driver, qemuDomainAsyncJob asyncJob) { qemuDomainObjPrivatePtr priv = vm->privateData; - VIR_AUTOFREE(char *) alias = qemuAliasDBusVMStateFromId(id); + g_autofree char *alias = qemuAliasDBusVMStateFromId(id); int ret; if (!alias || @@ -507,7 +507,7 @@ qemuDomainChangeMediaBlockdev(virQEMUDriverPtr driver, qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); VIR_AUTOPTR(qemuBlockStorageSourceChainData) newbackend = NULL; VIR_AUTOPTR(qemuBlockStorageSourceChainData) oldbackend = NULL; - VIR_AUTOFREE(char *) nodename = NULL; + g_autofree char *nodename = NULL; int rc; if (!virStorageSourceIsEmpty(oldsrc) && @@ -675,10 +675,10 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, VIR_AUTOPTR(qemuBlockStorageSourceChainData) data = NULL; int ret = -1; qemuDomainObjPrivatePtr priv = vm->privateData; - VIR_AUTOFREE(char *) devstr = NULL; + g_autofree char *devstr = NULL; VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver); VIR_AUTOPTR(virJSONValue) corProps = NULL; - VIR_AUTOFREE(char *) corAlias = NULL; + g_autofree char *corAlias = NULL; bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); if (qemuDomainStorageSourceChainAccessAllow(driver, vm, disk->src) < 0) @@ -808,7 +808,7 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, { int ret = -1; const char* type = virDomainControllerTypeToString(controller->type); - VIR_AUTOFREE(char *) devstr = NULL; + g_autofree char *devstr = NULL; qemuDomainObjPrivatePtr priv = vm->privateData; virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_CONTROLLER, { .controller = controller } }; @@ -1131,7 +1131,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, qemuDomainObjPrivatePtr priv = vm->privateData; virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_NET, { .net = net } }; virErrorPtr originalError = NULL; - VIR_AUTOFREE(char *) slirpfdName = NULL; + g_autofree char *slirpfdName = NULL; int slirpfd = -1; char **tapfdName = NULL; int *tapfd = NULL; @@ -1140,8 +1140,8 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, int *vhostfd = NULL; size_t vhostfdSize = 0; size_t queueSize = 0; - VIR_AUTOFREE(char *) nicstr = NULL; - VIR_AUTOFREE(char *) netstr = NULL; + g_autofree char *nicstr = NULL; + g_autofree char *netstr = NULL; int ret = -1; bool releaseaddr = false; bool iface_connected = false; @@ -1150,10 +1150,10 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver); virDomainCCWAddressSetPtr ccwaddrs = NULL; size_t i; - VIR_AUTOFREE(char *) charDevAlias = NULL; + g_autofree char *charDevAlias = NULL; bool charDevPlugged = false; bool netdevPlugged = false; - VIR_AUTOFREE(char *) netdev_name = NULL; + g_autofree char *netdev_name = NULL; virConnectPtr conn = NULL; virErrorPtr save_err = NULL; @@ -1536,7 +1536,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, { .hostdev = hostdev } }; virDomainDeviceInfoPtr info = hostdev->info; int ret; - VIR_AUTOFREE(char *) devstr = NULL; + g_autofree char *devstr = NULL; bool releaseaddr = false; bool teardowncgroup = false; bool teardownlabel = false; @@ -1702,7 +1702,7 @@ qemuDomainAddTLSObjects(virQEMUDriverPtr driver, { qemuDomainObjPrivatePtr priv = vm->privateData; virErrorPtr orig_err; - VIR_AUTOFREE(char *) secAlias = NULL; + g_autofree char *secAlias = NULL; if (!tlsProps && !secProps) return 0; @@ -1825,8 +1825,8 @@ qemuDomainDelChardevTLSObjects(virQEMUDriverPtr driver, { VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver); qemuDomainObjPrivatePtr priv = vm->privateData; - VIR_AUTOFREE(char *) tlsAlias = NULL; - VIR_AUTOFREE(char *) secAlias = NULL; + g_autofree char *tlsAlias = NULL; + g_autofree char *secAlias = NULL; if (dev->type != VIR_DOMAIN_CHR_TYPE_TCP || dev->data.tcp.haveTLS != VIR_TRISTATE_BOOL_YES) { @@ -1864,10 +1864,10 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr driver, int ret = -1; qemuDomainObjPrivatePtr priv = vm->privateData; virDomainDefPtr def = vm->def; - VIR_AUTOFREE(char *) charAlias = NULL; - VIR_AUTOFREE(char *) devstr = NULL; + g_autofree char *charAlias = NULL; + g_autofree char *devstr = NULL; bool chardevAdded = false; - VIR_AUTOFREE(char *) tlsAlias = NULL; + g_autofree char *tlsAlias = NULL; const char *secAlias = NULL; bool need_release = false; virErrorPtr orig_err; @@ -2097,14 +2097,14 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver, qemuDomainObjPrivatePtr priv = vm->privateData; virErrorPtr orig_err; virDomainDefPtr vmdef = vm->def; - VIR_AUTOFREE(char *) devstr = NULL; + g_autofree char *devstr = NULL; virDomainChrSourceDefPtr dev = chr->source; - VIR_AUTOFREE(char *)charAlias = NULL; + g_autofree char *charAlias = NULL; bool chardevAttached = false; bool teardowncgroup = false; bool teardowndevice = false; bool teardownlabel = false; - VIR_AUTOFREE(char *) tlsAlias = NULL; + g_autofree char *tlsAlias = NULL; const char *secAlias = NULL; bool need_release = false; bool guestfwd = false; @@ -2209,10 +2209,10 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver, qemuDomainObjPrivatePtr priv = vm->privateData; virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_RNG, { .rng = rng } }; virErrorPtr orig_err; - VIR_AUTOFREE(char *) devstr = NULL; - VIR_AUTOFREE(char *) charAlias = NULL; - VIR_AUTOFREE(char *) objAlias = NULL; - VIR_AUTOFREE(char *) tlsAlias = NULL; + g_autofree char *devstr = NULL; + g_autofree char *charAlias = NULL; + g_autofree char *objAlias = NULL; + g_autofree char *tlsAlias = NULL; const char *secAlias = NULL; bool releaseaddr = false; bool teardowncgroup = false; @@ -2336,8 +2336,8 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver, VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver); unsigned long long oldmem = virDomainDefGetMemoryTotal(vm->def); unsigned long long newmem = oldmem + mem->size; - VIR_AUTOFREE(char *) devstr = NULL; - VIR_AUTOFREE(char *) objalias = NULL; + g_autofree char *devstr = NULL; + g_autofree char *objalias = NULL; bool objAdded = false; bool teardownlabel = false; bool teardowncgroup = false; @@ -2472,7 +2472,7 @@ qemuDomainAttachHostUSBDevice(virQEMUDriverPtr driver, virDomainHostdevDefPtr hostdev) { qemuDomainObjPrivatePtr priv = vm->privateData; - VIR_AUTOFREE(char *) devstr = NULL; + g_autofree char *devstr = NULL; bool added = false; bool teardowncgroup = false; bool teardownlabel = false; @@ -2547,10 +2547,10 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriverPtr driver, int ret = -1; qemuDomainObjPrivatePtr priv = vm->privateData; virErrorPtr orig_err; - VIR_AUTOFREE(char *) devstr = NULL; - VIR_AUTOFREE(char *) drvstr = NULL; - VIR_AUTOFREE(char *) drivealias = NULL; - VIR_AUTOFREE(char *) secobjAlias = NULL; + g_autofree char *devstr = NULL; + g_autofree char *drvstr = NULL; + g_autofree char *drivealias = NULL; + g_autofree char *secobjAlias = NULL; bool teardowncgroup = false; bool teardownlabel = false; bool teardowndevice = false; @@ -2681,9 +2681,9 @@ qemuDomainAttachSCSIVHostDevice(virQEMUDriverPtr driver, virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_HOSTDEV, { .hostdev = hostdev } }; virDomainCCWAddressSetPtr ccwaddrs = NULL; - VIR_AUTOFREE(char *) vhostfdName = NULL; + g_autofree char *vhostfdName = NULL; int vhostfd = -1; - VIR_AUTOFREE(char *) devstr = NULL; + g_autofree char *devstr = NULL; bool teardowncgroup = false; bool teardownlabel = false; bool teardowndevice = false; @@ -2789,7 +2789,7 @@ qemuDomainAttachMediatedDevice(virQEMUDriverPtr driver, virDomainHostdevDefPtr hostdev) { int ret = -1; - VIR_AUTOFREE(char *) devstr = NULL; + g_autofree char *devstr = NULL; bool added = false; bool teardowncgroup = false; bool teardownlabel = false; @@ -2938,9 +2938,9 @@ qemuDomainAttachShmemDevice(virQEMUDriverPtr driver, virDomainShmemDefPtr shmem) { int ret = -1; - VIR_AUTOFREE(char *) shmstr = NULL; - VIR_AUTOFREE(char *) charAlias = NULL; - VIR_AUTOFREE(char *) memAlias = NULL; + g_autofree char *shmstr = NULL; + g_autofree char *charAlias = NULL; + g_autofree char *memAlias = NULL; bool release_backing = false; bool release_address = true; virErrorPtr orig_err = NULL; @@ -3060,7 +3060,7 @@ qemuDomainAttachWatchdog(virQEMUDriverPtr driver, virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_WATCHDOG, { .watchdog = watchdog } }; virDomainWatchdogAction actualAction = watchdog->action; const char *actionStr = NULL; - VIR_AUTOFREE(char *) watchdogstr = NULL; + g_autofree char *watchdogstr = NULL; bool releaseAddress = false; int rv; @@ -3127,7 +3127,7 @@ qemuDomainAttachInputDevice(virQEMUDriverPtr driver, virDomainInputDefPtr input) { int ret = -1; - VIR_AUTOFREE(char *) devstr = NULL; + g_autofree char *devstr = NULL; qemuDomainObjPrivatePtr priv = vm->privateData; virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_INPUT, { .input = input } }; @@ -3234,8 +3234,8 @@ qemuDomainAttachVsockDevice(virQEMUDriverPtr driver, virErrorPtr originalError = NULL; const char *fdprefix = "vsockfd"; bool releaseaddr = false; - VIR_AUTOFREE(char *) fdname = NULL; - VIR_AUTOFREE(char *) devstr = NULL; + g_autofree char *fdname = NULL; + g_autofree char *devstr = NULL; int ret = -1; if (vm->def->vsock) { @@ -3965,7 +3965,7 @@ qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver, qemuDomainObjPrivatePtr priv = vm->privateData; time_t now = time(NULL); const char *expire; - VIR_AUTOFREE(char *) validTo = NULL; + g_autofree char *validTo = NULL; const char *connected = NULL; const char *password; int ret = -1; @@ -4236,7 +4236,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, virDomainDeviceDef dev; size_t i; qemuDomainObjPrivatePtr priv = vm->privateData; - VIR_AUTOFREE(char *) corAlias = NULL; + g_autofree char *corAlias = NULL; bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); int ret = -1; @@ -4339,7 +4339,7 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver, qemuDomainObjPrivatePtr priv = vm->privateData; unsigned long long oldmem = virDomainDefGetMemoryTotal(vm->def); unsigned long long newmem = oldmem - mem->size; - VIR_AUTOFREE(char *) backendAlias = NULL; + g_autofree char *backendAlias = NULL; int rc; int idx; @@ -4438,8 +4438,8 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver, virDomainNetDefPtr net = NULL; size_t i; qemuDomainObjPrivatePtr priv = vm->privateData; - VIR_AUTOFREE(char *) drivealias = NULL; - VIR_AUTOFREE(char *) objAlias = NULL; + g_autofree char *drivealias = NULL; + g_autofree char *objAlias = NULL; bool is_vfio = false; VIR_DEBUG("Removing host device %s from domain %p %s", @@ -4557,8 +4557,8 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver, { VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver); qemuDomainObjPrivatePtr priv = vm->privateData; - VIR_AUTOFREE(char *) hostnet_name = NULL; - VIR_AUTOFREE(char *) charDevAlias = NULL; + g_autofree char *hostnet_name = NULL; + g_autofree char *charDevAlias = NULL; size_t i; int actualType = virDomainNetGetActualType(net); @@ -4661,7 +4661,7 @@ qemuDomainRemoveChrDevice(virQEMUDriverPtr driver, bool monitor) { virObjectEventPtr event; - VIR_AUTOFREE(char *) charAlias = NULL; + g_autofree char *charAlias = NULL; qemuDomainObjPrivatePtr priv = vm->privateData; int rc = 0; @@ -4716,8 +4716,8 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainRNGDefPtr rng) { - VIR_AUTOFREE(char *) charAlias = NULL; - VIR_AUTOFREE(char *) objAlias = NULL; + g_autofree char *charAlias = NULL; + g_autofree char *objAlias = NULL; qemuDomainObjPrivatePtr priv = vm->privateData; ssize_t idx; int rc = 0; @@ -4778,8 +4778,8 @@ qemuDomainRemoveShmemDevice(virQEMUDriverPtr driver, { int rc; ssize_t idx = -1; - VIR_AUTOFREE(char *) charAlias = NULL; - VIR_AUTOFREE(char *) memAlias = NULL; + g_autofree char *charAlias = NULL; + g_autofree char *memAlias = NULL; qemuDomainObjPrivatePtr priv = vm->privateData; VIR_DEBUG("Removing shmem device %s from domain %p %s", @@ -4880,7 +4880,7 @@ qemuDomainRemoveRedirdevDevice(virQEMUDriverPtr driver, virDomainRedirdevDefPtr dev) { qemuDomainObjPrivatePtr priv = vm->privateData; - VIR_AUTOFREE(char *) charAlias = NULL; + g_autofree char *charAlias = NULL; ssize_t idx; VIR_DEBUG("Removing redirdev device %s from domain %p %s", @@ -4983,7 +4983,7 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver, { virDomainDeviceInfoPtr info; virObjectEventPtr event; - VIR_AUTOFREE(char *) alias = NULL; + g_autofree char *alias = NULL; /* * save the alias to use when sending a DEVICE_REMOVED event after diff --git a/src/qemu/qemu_interop_config.c b/src/qemu/qemu_interop_config.c index 1f39d4b576..9281935d9a 100644 --- a/src/qemu/qemu_interop_config.c +++ b/src/qemu/qemu_interop_config.c @@ -48,8 +48,8 @@ qemuBuildFileList(virHashTablePtr files, const char *dir) return 0; while ((rc = virDirRead(dirp, &ent, dir)) > 0) { - VIR_AUTOFREE(char *) filename = NULL; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *filename = NULL; + g_autofree char *path = NULL; struct stat sb; if (STRPREFIX(ent->d_name, ".")) @@ -100,11 +100,11 @@ qemuInteropFetchConfigs(const char *name, bool privileged) { VIR_AUTOPTR(virHashTable) files = NULL; - VIR_AUTOFREE(char *) homeConfig = NULL; - VIR_AUTOFREE(char *) xdgConfig = NULL; - VIR_AUTOFREE(char *) sysLocation = virFileBuildPath(QEMU_SYSTEM_LOCATION, name, NULL); - VIR_AUTOFREE(char *) etcLocation = virFileBuildPath(QEMU_ETC_LOCATION, name, NULL); - VIR_AUTOFREE(virHashKeyValuePairPtr) pairs = NULL; + g_autofree char *homeConfig = NULL; + g_autofree char *xdgConfig = NULL; + g_autofree char *sysLocation = virFileBuildPath(QEMU_SYSTEM_LOCATION, name, NULL); + g_autofree char *etcLocation = virFileBuildPath(QEMU_ETC_LOCATION, name, NULL); + g_autofree virHashKeyValuePairPtr pairs = NULL; virHashKeyValuePairPtr tmp = NULL; *configs = NULL; @@ -119,7 +119,7 @@ qemuInteropFetchConfigs(const char *name, return -1; if (!xdgConfig) { - VIR_AUTOFREE(char *) home = virGetUserDirectory(); + g_autofree char *home = virGetUserDirectory(); if (!home) return -1; diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 52ef1874aa..fbd6681051 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -869,7 +869,7 @@ qemuMigrationSrcNBDStorageCopyDriveMirror(virQEMUDriverPtr driver, unsigned long long mirror_speed, bool mirror_shallow) { - VIR_AUTOFREE(char *) nbd_dest = NULL; + g_autofree char *nbd_dest = NULL; int mon_ret; if (strchr(host, ':')) { diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 49f9159315..33dae75e41 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1129,7 +1129,7 @@ qemuMonitorUpdateVideoMemorySize(qemuMonitorPtr mon, const char *videoName) { int rc = -1; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; QEMU_CHECK_MONITOR(mon); @@ -1159,7 +1159,7 @@ qemuMonitorUpdateVideoVram64Size(qemuMonitorPtr mon, const char *videoName) { int rc = -1; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; QEMU_CHECK_MONITOR(mon); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 242b637451..e9967eadfe 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2527,7 +2527,7 @@ static qemuBlockStatsPtr qemuMonitorJSONBlockStatsCollectData(virJSONValuePtr dev, int *nstats) { - VIR_AUTOFREE(qemuBlockStatsPtr) bstats = NULL; + g_autofree qemuBlockStatsPtr bstats = NULL; virJSONValuePtr parent; virJSONValuePtr parentstats; virJSONValuePtr stats; @@ -2601,11 +2601,11 @@ qemuMonitorJSONGetOneBlockStatsInfo(virJSONValuePtr dev, virHashTablePtr hash, bool backingChain) { - VIR_AUTOFREE(qemuBlockStatsPtr) bstats = NULL; + g_autofree qemuBlockStatsPtr bstats = NULL; int nstats = 0; const char *qdevname = NULL; const char *nodename = NULL; - VIR_AUTOFREE(char *) devicename = NULL; + g_autofree char *devicename = NULL; virJSONValuePtr backing; if (dev_name && diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 9c50c4a1d8..afbbe1a853 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5508,7 +5508,7 @@ qemuProcessStartValidate(virQEMUDriverPtr driver, return -1; if (n > 0) { - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; str = virStringListJoin((const char **)features, ", "); virReportError(VIR_ERR_CONFIG_UNSUPPORTED, diff --git a/src/qemu/qemu_slirp.c b/src/qemu/qemu_slirp.c index 716b73759d..53e8f27e2d 100644 --- a/src/qemu/qemu_slirp.c +++ b/src/qemu/qemu_slirp.c @@ -99,7 +99,7 @@ qemuSlirpNewForHelper(const char *helper) { VIR_AUTOPTR(qemuSlirp) slirp = NULL; VIR_AUTOPTR(virCommand) cmd = NULL; - VIR_AUTOFREE(char *) output = NULL; + g_autofree char *output = NULL; VIR_AUTOPTR(virJSONValue) doc = NULL; virJSONValuePtr featuresJSON; size_t i, nfeatures; @@ -150,8 +150,8 @@ qemuSlirpCreatePidFilename(virQEMUDriverConfigPtr cfg, const virDomainDef *def, const char *alias) { - VIR_AUTOFREE(char *) shortName = NULL; - VIR_AUTOFREE(char *) name = NULL; + g_autofree char *shortName = NULL; + g_autofree char *name = NULL; if (!(shortName = virDomainDefGetShortName(def)) || virAsprintf(&name, "%s-%s-slirp", shortName, alias) < 0) @@ -221,7 +221,7 @@ qemuSlirpGetDBusPath(virQEMUDriverConfigPtr cfg, const virDomainDef *def, const char *alias) { - VIR_AUTOFREE(char *) shortName = NULL; + g_autofree char *shortName = NULL; char *path = NULL; if (!(shortName = virDomainDefGetShortName(def)) || @@ -241,9 +241,9 @@ qemuSlirpStop(qemuSlirpPtr slirp, bool hot) { VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver); - VIR_AUTOFREE(char *) pidfile = NULL; - VIR_AUTOFREE(char *) dbus_path = NULL; - VIR_AUTOFREE(char *) id = qemuSlirpGetDBusVMStateId(net); + g_autofree char *pidfile = NULL; + g_autofree char *dbus_path = NULL; + g_autofree char *id = qemuSlirpGetDBusVMStateId(net); virErrorPtr orig_err; pid_t pid; int rc; @@ -298,10 +298,10 @@ qemuSlirpStart(qemuSlirpPtr slirp, { VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver); VIR_AUTOPTR(virCommand) cmd = NULL; - VIR_AUTOFREE(char *) pidfile = NULL; - VIR_AUTOFREE(char *) dbus_path = NULL; - VIR_AUTOFREE(char *) dbus_addr = NULL; - VIR_AUTOFREE(char *) id = NULL; + g_autofree char *pidfile = NULL; + g_autofree char *dbus_path = NULL; + g_autofree char *dbus_addr = NULL; + g_autofree char *id = NULL; size_t i; const unsigned long long timeout = 5 * 1000; /* ms */ pid_t pid = (pid_t) -1; @@ -334,7 +334,7 @@ qemuSlirpStart(qemuSlirpPtr slirp, for (i = 0; i < net->guestIP.nips; i++) { const virNetDevIPAddr *ip = net->guestIP.ips[i]; - VIR_AUTOFREE(char *) addr = NULL; + g_autofree char *addr = NULL; const char *opt = ""; if (!(addr = virSocketAddrFormat(&ip->address))) @@ -350,7 +350,7 @@ qemuSlirpStart(qemuSlirpPtr slirp, if (ip->prefix) { if (VIR_SOCKET_ADDR_IS_FAMILY(&ip->address, AF_INET)) { virSocketAddr netmask; - VIR_AUTOFREE(char *) netmaskStr = NULL; + g_autofree char *netmaskStr = NULL; if (virSocketAddrPrefixToNetmask(ip->prefix, &netmask, AF_INET) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 31fdfa995f..f21dbf9727 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -280,7 +280,7 @@ qemuTPMEmulatorGetPid(const char *swtpmStateDir, pid_t *pid) { int ret; - VIR_AUTOFREE(char *) swtpm = virTPMGetSwtpm(); + g_autofree char *swtpm = virTPMGetSwtpm(); char *pidfile = qemuTPMEmulatorCreatePidFilename(swtpmStateDir, shortName); if (!pidfile) @@ -399,7 +399,7 @@ qemuTPMSetupEncryption(const unsigned char *secretuuid, int ret = -1; int pipefd[2] = { -1, -1 }; virConnectPtr conn; - VIR_AUTOFREE(uint8_t *) secret = NULL; + g_autofree uint8_t *secret = NULL; size_t secret_len; virSecretLookupTypeDef seclookupdef = { .type = VIR_SECRET_LOOKUP_TYPE_UUID, @@ -475,7 +475,7 @@ qemuTPMEmulatorRunSetup(const char *storagepath, int ret = -1; char uuid[VIR_UUID_STRING_BUFLEN]; char *vmid = NULL; - VIR_AUTOFREE(char *)swtpm_setup = virTPMGetSwtpmSetup(); + g_autofree char *swtpm_setup = virTPMGetSwtpmSetup(); VIR_AUTOCLOSE pwdfile_fd = -1; if (!swtpm_setup) @@ -597,7 +597,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDefPtr tpm, virCommandPtr cmd = NULL; bool created = false; char *pidfile; - VIR_AUTOFREE(char *) swtpm = virTPMGetSwtpm(); + g_autofree char *swtpm = virTPMGetSwtpm(); VIR_AUTOCLOSE pwdfile_fd = -1; VIR_AUTOCLOSE migpwdfile_fd = -1; const unsigned char *secretuuid = NULL; @@ -713,7 +713,7 @@ qemuTPMEmulatorStop(const char *swtpmStateDir, virCommandPtr cmd; char *pathname; char *errbuf = NULL; - VIR_AUTOFREE(char *) swtpm_ioctl = virTPMGetSwtpmIoctl(); + g_autofree char *swtpm_ioctl = virTPMGetSwtpmIoctl(); if (!swtpm_ioctl) return; diff --git a/src/qemu/qemu_vhost_user.c b/src/qemu/qemu_vhost_user.c index bdc6cfb104..d1dbc3bd5c 100644 --- a/src/qemu/qemu_vhost_user.c +++ b/src/qemu/qemu_vhost_user.c @@ -182,7 +182,7 @@ qemuVhostUserBinaryParse(const char *path, qemuVhostUserPtr qemuVhostUserParse(const char *path) { - VIR_AUTOFREE(char *) cont = NULL; + g_autofree char *cont = NULL; VIR_AUTOPTR(virJSONValue) doc = NULL; VIR_AUTOPTR(qemuVhostUser) vu = NULL; qemuVhostUserPtr ret = NULL; @@ -351,7 +351,7 @@ qemuVhostUserFillDomainGPU(virQEMUDriverPtr driver, for (i = 0; i < nvus; i++) { VIR_AUTOPTR(virJSONValue) doc = NULL; - VIR_AUTOFREE(char *) output = NULL; + g_autofree char *output = NULL; VIR_AUTOPTR(virCommand) cmd = NULL; vu = vus[i]; diff --git a/src/qemu/qemu_vhost_user_gpu.c b/src/qemu/qemu_vhost_user_gpu.c index 1d6fdcb5e9..291a6a0d9e 100644 --- a/src/qemu/qemu_vhost_user_gpu.c +++ b/src/qemu/qemu_vhost_user_gpu.c @@ -45,7 +45,7 @@ qemuVhostUserGPUCreatePidFilename(const char *stateDir, const char *shortName, const char *alias) { - VIR_AUTOFREE(char *) devicename = NULL; + g_autofree char *devicename = NULL; if (virAsprintf(&devicename, "%s-%s-vhost-user-gpu", shortName, alias) < 0) return NULL; @@ -73,7 +73,7 @@ qemuVhostUserGPUGetPid(const char *binPath, const char *alias, pid_t *pid) { - VIR_AUTOFREE(char *) pidfile = NULL; + g_autofree char *pidfile = NULL; pidfile = qemuVhostUserGPUCreatePidFilename(stateDir, shortName, alias); if (!pidfile) @@ -106,8 +106,8 @@ int qemuExtVhostUserGPUStart(virQEMUDriverPtr driver, virDomainVideoDefPtr video) { VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver); - VIR_AUTOFREE(char *) shortname = NULL; - VIR_AUTOFREE(char *) pidfile = NULL; + g_autofree char *shortname = NULL; + g_autofree char *pidfile = NULL; VIR_AUTOPTR(virCommand) cmd = NULL; int pair[2] = { -1, -1 }; int cmdret = 0, rc; @@ -210,8 +210,8 @@ void qemuExtVhostUserGPUStop(virQEMUDriverPtr driver, virDomainVideoDefPtr video) { VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver); - VIR_AUTOFREE(char *) pidfile = NULL; - VIR_AUTOFREE(char *) shortname = NULL; + g_autofree char *pidfile = NULL; + g_autofree char *shortname = NULL; virErrorPtr orig_err; shortname = virDomainDefGetShortName(vm->def); @@ -253,7 +253,7 @@ qemuExtVhostUserGPUSetupCgroup(virQEMUDriverPtr driver, virCgroupPtr cgroup) { VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver); - VIR_AUTOFREE(char *) shortname = NULL; + g_autofree char *shortname = NULL; int rc; pid_t pid; diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c index 9153791b3c..56a46a13be 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -2177,8 +2177,8 @@ remoteDispatchProbeURI(bool readonly, ssize_t i; for (i = 0; i < (ssize_t) G_N_ELEMENTS(drivers) && !*probeduri; i++) { - VIR_AUTOFREE(char *) daemonname = NULL; - VIR_AUTOFREE(char *) daemonpath = NULL; + g_autofree char *daemonname = NULL; + g_autofree char *daemonpath = NULL; if (virAsprintf(&daemonname, "virt%sd", drivers[i]) < 0) return -1; @@ -2223,7 +2223,7 @@ remoteDispatchProbeURI(bool readonly, ssize_t i; for (i = 0; i < (ssize_t) G_N_ELEMENTS(drivers) && !*probeduri; i++) { - VIR_AUTOFREE(char *) sockname = NULL; + g_autofree char *sockname = NULL; if (virAsprintf(&sockname, "%s/libvirt/virt%sd-%s", RUNSTATEDIR, drivers[i], @@ -2262,7 +2262,7 @@ remoteDispatchConnectOpen(virNetServerPtr server G_GNUC_UNUSED, { const char *name; #ifdef VIRTPROXYD - VIR_AUTOFREE(char *) probeduri = NULL; + g_autofree char *probeduri = NULL; #endif unsigned int flags; struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client); diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 5251079282..a0a0e311e0 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -771,7 +771,7 @@ remoteGetUNIXSocketHelper(remoteDriverTransport transport, unsigned int flags) { char *sockname = NULL; - VIR_AUTOFREE(char *) userdir = NULL; + g_autofree char *userdir = NULL; if (flags & VIR_DRV_OPEN_REMOTE_USER) { if (transport != REMOTE_DRIVER_TRANSPORT_UNIX) { @@ -817,10 +817,10 @@ remoteGetUNIXSocket(remoteDriverTransport transport, unsigned int flags) { char *sock_name = NULL; - VIR_AUTOFREE(char *) direct_daemon = NULL; - VIR_AUTOFREE(char *) legacy_daemon = NULL; - VIR_AUTOFREE(char *) direct_sock_name = NULL; - VIR_AUTOFREE(char *) legacy_sock_name = NULL; + g_autofree char *direct_daemon = NULL; + g_autofree char *legacy_daemon = NULL; + g_autofree char *direct_sock_name = NULL; + g_autofree char *legacy_sock_name = NULL; if (driver && virAsprintf(&direct_daemon, "virt%sd", driver) < 0) @@ -945,23 +945,23 @@ doRemoteOpen(virConnectPtr conn, { int transport; #ifndef WIN32 - VIR_AUTOFREE(char *) daemonPath = NULL; + g_autofree char *daemonPath = NULL; #endif - VIR_AUTOFREE(char *) tls_priority = NULL; - VIR_AUTOFREE(char *) name = NULL; - VIR_AUTOFREE(char *) command = NULL; - VIR_AUTOFREE(char *) sockname = NULL; - VIR_AUTOFREE(char *) netcat = NULL; - VIR_AUTOFREE(char *) port = NULL; - VIR_AUTOFREE(char *) authtype = NULL; - VIR_AUTOFREE(char *) username = NULL; - VIR_AUTOFREE(char *) pkipath = NULL; - VIR_AUTOFREE(char *) keyfile = NULL; - VIR_AUTOFREE(char *) sshauth = NULL; - VIR_AUTOFREE(char *) knownHostsVerify = NULL; - VIR_AUTOFREE(char *) knownHosts = NULL; - VIR_AUTOFREE(char *) mode_str = NULL; - VIR_AUTOFREE(char *) daemon_name = NULL; + g_autofree char *tls_priority = NULL; + g_autofree char *name = NULL; + g_autofree char *command = NULL; + g_autofree char *sockname = NULL; + g_autofree char *netcat = NULL; + g_autofree char *port = NULL; + g_autofree char *authtype = NULL; + g_autofree char *username = NULL; + g_autofree char *pkipath = NULL; + g_autofree char *keyfile = NULL; + g_autofree char *sshauth = NULL; + g_autofree char *knownHostsVerify = NULL; + g_autofree char *knownHosts = NULL; + g_autofree char *mode_str = NULL; + g_autofree char *daemon_name = NULL; bool sanity = true; bool verify = true; #ifndef WIN32 diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index 7e0a8351b4..ad4a684c16 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -476,8 +476,8 @@ secretStateInitialize(bool privileged, "%s/libvirt/secrets", RUNSTATEDIR) < 0) goto error; } else { - VIR_AUTOFREE(char *) rundir = NULL; - VIR_AUTOFREE(char *) cfgdir = NULL; + g_autofree char *rundir = NULL; + g_autofree char *cfgdir = NULL; if (!(cfgdir = virGetUserConfigDirectory())) goto error; diff --git a/src/security/security_util.c b/src/security/security_util.c index 4fd8289413..e6fbae7e34 100644 --- a/src/security/security_util.c +++ b/src/security/security_util.c @@ -162,9 +162,9 @@ static int virSecurityValidateTimestamp(const char *name, const char *path) { - VIR_AUTOFREE(char *) expected_timestamp = NULL; - VIR_AUTOFREE(char *) timestamp_name = NULL; - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *expected_timestamp = NULL; + g_autofree char *timestamp_name = NULL; + g_autofree char *value = NULL; if (!(expected_timestamp = virSecurityGetTimestamp()) || !(timestamp_name = virSecurityGetTimestampAttrName(name))) @@ -208,8 +208,8 @@ static int virSecurityAddTimestamp(const char *name, const char *path) { - VIR_AUTOFREE(char *) timestamp_name = NULL; - VIR_AUTOFREE(char *) timestamp_value = NULL; + g_autofree char *timestamp_name = NULL; + g_autofree char *timestamp_value = NULL; if (!(timestamp_value = virSecurityGetTimestamp()) || !(timestamp_name = virSecurityGetTimestampAttrName(name))) @@ -223,7 +223,7 @@ static int virSecurityRemoveTimestamp(const char *name, const char *path) { - VIR_AUTOFREE(char *) timestamp_name = NULL; + g_autofree char *timestamp_name = NULL; if (!(timestamp_name = virSecurityGetTimestampAttrName(name))) return -1; @@ -265,9 +265,9 @@ virSecurityGetRememberedLabel(const char *name, const char *path, char **label) { - VIR_AUTOFREE(char *) ref_name = NULL; - VIR_AUTOFREE(char *) attr_name = NULL; - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *ref_name = NULL; + g_autofree char *attr_name = NULL; + g_autofree char *value = NULL; unsigned int refcount = 0; *label = NULL; @@ -363,9 +363,9 @@ virSecuritySetRememberedLabel(const char *name, const char *path, const char *label) { - VIR_AUTOFREE(char *) ref_name = NULL; - VIR_AUTOFREE(char *) attr_name = NULL; - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *ref_name = NULL; + g_autofree char *attr_name = NULL; + g_autofree char *value = NULL; unsigned int refcount = 0; if (!(ref_name = virSecurityGetRefCountAttrName(name))) @@ -448,12 +448,12 @@ virSecurityMoveRememberedLabel(const char *name, const char *src, const char *dst) { - VIR_AUTOFREE(char *) ref_name = NULL; - VIR_AUTOFREE(char *) ref_value = NULL; - VIR_AUTOFREE(char *) attr_name = NULL; - VIR_AUTOFREE(char *) attr_value = NULL; - VIR_AUTOFREE(char *) timestamp_name = NULL; - VIR_AUTOFREE(char *) timestamp_value = NULL; + g_autofree char *ref_name = NULL; + g_autofree char *ref_value = NULL; + g_autofree char *attr_name = NULL; + g_autofree char *attr_value = NULL; + g_autofree char *timestamp_name = NULL; + g_autofree char *timestamp_value = NULL; if (!(ref_name = virSecurityGetRefCountAttrName(name)) || !(attr_name = virSecurityGetAttrName(name)) || diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index 6ab5844235..e9f6663e6d 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -87,7 +87,7 @@ virStorageDriverLoadBackendModule(const char *name, const char *regfunc, bool forceload) { - VIR_AUTOFREE(char *) modfile = NULL; + g_autofree char *modfile = NULL; if (!(modfile = virFileFindResourceFull(name, "libvirt_storage_backend_", diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c index 5bf704bcc8..742539036c 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -58,7 +58,7 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr pool, virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool); char *tmp, *partname; bool addVol = false; - VIR_AUTOFREE(char *) devpath = NULL; + g_autofree char *devpath = NULL; /* Prepended path will be same for all partitions, so we can * strip the path to form a reasonable pool-unique name @@ -359,7 +359,7 @@ virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool, .pool = pool, .vol = vol, }; - VIR_AUTOFREE(char *) parthelper_path = NULL; + g_autofree char *parthelper_path = NULL; VIR_AUTOPTR(virCommand) cmd = NULL; if (!(parthelper_path = virFileFindResource("libvirt_parthelper", @@ -413,7 +413,7 @@ static int virStorageBackendDiskReadGeometry(virStoragePoolObjPtr pool) { virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool); - VIR_AUTOFREE(char *) parthelper_path = NULL; + g_autofree char *parthelper_path = NULL; VIR_AUTOPTR(virCommand) cmd = NULL; if (!(parthelper_path = virFileFindResource("libvirt_parthelper", @@ -773,7 +773,7 @@ virStorageBackendDiskDeleteVol(virStoragePoolObjPtr pool, char *src_path = def->source.devices[0].path; char *srcname = last_component(src_path); bool isDevMapperDevice; - VIR_AUTOFREE(char *) devpath = NULL; + g_autofree char *devpath = NULL; VIR_AUTOPTR(virCommand) cmd = NULL; virCheckFlags(0, -1); @@ -855,7 +855,7 @@ virStorageBackendDiskCreateVol(virStoragePoolObjPtr pool, unsigned long long startOffset = 0, endOffset = 0; virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool); virErrorPtr save_err; - VIR_AUTOFREE(char *)partFormat = NULL; + g_autofree char *partFormat = NULL; VIR_AUTOPTR(virCommand) cmd = NULL; cmd = virCommandNewArgList(PARTED, diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c index ed677058ed..132b7e721f 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -249,7 +249,7 @@ virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool) struct mntent ent; char buf[1024]; int rc1, rc2; - VIR_AUTOFREE(char *) src = NULL; + g_autofree char *src = NULL; if ((mtab = fopen(_PATH_MOUNTED, "r")) == NULL) { virReportSystemError(errno, @@ -298,7 +298,7 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool) { virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool); int rc; - VIR_AUTOFREE(char *) src = NULL; + g_autofree char *src = NULL; VIR_AUTOPTR(virCommand) cmd = NULL; if (virStorageBackendFileSystemIsValid(pool) < 0) @@ -576,7 +576,7 @@ virStoragePoolDefFSNamespaceParse(xmlXPathContextPtr ctxt, int nnodes; size_t i; int ret = -1; - VIR_AUTOFREE(xmlNodePtr *)nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; nnodes = virXPathNodeSet("./fs:mount_opts/fs:option", ctxt, &nodes); if (nnodes < 0) diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c index 5955d834d9..7fb4e1ef8e 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -127,7 +127,7 @@ virStorageBackendGlusterOpen(virStoragePoolObjPtr pool) if (glfs_set_volfile_server(ret->vol, "tcp", ret->uri->server, ret->uri->port) < 0 || glfs_init(ret->vol) < 0) { - VIR_AUTOFREE(char *) uri = NULL; + g_autofree char *uri = NULL; uri = virURIFormat(ret->uri); virReportSystemError(errno, _("failed to connect to %s"), NULLSTR(uri)); goto error; @@ -186,7 +186,7 @@ virStorageBackendGlusterSetMetadata(virStorageBackendGlusterStatePtr state, const char *name) { char *tmp; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; VIR_FREE(vol->key); VIR_FREE(vol->target.path); @@ -240,7 +240,7 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state, int backingFormat; VIR_AUTOPTR(virStorageVolDef) vol = NULL; VIR_AUTOUNREF(virStorageSourcePtr) meta = NULL; - VIR_AUTOFREE(char *) header = NULL; + g_autofree char *header = NULL; *volptr = NULL; diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c index 06f815625f..eba9c4790f 100644 --- a/src/storage/storage_backend_iscsi.c +++ b/src/storage/storage_backend_iscsi.c @@ -131,7 +131,7 @@ virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool, const char *session) { uint32_t host; - VIR_AUTOFREE(char *) sysfs_path = NULL; + g_autofree char *sysfs_path = NULL; if (virAsprintf(&sysfs_path, "/sys/class/iscsi_session/session%s/device", session) < 0) @@ -160,7 +160,7 @@ virStorageBackendISCSIFindPoolSources(const char *srcSpec, .nsources = 0, .sources = NULL }; - VIR_AUTOFREE(char *) portal = NULL; + g_autofree char *portal = NULL; VIR_AUTOPTR(virStoragePoolSource) source = NULL; virCheckFlags(0, NULL); @@ -228,7 +228,7 @@ virStorageBackendISCSICheckPool(virStoragePoolObjPtr pool, { virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool); int ret = -1; - VIR_AUTOFREE(char *) session = NULL; + g_autofree char *session = NULL; *isActive = false; @@ -320,8 +320,8 @@ static int virStorageBackendISCSIStartPool(virStoragePoolObjPtr pool) { virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool); - VIR_AUTOFREE(char *) portal = NULL; - VIR_AUTOFREE(char *) session = NULL; + g_autofree char *portal = NULL; + g_autofree char *session = NULL; if (def->source.nhost != 1) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -366,7 +366,7 @@ static int virStorageBackendISCSIRefreshPool(virStoragePoolObjPtr pool) { virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool); - VIR_AUTOFREE(char *) session = NULL; + g_autofree char *session = NULL; def->allocation = def->capacity = def->available = 0; @@ -385,8 +385,8 @@ static int virStorageBackendISCSIStopPool(virStoragePoolObjPtr pool) { virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool); - VIR_AUTOFREE(char *) portal = NULL; - VIR_AUTOFREE(char *) session = NULL; + g_autofree char *portal = NULL; + g_autofree char *session = NULL; if ((session = virStorageBackendISCSISession(pool, true)) == NULL) return 0; diff --git a/src/storage/storage_backend_iscsi_direct.c b/src/storage/storage_backend_iscsi_direct.c index deb02a7173..9d8f7d9ed2 100644 --- a/src/storage/storage_backend_iscsi_direct.c +++ b/src/storage/storage_backend_iscsi_direct.c @@ -423,7 +423,7 @@ virISCSIDirectUpdateTargets(struct iscsi_context *iscsi, } for (tmp_addr = addr; tmp_addr; tmp_addr = tmp_addr->next) { - VIR_AUTOFREE(char *) target = NULL; + g_autofree char *target = NULL; if (VIR_STRDUP(target, tmp_addr->target_name) < 0) goto cleanup; @@ -490,7 +490,7 @@ virStorageBackendISCSIDirectFindPoolSources(const char *srcSpec, .nsources = 0, .sources = NULL }; - VIR_AUTOFREE(char *) portal = NULL; + g_autofree char *portal = NULL; VIR_AUTOPTR(virStoragePoolSource) source = NULL; virCheckFlags(0, NULL); @@ -560,7 +560,7 @@ virStorageBackendISCSIDirectSetConnection(virStoragePoolObjPtr pool, { virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool); struct iscsi_context *iscsi = NULL; - VIR_AUTOFREE(char *) portal = NULL; + g_autofree char *portal = NULL; if (!(iscsi = virISCSIDirectCreateContext(def->source.initiator.iqn))) goto error; @@ -590,7 +590,7 @@ virStorageBackendISCSIDirectRefreshPool(virStoragePoolObjPtr pool) { struct iscsi_context *iscsi = NULL; int ret = -1; - VIR_AUTOFREE(char *) portal = NULL; + g_autofree char *portal = NULL; if (!(iscsi = virStorageBackendISCSIDirectSetConnection(pool, &portal))) return -1; @@ -626,7 +626,7 @@ virStorageBackendISCSIDirectVolWipeZero(virStorageVolDefPtr vol, struct scsi_task *task = NULL; int lun = 0; int ret = -1; - VIR_AUTOFREE(unsigned char *) data = NULL; + g_autofree unsigned char *data = NULL; if (virStorageBackendISCSIDirectGetLun(vol, &lun) < 0) return ret; diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c index 6e468b3579..784e238ba7 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -128,9 +128,9 @@ virStorageBackendLogicalParseVolExtents(virStorageVolDefPtr vol, int err, nvars; unsigned long long offset, size, length; virStorageVolSourceExtent extent; - VIR_AUTOFREE(char *) regex = NULL; - VIR_AUTOFREE(regex_t *) reg = NULL; - VIR_AUTOFREE(regmatch_t *) vars = NULL; + g_autofree char *regex = NULL; + g_autofree regex_t *reg = NULL; + g_autofree regmatch_t *vars = NULL; memset(&extent, 0, sizeof(extent)); @@ -208,7 +208,7 @@ virStorageBackendLogicalParseVolExtents(virStorageVolDefPtr vol, for (i = 0; i < nextents; i++) { size_t j; int len; - VIR_AUTOFREE(char *) offset_str = NULL; + g_autofree char *offset_str = NULL; j = (i * 2) + 1; len = vars[j].rm_eo - vars[j].rm_so; @@ -463,8 +463,8 @@ virStorageBackendLogicalFindPoolSourcesFunc(char **const groups, size_t i; virStoragePoolSourceDevicePtr dev; virStoragePoolSource *thisSource; - VIR_AUTOFREE(char *) pvname = NULL; - VIR_AUTOFREE(char *) vgname = NULL; + g_autofree char *pvname = NULL; + g_autofree char *vgname = NULL; if (VIR_STRDUP(pvname, groups[0]) < 0 || VIR_STRDUP(vgname, groups[1]) < 0) diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_backend_mpath.c index 4d41ea1107..cbd544b038 100644 --- a/src/storage/storage_backend_mpath.c +++ b/src/storage/storage_backend_mpath.c @@ -156,7 +156,7 @@ virStorageBackendCreateVols(virStoragePoolObjPtr pool, int is_mpath = 0; uint32_t minor = -1; uint32_t next; - VIR_AUTOFREE(char *) map_device = NULL; + g_autofree char *map_device = NULL; do { is_mpath = virStorageBackendIsMultipath(names->name); diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c index 4f4ade9d15..8b62969219 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -85,7 +85,7 @@ virStoragePoolDefRBDNamespaceParse(xmlXPathContextPtr ctxt, int nnodes; size_t i; int ret = -1; - VIR_AUTOFREE(xmlNodePtr *)nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; nnodes = virXPathNodeSet("./rbd:config_opts/rbd:option", ctxt, &nodes); if (nnodes < 0) @@ -198,7 +198,7 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr, const char *osd_op_timeout = "30"; const char *rbd_default_format = "2"; virConnectPtr conn = NULL; - VIR_AUTOFREE(char *) mon_buff = NULL; + g_autofree char *mon_buff = NULL; if (authdef) { VIR_DEBUG("Using cephx authorization, username: %s", authdef->username); @@ -637,7 +637,7 @@ virStorageBackendRBDGetVolNames(virStorageBackendRBDStatePtr ptr) size_t nnames = 0; int rc; size_t max_size = 1024; - VIR_AUTOFREE(char *) namebuf = NULL; + g_autofree char *namebuf = NULL; const char *name; while (true) { @@ -655,7 +655,7 @@ virStorageBackendRBDGetVolNames(virStorageBackendRBDStatePtr ptr) } for (name = namebuf; name < namebuf + max_size;) { - VIR_AUTOFREE(char *) namedup = NULL; + g_autofree char *namedup = NULL; if (STREQ(name, "")) break; @@ -772,7 +772,7 @@ virStorageBackendRBDCleanupSnapshots(rados_ioctx_t ioctx, int snap_count, protected; size_t i; rbd_image_t image = NULL; - VIR_AUTOFREE(rbd_snap_info_t *) snaps = NULL; + g_autofree rbd_snap_info_t *snaps = NULL; if ((r = rbd_open(ioctx, vol->name, &image, NULL)) < 0) { virReportSystemError(-r, _("failed to open the RBD image '%s'"), @@ -1042,7 +1042,7 @@ virStorageBackendRBDSnapshotFindNoDiff(rbd_image_t image, size_t i; int diff; rbd_image_info_t info; - VIR_AUTOFREE(rbd_snap_info_t *) snaps = NULL; + g_autofree rbd_snap_info_t *snaps = NULL; if ((r = rbd_stat(image, &info, sizeof(info))) < 0) { virReportSystemError(-r, _("failed to stat the RBD image %s"), @@ -1189,7 +1189,7 @@ virStorageBackendRBDCloneImage(rados_ioctx_t io, uint64_t stripe_unit; virBuffer snapname = VIR_BUFFER_INITIALIZER; rbd_image_t image = NULL; - VIR_AUTOFREE(char *) snapname_buff = NULL; + g_autofree char *snapname_buff = NULL; if ((r = rbd_open(io, origvol, &image, NULL)) < 0) { virReportSystemError(-r, _("failed to open the RBD image %s"), @@ -1362,7 +1362,7 @@ virStorageBackendRBDVolWipeZero(rbd_image_t image, int r = -1; unsigned long long offset = 0; unsigned long long length; - VIR_AUTOFREE(char *) writebuf = NULL; + g_autofree char *writebuf = NULL; if (VIR_ALLOC_N(writebuf, info->obj_size * stripe_count) < 0) return -1; diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c index 1c27fc74f6..14bf1352a6 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -56,7 +56,7 @@ static int virStorageBackendSCSITriggerRescan(uint32_t host) { VIR_AUTOCLOSE fd = -1; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; VIR_DEBUG("Triggering rescan of host %d", host); @@ -238,8 +238,8 @@ checkParent(const char *name, unsigned int host_num; bool retval = false; virConnectPtr conn = NULL; - VIR_AUTOFREE(char *) scsi_host_name = NULL; - VIR_AUTOFREE(char *) vhba_parent = NULL; + g_autofree char *scsi_host_name = NULL; + g_autofree char *vhba_parent = NULL; VIR_DEBUG("name=%s, parent_name=%s", name, parent_name); @@ -290,7 +290,7 @@ createVport(virStoragePoolDefPtr def, { virStoragePoolFCRefreshInfoPtr cbdata = NULL; virThread thread; - VIR_AUTOFREE(char *) name = NULL; + g_autofree char *name = NULL; VIR_DEBUG("configFile='%s' parent='%s', wwnn='%s' wwpn='%s'", NULLSTR(configFile), NULLSTR(fchost->parent), @@ -355,8 +355,8 @@ virStorageBackendSCSICheckPool(virStoragePoolObjPtr pool, { virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool); unsigned int host; - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(char *) name = NULL; + g_autofree char *path = NULL; + g_autofree char *name = NULL; *isActive = false; @@ -390,7 +390,7 @@ virStorageBackendSCSIRefreshPool(virStoragePoolObjPtr pool) { virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool); unsigned int host; - VIR_AUTOFREE(char *) name = NULL; + g_autofree char *name = NULL; def->allocation = def->capacity = def->available = 0; diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c index 6df90937c2..25183d0d2f 100644 --- a/src/storage/storage_backend_sheepdog.c +++ b/src/storage/storage_backend_sheepdog.c @@ -137,7 +137,7 @@ static int virStorageBackendSheepdogRefreshAllVol(virStoragePoolObjPtr pool) { size_t i; - VIR_AUTOFREE(char *) output = NULL; + g_autofree char *output = NULL; VIR_AUTOSTRINGLIST lines = NULL; VIR_AUTOSTRINGLIST cells = NULL; VIR_AUTOPTR(virCommand) cmd = NULL; @@ -176,7 +176,7 @@ virStorageBackendSheepdogRefreshAllVol(virStoragePoolObjPtr pool) static int virStorageBackendSheepdogRefreshPool(virStoragePoolObjPtr pool) { - VIR_AUTOFREE(char *) output = NULL; + g_autofree char *output = NULL; VIR_AUTOPTR(virCommand) cmd = NULL; cmd = virCommandNewArgList(SHEEPDOGCLI, "node", "info", "-r", NULL); diff --git a/src/storage/storage_backend_vstorage.c b/src/storage/storage_backend_vstorage.c index cec21dccbf..ee944c18e1 100644 --- a/src/storage/storage_backend_vstorage.c +++ b/src/storage/storage_backend_vstorage.c @@ -38,9 +38,9 @@ static int virStorageBackendVzPoolStart(virStoragePoolObjPtr pool) { virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool); - VIR_AUTOFREE(char *) grp_name = NULL; - VIR_AUTOFREE(char *) usr_name = NULL; - VIR_AUTOFREE(char *) mode = NULL; + g_autofree char *grp_name = NULL; + g_autofree char *usr_name = NULL; + g_autofree char *mode = NULL; VIR_AUTOPTR(virCommand) cmd = NULL; int ret; @@ -88,7 +88,7 @@ virStorageBackendVzIsMounted(virStoragePoolObjPtr pool) FILE *mtab; struct mntent ent; char buf[1024]; - VIR_AUTOFREE(char *) cluster = NULL; + g_autofree char *cluster = NULL; if (virAsprintf(&cluster, "vstorage://%s", def->source.name) < 0) return -1; diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backend_zfs.c index 354d65d8c3..5a417119f3 100644 --- a/src/storage/storage_backend_zfs.c +++ b/src/storage/storage_backend_zfs.c @@ -52,7 +52,7 @@ static int virStorageBackendZFSVolModeNeeded(void) { int ret = -1, exit_code = -1; - VIR_AUTOFREE(char *) error = NULL; + g_autofree char *error = NULL; VIR_AUTOPTR(virCommand) cmd = NULL; /* 'zfs get' without arguments prints out @@ -85,7 +85,7 @@ virStorageBackendZFSCheckPool(virStoragePoolObjPtr pool G_GNUC_UNUSED, bool *isActive) { virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool); - VIR_AUTOFREE(char *) devpath = NULL; + g_autofree char *devpath = NULL; if (virAsprintf(&devpath, "/dev/zvol/%s", def->source.name) < 0) @@ -179,7 +179,7 @@ virStorageBackendZFSFindVols(virStoragePoolObjPtr pool, size_t i; VIR_AUTOSTRINGLIST lines = NULL; VIR_AUTOPTR(virCommand) cmd = NULL; - VIR_AUTOFREE(char *) volumes_list = NULL; + g_autofree char *volumes_list = NULL; /** * $ zfs list -Hp -t volume -o name,volsize -r test diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 6516b0943d..af3b04fbf4 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -137,7 +137,7 @@ storagePoolUpdateStateCallback(virStoragePoolObjPtr obj, virStoragePoolDefPtr def = virStoragePoolObjGetDef(obj); bool active = false; virStorageBackendPtr backend; - VIR_AUTOFREE(char *) stateFile = NULL; + g_autofree char *stateFile = NULL; if ((backend = virStorageBackendForType(def->type)) == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -215,7 +215,7 @@ storageDriverAutostartCallback(virStoragePoolObjPtr obj, } if (started) { - VIR_AUTOFREE(char *) stateFile = NULL; + g_autofree char *stateFile = NULL; stateFile = virFileBuildPath(driver->stateDir, def->name, ".xml"); if (!stateFile || @@ -256,8 +256,8 @@ storageStateInitialize(bool privileged, virStateInhibitCallback callback G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED) { - VIR_AUTOFREE(char *) configdir = NULL; - VIR_AUTOFREE(char *) rundir = NULL; + g_autofree char *configdir = NULL; + g_autofree char *rundir = NULL; bool autostart = true; if (VIR_ALLOC(driver) < 0) @@ -739,7 +739,7 @@ storagePoolCreateXML(virConnectPtr conn, virObjectEventPtr event = NULL; unsigned int build_flags = 0; VIR_AUTOPTR(virStoragePoolDef) newDef = NULL; - VIR_AUTOFREE(char *) stateFile = NULL; + g_autofree char *stateFile = NULL; virCheckFlags(VIR_STORAGE_POOL_CREATE_WITH_BUILD | VIR_STORAGE_POOL_CREATE_WITH_BUILD_OVERWRITE | @@ -939,7 +939,7 @@ storagePoolCreate(virStoragePoolPtr pool, virObjectEventPtr event = NULL; int ret = -1; unsigned int build_flags = 0; - VIR_AUTOFREE(char *) stateFile = NULL; + g_autofree char *stateFile = NULL; bool restoreStarting = false; virCheckFlags(VIR_STORAGE_POOL_CREATE_WITH_BUILD | @@ -1091,7 +1091,7 @@ storagePoolDestroy(virStoragePoolPtr pool) virStorageBackendPtr backend; virObjectEventPtr event = NULL; int ret = -1; - VIR_AUTOFREE(char *) stateFile = NULL; + g_autofree char *stateFile = NULL; if (!(obj = storagePoolObjFindByUUID(pool->uuid, pool->name))) goto cleanup; @@ -1162,7 +1162,7 @@ storagePoolDelete(virStoragePoolPtr pool, virStorageBackendPtr backend; virObjectEventPtr event = NULL; int ret = -1; - VIR_AUTOFREE(char *) stateFile = NULL; + g_autofree char *stateFile = NULL; if (!(obj = virStoragePoolObjFromStoragePool(pool))) return -1; @@ -1231,7 +1231,7 @@ storagePoolRefresh(virStoragePoolPtr pool, virStoragePoolObjPtr obj; virStoragePoolDefPtr def; virStorageBackendPtr backend; - VIR_AUTOFREE(char *) stateFile = NULL; + g_autofree char *stateFile = NULL; int ret = -1; virObjectEventPtr event = NULL; @@ -1632,7 +1632,7 @@ storageVolLookupByPathCallback(virStoragePoolObjPtr obj, { struct storageVolLookupData *data = (struct storageVolLookupData *)opaque; virStoragePoolDefPtr def; - VIR_AUTOFREE(char *) stable_path = NULL; + g_autofree char *stable_path = NULL; if (!virStoragePoolObjIsActive(obj)) return false; @@ -1740,7 +1740,7 @@ storagePoolLookupByTargetPath(virConnectPtr conn, virStoragePoolObjPtr obj; virStoragePoolDefPtr def; virStoragePoolPtr pool = NULL; - VIR_AUTOFREE(char *) cleanpath = NULL; + g_autofree char *cleanpath = NULL; cleanpath = virFileSanitizePath(path); if (!cleanpath) @@ -2296,8 +2296,8 @@ static int virStorageBackendPloopRestoreDesc(char *path) { VIR_AUTOPTR(virCommand) cmd = NULL; - VIR_AUTOFREE(char *) refresh_tool = NULL; - VIR_AUTOFREE(char *) desc = NULL; + g_autofree char *refresh_tool = NULL; + g_autofree char *desc = NULL; if (virAsprintf(&desc, "%s/DiskDescriptor.xml", path) < 0) return -1; diff --git a/src/storage/storage_file_gluster.c b/src/storage/storage_file_gluster.c index 7c2189d297..babb8fbe94 100644 --- a/src/storage/storage_file_gluster.c +++ b/src/storage/storage_file_gluster.c @@ -261,7 +261,7 @@ virStorageFileBackendGlusterReadlinkCallback(const char *path, size_t bufsiz = 0; ssize_t ret; struct stat st; - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *buf = NULL; *linkpath = NULL; @@ -301,7 +301,7 @@ static const char * virStorageFileBackendGlusterGetUniqueIdentifier(virStorageSourcePtr src) { virStorageFileBackendGlusterPrivPtr priv = src->drv->priv; - VIR_AUTOFREE(char *) filePath = NULL; + g_autofree char *filePath = NULL; if (priv->canonpath) return priv->canonpath; diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 83e93253e4..6a99387597 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -136,8 +136,8 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol, int wbytes = 0; int interval; struct stat st; - VIR_AUTOFREE(char *) zerobuf = NULL; - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *zerobuf = NULL; + g_autofree char *buf = NULL; VIR_AUTOCLOSE inputfd = -1; if ((inputfd = open(inputvol->target.path, O_RDONLY)) < 0) { @@ -599,7 +599,7 @@ storageBackendCreatePloop(virStoragePoolObjPtr pool G_GNUC_UNUSED, int ret = -1; bool created = false; VIR_AUTOPTR(virCommand) cmd = NULL; - VIR_AUTOFREE(char *) create_tool = NULL; + g_autofree char *create_tool = NULL; virCheckFlags(0, -1); @@ -668,7 +668,7 @@ storagePloopResize(virStorageVolDefPtr vol, unsigned long long capacity) { VIR_AUTOPTR(virCommand) cmd = NULL; - VIR_AUTOFREE(char *) resize_tool = NULL; + g_autofree char *resize_tool = NULL; resize_tool = virFindFileInPath("ploop"); if (!resize_tool) { @@ -857,7 +857,7 @@ storageBackendCreateQemuImgSetBacking(virStoragePoolObjPtr pool, { virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool); int accessRetCode = -1; - VIR_AUTOFREE(char *) absolutePath = NULL; + g_autofree char *absolutePath = NULL; if (info->format == VIR_STORAGE_FILE_RAW) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -919,7 +919,7 @@ storageBackendCreateQemuImgSetOptions(virCommandPtr cmd, virStorageEncryptionInfoDefPtr encinfo, struct _virStorageBackendQemuImgInfo *info) { - VIR_AUTOFREE(char *) opts = NULL; + g_autofree char *opts = NULL; if (storageBackendCreateQemuImgOpts(encinfo, &opts, info) < 0) return -1; @@ -941,7 +941,7 @@ storageBackendCreateQemuImgSecretObject(virCommandPtr cmd, const char *secretAlias) { virBuffer buf = VIR_BUFFER_INITIALIZER; - VIR_AUTOFREE(char *) commandStr = NULL; + g_autofree char *commandStr = NULL; virBufferAsprintf(&buf, "secret,id=%s,file=", secretAlias); virQEMUBuildBufferEscapeComma(&buf, secretPath); @@ -970,7 +970,7 @@ storageBackendResizeQemuImgImageOpts(virCommandPtr cmd, const char *secretAlias) { virBuffer buf = VIR_BUFFER_INITIALIZER; - VIR_AUTOFREE(char *) commandStr = NULL; + g_autofree char *commandStr = NULL; virBufferAsprintf(&buf, "driver=luks,key-secret=%s,file.filename=", secretAlias); @@ -1092,7 +1092,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool, virStorageEncryptionPtr enc = vol->target.encryption; virStorageEncryptionPtr inputenc = inputvol ? inputvol->target.encryption : NULL; virStorageEncryptionInfoDefPtr encinfo = NULL; - VIR_AUTOFREE(char *) inputSecretAlias = NULL; + g_autofree char *inputSecretAlias = NULL; virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, NULL); @@ -1306,9 +1306,9 @@ storageBackendCreateQemuImg(virStoragePoolObjPtr pool, { int ret = -1; virStorageVolEncryptConvertStep convertStep = VIR_STORAGE_VOL_ENCRYPT_NONE; - VIR_AUTOFREE(char *) create_tool = NULL; - VIR_AUTOFREE(char *) secretPath = NULL; - VIR_AUTOFREE(char *) inputSecretPath = NULL; + g_autofree char *create_tool = NULL; + g_autofree char *secretPath = NULL; + g_autofree char *inputSecretPath = NULL; virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, -1); @@ -1680,8 +1680,8 @@ virStorageBackendVolOpen(const char *path, struct stat *sb, static bool storageBackendIsPloopDir(char *path) { - VIR_AUTOFREE(char *) root = NULL; - VIR_AUTOFREE(char *) desc = NULL; + g_autofree char *root = NULL; + g_autofree char *desc = NULL; if (virAsprintf(&root, "%s/root.hds", path) < 0) return false; @@ -1704,7 +1704,7 @@ static int storageBackendRedoPloopUpdate(virStorageSourcePtr target, struct stat *sb, int *fd, unsigned int flags) { - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; if (virAsprintf(&path, "%s/root.hds", target->path) < 0) return -1; @@ -1738,7 +1738,7 @@ storageBackendUpdateVolTargetInfo(virStorageVolType voltype, int rc; struct stat sb; ssize_t len = VIR_STORAGE_MAX_HEADER; - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *buf = NULL; VIR_AUTOCLOSE fd = -1; if ((rc = virStorageBackendVolOpen(target->path, &sb, openflags)) < 0) @@ -2262,9 +2262,9 @@ storageBackendResizeQemuImg(virStoragePoolObjPtr pool, const char *type; virStorageEncryptionPtr enc = vol->target.encryption; VIR_AUTOPTR(virCommand) cmd = NULL; - VIR_AUTOFREE(char *) img_tool = NULL; - VIR_AUTOFREE(char *) secretPath = NULL; - VIR_AUTOFREE(char *) secretAlias = NULL; + g_autofree char *img_tool = NULL; + g_autofree char *secretPath = NULL; + g_autofree char *secretAlias = NULL; if (enc && (enc->format == VIR_STORAGE_ENCRYPTION_FORMAT_QCOW || enc->format == VIR_STORAGE_ENCRYPTION_FORMAT_DEFAULT) && @@ -2382,7 +2382,7 @@ storageBackendPloopHasSnapshots(char *path) { char *snap_tool = NULL; VIR_AUTOPTR(virCommand) cmd = NULL; - VIR_AUTOFREE(char *) output = NULL; + g_autofree char *output = NULL; snap_tool = virFindFileInPath("ploop"); if (!snap_tool) { @@ -2417,7 +2417,7 @@ virStorageBackendVolUploadLocal(virStoragePoolObjPtr pool G_GNUC_UNUSED, char *target_path = vol->target.path; int has_snap = 0; bool sparse = flags & VIR_STORAGE_VOL_UPLOAD_SPARSE_STREAM; - VIR_AUTOFREE(char *)path = NULL; + g_autofree char *path = NULL; virCheckFlags(VIR_STORAGE_VOL_UPLOAD_SPARSE_STREAM, -1); /* if volume has target format VIR_STORAGE_FILE_PLOOP @@ -2458,7 +2458,7 @@ virStorageBackendVolDownloadLocal(virStoragePoolObjPtr pool G_GNUC_UNUSED, char *target_path = vol->target.path; int has_snap = 0; bool sparse = flags & VIR_STORAGE_VOL_DOWNLOAD_SPARSE_STREAM; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; virCheckFlags(VIR_STORAGE_VOL_DOWNLOAD_SPARSE_STREAM, -1); if (vol->target.format == VIR_STORAGE_FILE_PLOOP) { @@ -2531,7 +2531,7 @@ storageBackendWipeLocal(const char *path, unsigned long long remaining = 0; off_t size; size_t write_size = 0; - VIR_AUTOFREE(char *) writebuf = NULL; + g_autofree char *writebuf = NULL; if (VIR_ALLOC_N(writebuf, writebuf_length) < 0) return -1; @@ -2673,9 +2673,9 @@ storageBackendVolWipePloop(virStorageVolDefPtr vol, unsigned int algorithm) { VIR_AUTOPTR(virCommand) cmd = NULL; - VIR_AUTOFREE(char *) target_path = NULL; - VIR_AUTOFREE(char *) disk_desc = NULL; - VIR_AUTOFREE(char *) create_tool = NULL; + g_autofree char *target_path = NULL; + g_autofree char *disk_desc = NULL; + g_autofree char *create_tool = NULL; create_tool = virFindFileInPath("ploop"); if (!create_tool) { @@ -2755,7 +2755,7 @@ virStorageBackendBuildLocal(virStoragePoolObjPtr pool) mode_t mode; bool needs_create_as_uid; unsigned int dir_create_flags; - VIR_AUTOFREE(char *) parent = NULL; + g_autofree char *parent = NULL; if (VIR_STRDUP(parent, def->target.path) < 0) return -1; @@ -2839,8 +2839,8 @@ virStorageUtilGlusterExtractPoolSources(const char *host, size_t i; int nnodes; int ret = -1; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; - VIR_AUTOFREE(char *) volname = NULL; + g_autofree xmlNodePtr *nodes = NULL; + g_autofree char *volname = NULL; if (!(doc = virXMLParseStringCtxt(xml, _("(gluster_cli_output)"), &ctxt))) goto cleanup; @@ -2914,8 +2914,8 @@ virStorageBackendFindGlusterPoolSources(const char *host, { int rc; VIR_AUTOPTR(virCommand) cmd = NULL; - VIR_AUTOFREE(char *) glusterpath = NULL; - VIR_AUTOFREE(char *) outbuf = NULL; + g_autofree char *glusterpath = NULL; + g_autofree char *outbuf = NULL; if (!(glusterpath = virFindFileInPath("gluster"))) { if (report) { @@ -3182,8 +3182,8 @@ virStorageBackendPARTEDFindLabel(const char *device, char *start, *end; int ret = VIR_STORAGE_PARTED_ERROR; VIR_AUTOPTR(virCommand) cmd = NULL; - VIR_AUTOFREE(char *) output = NULL; - VIR_AUTOFREE(char *) error = NULL; + g_autofree char *output = NULL; + g_autofree char *error = NULL; cmd = virCommandNew(PARTED); virCommandAddArgSet(cmd, args); @@ -3667,7 +3667,7 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool, virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool); int retval = -1; VIR_AUTOPTR(virStorageVolDef) vol = NULL; - VIR_AUTOFREE(char *) devpath = NULL; + g_autofree char *devpath = NULL; /* Check if the pool is using a stable target path. The call to * virStorageBackendStablePath will fail if the pool target path @@ -3757,7 +3757,7 @@ getNewStyleBlockDevice(const char *lun_path, struct dirent *block_dirent = NULL; int retval = -1; int direrr; - VIR_AUTOFREE(char *) block_path = NULL; + g_autofree char *block_path = NULL; if (virAsprintf(&block_path, "%s/block", lun_path) < 0) goto cleanup; @@ -3836,7 +3836,7 @@ getBlockDevice(uint32_t host, struct dirent *lun_dirent = NULL; int retval = -1; int direrr; - VIR_AUTOFREE(char *) lun_path = NULL; + g_autofree char *lun_path = NULL; *block_device = NULL; @@ -3892,7 +3892,7 @@ getDeviceType(uint32_t host, char typestr[3]; char *gottype, *p; FILE *typefile; - VIR_AUTOFREE(char *) type_path = NULL; + g_autofree char *type_path = NULL; if (virAsprintf(&type_path, "/sys/bus/scsi/devices/%u:%u:%u:%u/type", host, bus, target, lun) < 0) @@ -3953,7 +3953,7 @@ processLU(virStoragePoolObjPtr pool, { int retval = -1; int device_type; - VIR_AUTOFREE(char *) block_device = NULL; + g_autofree char *block_device = NULL; VIR_DEBUG("Processing LU %u:%u:%u:%u", host, bus, target, lun); @@ -4107,7 +4107,7 @@ virStorageBackendFileSystemMountAddOptions(virCommandPtr cmd, virStoragePoolDefPtr def, const char *providedOpts) { - VIR_AUTOFREE(char *) mountOpts = NULL; + g_autofree char *mountOpts = NULL; virBuffer buf = VIR_BUFFER_INITIALIZER; if (*default_mount_opts != '\0') @@ -4206,7 +4206,7 @@ virStorageBackendFileSystemMountCmd(const char *cmdstr, bool cifsfs = (def->type == VIR_STORAGE_POOL_NETFS && def->source.format == VIR_STORAGE_POOL_NETFS_CIFS); virCommandPtr cmd = NULL; - VIR_AUTOFREE(char *) nfsVers = NULL; + g_autofree char *nfsVers = NULL; if (def->type == VIR_STORAGE_POOL_NETFS && def->source.protocolVer > 0 && virAsprintf(&nfsVers, "nfsvers=%u", def->source.protocolVer) < 0) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 338d459e14..237bcb9c7e 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -202,7 +202,7 @@ testDomainDefNamespaceParse(xmlXPathContextPtr ctxt, int tmp, n; size_t i; unsigned int tmpuint; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; if (VIR_ALLOC(nsdata) < 0) return -1; @@ -753,7 +753,7 @@ testParseXMLDocFromFile(xmlNodePtr node, const char *file, const char *type) xmlNodePtr ret = NULL; xmlDocPtr doc = NULL; char *absFile = NULL; - VIR_AUTOFREE(char *) relFile = NULL; + g_autofree char *relFile = NULL; if ((relFile = virXMLPropString(node, "file"))) { absFile = testBuildFilename(file, relFile); @@ -787,7 +787,7 @@ testParseNodeInfo(virNodeInfoPtr nodeInfo, xmlXPathContextPtr ctxt) { long l; int ret; - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; ret = virXPathLong("string(/node/cpu/nodes[1])", ctxt, &l); if (ret == 0) { @@ -935,7 +935,7 @@ testParseDomains(testDriverPtr privconn, int num, ret = -1; size_t i; virDomainObjPtr obj = NULL; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; num = virXPathNodeSet("/node/domain", ctxt, &nodes); if (num < 0) @@ -997,7 +997,7 @@ testParseNetworks(testDriverPtr privconn, int num; size_t i; virNetworkObjPtr obj; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; num = virXPathNodeSet("/node/network", ctxt, &nodes); if (num < 0) @@ -1034,7 +1034,7 @@ testParseInterfaces(testDriverPtr privconn, int num; size_t i; virInterfaceObjPtr obj; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; num = virXPathNodeSet("/node/interface", ctxt, &nodes); if (num < 0) @@ -1073,8 +1073,8 @@ testOpenVolumesForPool(const char *file, virStoragePoolDefPtr def = virStoragePoolObjGetDef(obj); size_t i; int num; - VIR_AUTOFREE(char *) vol_xpath = NULL; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree char *vol_xpath = NULL; + g_autofree xmlNodePtr *nodes = NULL; VIR_AUTOPTR(virStorageVolDef) volDef = NULL; /* Find storage volumes */ @@ -1123,7 +1123,7 @@ testParseStorage(testDriverPtr privconn, int num; size_t i; virStoragePoolObjPtr obj; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; num = virXPathNodeSet("/node/pool", ctxt, &nodes); if (num < 0) @@ -1172,7 +1172,7 @@ testParseNodedevs(testDriverPtr privconn, int num; size_t i; virNodeDeviceObjPtr obj; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; num = virXPathNodeSet("/node/device", ctxt, &nodes); if (num < 0) @@ -1207,7 +1207,7 @@ testParseAuthUsers(testDriverPtr privconn, { int num; size_t i; - VIR_AUTOFREE(xmlNodePtr *) nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; num = virXPathNodeSet("/node/auth/user", ctxt, &nodes); if (num < 0) @@ -1218,7 +1218,7 @@ testParseAuthUsers(testDriverPtr privconn, return -1; for (i = 0; i < num; i++) { - VIR_AUTOFREE(char *) username = NULL; + g_autofree char *username = NULL; ctxt->node = nodes[i]; username = virXPathString("string(.)", ctxt); @@ -1382,8 +1382,8 @@ testConnectAuthenticate(virConnectPtr conn, testDriverPtr privconn = conn->privateData; int ret = -1; ssize_t i; - VIR_AUTOFREE(char *) username = NULL; - VIR_AUTOFREE(char *) password = NULL; + g_autofree char *username = NULL; + g_autofree char *password = NULL; virObjectLock(privconn); if (privconn->numAuths == 0) { @@ -2182,7 +2182,7 @@ testDomainSaveImageWrite(testDriverPtr driver, { int len; int fd = -1; - VIR_AUTOFREE(char *) xml = NULL; + g_autofree char *xml = NULL; xml = virDomainDefFormat(def, driver->caps, VIR_DOMAIN_DEF_FORMAT_SECURE); @@ -2260,7 +2260,7 @@ testDomainSaveImageOpen(testDriverPtr driver, int fd = -1; int len; virDomainDefPtr def = NULL; - VIR_AUTOFREE(char *) xml = NULL; + g_autofree char *xml = NULL; if ((fd = open(path, O_RDONLY)) < 0) { virReportSystemError(errno, _("cannot read domain image '%s'"), path); @@ -3095,7 +3095,7 @@ testDomainRenameCallback(virDomainObjPtr privdom, virObjectEventPtr event_new = NULL; virObjectEventPtr event_old = NULL; int ret = -1; - VIR_AUTOFREE(char *) new_dom_name = NULL; + g_autofree char *new_dom_name = NULL; virCheckFlags(0, -1); @@ -3412,7 +3412,7 @@ testDomainGetNumaParameters(virDomainPtr dom, virDomainObjPtr vm = NULL; virDomainDefPtr def = NULL; virDomainNumatuneMemMode mode = VIR_DOMAIN_NUMATUNE_MEM_STRICT; - VIR_AUTOFREE(char *) nodeset = NULL; + g_autofree char *nodeset = NULL; int ret = -1; virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | @@ -7435,7 +7435,7 @@ testNodeDeviceMockCreateVport(testDriverPtr driver, virNodeDeviceObjPtr obj = NULL, objcopy = NULL; virNodeDeviceDefPtr objdef; virObjectEventPtr event = NULL; - VIR_AUTOFREE(char *) xml = NULL; + g_autofree char *xml = NULL; /* In the real code, we'd call virVHBAManageVport which would take the * wwnn/wwpn from the input XML in order to call the "vport_create" @@ -7514,8 +7514,8 @@ testNodeDeviceCreateXML(virConnectPtr conn, virNodeDevicePtr dev = NULL, ret = NULL; virNodeDeviceObjPtr obj = NULL; virNodeDeviceDefPtr objdef; - VIR_AUTOFREE(char *) wwnn = NULL; - VIR_AUTOFREE(char *) wwpn = NULL; + g_autofree char *wwnn = NULL; + g_autofree char *wwpn = NULL; virCheckFlags(0, NULL); @@ -7568,8 +7568,8 @@ testNodeDeviceDestroy(virNodeDevicePtr dev) virNodeDeviceObjPtr parentobj = NULL; virNodeDeviceDefPtr def; virObjectEventPtr event = NULL; - VIR_AUTOFREE(char *) wwnn = NULL; - VIR_AUTOFREE(char *) wwpn = NULL; + g_autofree char *wwnn = NULL; + g_autofree char *wwpn = NULL; if (!(obj = testNodeDeviceObjFindByName(driver, dev->name))) return -1; diff --git a/src/util/iohelper.c b/src/util/iohelper.c index 3dc0488b26..a102a95abb 100644 --- a/src/util/iohelper.c +++ b/src/util/iohelper.c @@ -42,7 +42,7 @@ static int runIO(const char *path, int fd, int oflags) { - VIR_AUTOFREE(void *) base = NULL; /* Location to be freed */ + g_autofree void *base = NULL; /* Location to be freed */ char *buf = NULL; /* Aligned location within base */ size_t buflen = 1024*1024; intptr_t alignMask = 64*1024 - 1; diff --git a/src/util/virarptable.c b/src/util/virarptable.c index 47ac1bb9ab..cc676a0200 100644 --- a/src/util/virarptable.c +++ b/src/util/virarptable.c @@ -66,7 +66,7 @@ virArpTableGet(void) { int num = 0; int msglen; - VIR_AUTOFREE(void *) nlData = NULL; + g_autofree void *nlData = NULL; virArpTablePtr table = NULL; struct nlmsghdr* nh; struct rtattr * tb[NDA_MAX+1]; @@ -113,7 +113,7 @@ virArpTableGet(void) continue; if (tb[NDA_DST]) { - VIR_AUTOFREE(char *) ipstr = NULL; + g_autofree char *ipstr = NULL; virSocketAddr virAddr; if (VIR_REALLOC_N(table->t, num + 1) < 0) goto cleanup; diff --git a/src/util/viraudit.c b/src/util/viraudit.c index b54ae1283e..9bf42824f6 100644 --- a/src/util/viraudit.c +++ b/src/util/viraudit.c @@ -96,7 +96,7 @@ void virAuditSend(virLogSourcePtr source, virAuditRecordType type G_GNUC_UNUSED, bool success, const char *fmt, ...) { - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; va_list args; /* Duplicate later checks, to short circuit & avoid printf overhead diff --git a/src/util/virauth.c b/src/util/virauth.c index 9de3996e92..004b2f3a71 100644 --- a/src/util/virauth.c +++ b/src/util/virauth.c @@ -43,7 +43,7 @@ virAuthGetConfigFilePathURI(virURIPtr uri, { size_t i; const char *authenv = getenv("LIBVIRT_AUTH_FILE"); - VIR_AUTOFREE(char *) userdir = NULL; + g_autofree char *userdir = NULL; *path = NULL; @@ -145,7 +145,7 @@ virAuthGetUsernamePath(const char *path, { unsigned int ncred; virConnectCredential cred; - VIR_AUTOFREE(char *) prompt = NULL; + g_autofree char *prompt = NULL; char *ret = NULL; if (virAuthGetCredential(servicename, hostname, "username", path, &ret) < 0) @@ -210,7 +210,7 @@ virAuthGetUsername(virConnectPtr conn, const char *defaultUsername, const char *hostname) { - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; if (virAuthGetConfigFilePath(conn, &path) < 0) return NULL; @@ -229,7 +229,7 @@ virAuthGetPasswordPath(const char *path, { unsigned int ncred; virConnectCredential cred; - VIR_AUTOFREE(char *) prompt = NULL; + g_autofree char *prompt = NULL; char *ret = NULL; if (virAuthGetCredential(servicename, hostname, "password", path, &ret) < 0) @@ -292,7 +292,7 @@ virAuthGetPassword(virConnectPtr conn, const char *username, const char *hostname) { - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; if (virAuthGetConfigFilePath(conn, &path) < 0) return NULL; diff --git a/src/util/virauthconfig.c b/src/util/virauthconfig.c index 2c6379680a..9e55852cd4 100644 --- a/src/util/virauthconfig.c +++ b/src/util/virauthconfig.c @@ -104,8 +104,8 @@ int virAuthConfigLookup(virAuthConfigPtr auth, const char *credname, const char **value) { - VIR_AUTOFREE(char *) authgroup = NULL; - VIR_AUTOFREE(char *) credgroup = NULL; + g_autofree char *authgroup = NULL; + g_autofree char *credgroup = NULL; const char *authcred; *value = NULL; diff --git a/src/util/virbuffer.c b/src/util/virbuffer.c index 12b33f8bd6..04c8fd7291 100644 --- a/src/util/virbuffer.c +++ b/src/util/virbuffer.c @@ -436,7 +436,7 @@ void virBufferEscapeString(virBufferPtr buf, const char *format, const char *str) { int len; - VIR_AUTOFREE(char *) escaped = NULL; + g_autofree char *escaped = NULL; char *out; const char *cur; const char forbidden_characters[] = { @@ -592,7 +592,7 @@ virBufferEscape(virBufferPtr buf, char escape, const char *toescape, const char *format, const char *str) { int len; - VIR_AUTOFREE(char *) escaped = NULL; + g_autofree char *escaped = NULL; char *out; const char *cur; @@ -689,7 +689,7 @@ void virBufferEscapeShell(virBufferPtr buf, const char *str) { int len; - VIR_AUTOFREE(char *) escaped = NULL; + g_autofree char *escaped = NULL; char *out; const char *cur; diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index c6e4cf2dde..e5b1df56e8 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -132,7 +132,7 @@ virCgroupPartitionNeedsEscaping(const char *path) { FILE *fp = NULL; int ret = 0; - VIR_AUTOFREE(char *) line = NULL; + g_autofree char *line = NULL; size_t buflen; /* If it starts with 'cgroup.' or a '_' of any @@ -284,7 +284,7 @@ virCgroupDetectPlacement(virCgroupPtr group, FILE *mapping = NULL; char line[1024]; int ret = -1; - VIR_AUTOFREE(char *) procfile = NULL; + g_autofree char *procfile = NULL; VIR_DEBUG("Detecting placement for pid %lld path %s", (long long) pid, path); @@ -508,7 +508,7 @@ virCgroupSetValueStr(virCgroupPtr group, const char *key, const char *value) { - VIR_AUTOFREE(char *) keypath = NULL; + g_autofree char *keypath = NULL; if (virCgroupPathOfController(group, controller, key, &keypath) < 0) return -1; @@ -523,7 +523,7 @@ virCgroupGetValueStr(virCgroupPtr group, const char *key, char **value) { - VIR_AUTOFREE(char *) keypath = NULL; + g_autofree char *keypath = NULL; if (virCgroupPathOfController(group, controller, key, &keypath) < 0) return -1; @@ -537,7 +537,7 @@ virCgroupGetValueForBlkDev(const char *str, const char *path, char **value) { - VIR_AUTOFREE(char *) prefix = NULL; + g_autofree char *prefix = NULL; char **lines = NULL; int ret = -1; @@ -563,7 +563,7 @@ virCgroupSetValueU64(virCgroupPtr group, const char *key, unsigned long long int value) { - VIR_AUTOFREE(char *) strval = NULL; + g_autofree char *strval = NULL; if (virAsprintf(&strval, "%llu", value) < 0) return -1; @@ -578,7 +578,7 @@ virCgroupSetValueI64(virCgroupPtr group, const char *key, long long int value) { - VIR_AUTOFREE(char *) strval = NULL; + g_autofree char *strval = NULL; if (virAsprintf(&strval, "%lld", value) < 0) return -1; @@ -593,7 +593,7 @@ virCgroupGetValueI64(virCgroupPtr group, const char *key, long long int *value) { - VIR_AUTOFREE(char *) strval = NULL; + g_autofree char *strval = NULL; if (virCgroupGetValueStr(group, controller, key, &strval) < 0) return -1; @@ -615,7 +615,7 @@ virCgroupGetValueU64(virCgroupPtr group, const char *key, unsigned long long int *value) { - VIR_AUTOFREE(char *) strval = NULL; + g_autofree char *strval = NULL; if (virCgroupGetValueStr(group, controller, key, &strval) < 0) return -1; @@ -842,8 +842,8 @@ virCgroupNewPartition(const char *path, virCgroupPtr *group) { int ret = -1; - VIR_AUTOFREE(char *) parentPath = NULL; - VIR_AUTOFREE(char *) newPath = NULL; + g_autofree char *parentPath = NULL; + g_autofree char *newPath = NULL; virCgroupPtr parent = NULL; VIR_DEBUG("path=%s create=%d controllers=%x", path, create, controllers); @@ -920,7 +920,7 @@ virCgroupNewDomainPartition(virCgroupPtr partition, bool create, virCgroupPtr *group) { - VIR_AUTOFREE(char *)grpname = NULL; + g_autofree char *grpname = NULL; if (virAsprintf(&grpname, "%s.libvirt-%s", name, driver) < 0) @@ -970,7 +970,7 @@ virCgroupNewThread(virCgroupPtr domain, bool create, virCgroupPtr *group) { - VIR_AUTOFREE(char *) name = NULL; + g_autofree char *name = NULL; int controllers; switch (nameval) { @@ -1123,7 +1123,7 @@ virCgroupNewMachineSystemd(const char *name, { int rv; virCgroupPtr init; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; size_t i; VIR_DEBUG("Trying to setup machine '%s' via systemd", name); @@ -2061,7 +2061,7 @@ virCgroupGetPercpuVcpuSum(virCgroupPtr group, virCgroupPtr group_vcpu = NULL; while ((i = virBitmapNextSetBit(guestvcpus, i)) >= 0) { - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *buf = NULL; char *pos; unsigned long long tmp; ssize_t j; @@ -2127,8 +2127,8 @@ virCgroupGetPercpuStats(virCgroupPtr group, size_t i; int need_cpus, total_cpus; char *pos; - VIR_AUTOFREE(char *) buf = NULL; - VIR_AUTOFREE(unsigned long long *) sum_cpu_time = NULL; + g_autofree char *buf = NULL; + g_autofree unsigned long long *sum_cpu_time = NULL; virTypedParameterPtr ent; int param_idx; unsigned long long cpu_time; @@ -2359,7 +2359,7 @@ virCgroupRemoveRecursively(char *grppath) /* This is best-effort cleanup: we want to log failures with just * VIR_ERROR instead of normal virReportError */ while ((direrr = virDirRead(grpdir, &ent, NULL)) > 0) { - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; if (ent->d_type != DT_DIR) continue; @@ -2429,7 +2429,7 @@ virCgroupKillInternal(virCgroupPtr group, { int ret = -1; bool killedAny = false; - VIR_AUTOFREE(char *) keypath = NULL; + g_autofree char *keypath = NULL; bool done = false; FILE *fp = NULL; VIR_DEBUG("group=%p path=%s signum=%d pids=%p", @@ -2532,7 +2532,7 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, int ret = -1; int rc; bool killedAny = false; - VIR_AUTOFREE(char *) keypath = NULL; + g_autofree char *keypath = NULL; DIR *dp = NULL; virCgroupPtr subgroup = NULL; struct dirent *ent; diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index dcf8e3383b..d23045331e 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -92,10 +92,10 @@ virCgroupV1ValidateMachineGroup(virCgroupPtr group, const char *machinename) { size_t i; - VIR_AUTOFREE(char *) partname = NULL; - VIR_AUTOFREE(char *) scopename_old = NULL; - VIR_AUTOFREE(char *) scopename_new = NULL; - VIR_AUTOFREE(char *) partmachinename = NULL; + g_autofree char *partname = NULL; + g_autofree char *scopename_old = NULL; + g_autofree char *scopename_new = NULL; + g_autofree char *partmachinename = NULL; if (virAsprintf(&partname, "%s.libvirt-%s", name, drivername) < 0) @@ -228,8 +228,8 @@ virCgroupV1ResolveMountLink(const char *mntDir, const char *typeStr, virCgroupV1ControllerPtr controller) { - VIR_AUTOFREE(char *) linkSrc = NULL; - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree char *linkSrc = NULL; + g_autofree char *tmp = NULL; char *dirName; struct stat sb; @@ -556,7 +556,7 @@ virCgroupV1CpuSetInherit(virCgroupPtr parent, VIR_DEBUG("Setting up inheritance %s -> %s", parent->path, group->path); for (i = 0; i < G_N_ELEMENTS(inherit_values); i++) { - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *value = NULL; if (virCgroupGetValueStr(parent, VIR_CGROUP_CONTROLLER_CPUSET, @@ -612,7 +612,7 @@ virCgroupV1MakeGroup(virCgroupPtr parent, VIR_DEBUG("Make group %s", group->path); for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; /* We must never mkdir() in systemd's hierarchy */ if (i == VIR_CGROUP_CONTROLLER_SYSTEMD) { @@ -682,7 +682,7 @@ virCgroupV1Remove(virCgroupPtr group) VIR_DEBUG("Removing cgroup %s", group->path); for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { - VIR_AUTOFREE(char *) grppath = NULL; + g_autofree char *grppath = NULL; /* Skip over controllers not mounted */ if (!group->legacy[i].mountPoint) @@ -747,7 +747,7 @@ virCgroupV1HasEmptyTasks(virCgroupPtr cgroup, int controller) { int ret = -1; - VIR_AUTOFREE(char *) content = NULL; + g_autofree char *content = NULL; if (!cgroup) return -1; @@ -811,8 +811,8 @@ virCgroupV1BindMount(virCgroupPtr group, const char *mountopts) { size_t i; - VIR_AUTOFREE(char *) opts = NULL; - VIR_AUTOFREE(char *) root = NULL; + g_autofree char *opts = NULL; + g_autofree char *root = NULL; if (!(root = virCgroupV1IdentifyRoot(group))) return -1; @@ -842,7 +842,7 @@ virCgroupV1BindMount(virCgroupPtr group, continue; if (!virFileExists(group->legacy[i].mountPoint)) { - VIR_AUTOFREE(char *) src = NULL; + g_autofree char *src = NULL; if (virAsprintf(&src, "%s%s", oldroot, group->legacy[i].mountPoint) < 0) @@ -897,7 +897,7 @@ virCgroupV1SetOwner(virCgroupPtr cgroup, int direrr; for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { - VIR_AUTOFREE(char *) base = NULL; + g_autofree char *base = NULL; struct dirent *de; if (!((1 << i) & controllers)) @@ -914,7 +914,7 @@ virCgroupV1SetOwner(virCgroupPtr cgroup, goto cleanup; while ((direrr = virDirRead(dh, &de, base)) > 0) { - VIR_AUTOFREE(char *) entry = NULL; + g_autofree char *entry = NULL; if (virAsprintf(&entry, "%s/%s", base, de->d_name) < 0) goto cleanup; @@ -951,8 +951,8 @@ static int virCgroupV1SetBlkioWeight(virCgroupPtr group, unsigned int weight) { - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *path = NULL; + g_autofree char *value = NULL; if (virCgroupV1PathOfController(group, VIR_CGROUP_CONTROLLER_BLKIO, "blkio.bfq.weight", &path) < 0) { @@ -985,8 +985,8 @@ static int virCgroupV1GetBlkioWeight(virCgroupPtr group, unsigned int *weight) { - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *path = NULL; + g_autofree char *value = NULL; if (virCgroupV1PathOfController(group, VIR_CGROUP_CONTROLLER_BLKIO, "blkio.bfq.weight", &path) < 0) { @@ -1030,8 +1030,8 @@ virCgroupV1GetBlkioIoServiced(virCgroupPtr group, long long *requests_write) { long long stats_val; - VIR_AUTOFREE(char *) str1 = NULL; - VIR_AUTOFREE(char *) str2 = NULL; + g_autofree char *str1 = NULL; + g_autofree char *str2 = NULL; char *p1 = NULL; char *p2 = NULL; size_t i; @@ -1124,9 +1124,9 @@ virCgroupV1GetBlkioIoDeviceServiced(virCgroupPtr group, long long *requests_read, long long *requests_write) { - VIR_AUTOFREE(char *) str1 = NULL; - VIR_AUTOFREE(char *) str2 = NULL; - VIR_AUTOFREE(char *) str3 = NULL; + g_autofree char *str1 = NULL; + g_autofree char *str2 = NULL; + g_autofree char *str3 = NULL; char *p1 = NULL; char *p2 = NULL; size_t i; @@ -1210,9 +1210,9 @@ virCgroupV1SetBlkioDeviceWeight(virCgroupPtr group, const char *devPath, unsigned int weight) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) blkstr = NULL; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *str = NULL; + g_autofree char *blkstr = NULL; + g_autofree char *path = NULL; if (!(blkstr = virCgroupGetBlockDevString(devPath))) return -1; @@ -1240,9 +1240,9 @@ virCgroupV1GetBlkioDeviceWeight(virCgroupPtr group, const char *devPath, unsigned int *weight) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) value = NULL; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *str = NULL; + g_autofree char *value = NULL; + g_autofree char *path = NULL; if (virCgroupV1PathOfController(group, VIR_CGROUP_CONTROLLER_BLKIO, "blkio.weight_device", &path) < 0) { @@ -1279,8 +1279,8 @@ virCgroupV1SetBlkioDeviceReadIops(virCgroupPtr group, const char *path, unsigned int riops) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) blkstr = NULL; + g_autofree char *str = NULL; + g_autofree char *blkstr = NULL; if (!(blkstr = virCgroupGetBlockDevString(path))) return -1; @@ -1300,8 +1300,8 @@ virCgroupV1GetBlkioDeviceReadIops(virCgroupPtr group, const char *path, unsigned int *riops) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *str = NULL; + g_autofree char *value = NULL; if (virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_BLKIO, @@ -1331,8 +1331,8 @@ virCgroupV1SetBlkioDeviceWriteIops(virCgroupPtr group, const char *path, unsigned int wiops) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) blkstr = NULL; + g_autofree char *str = NULL; + g_autofree char *blkstr = NULL; if (!(blkstr = virCgroupGetBlockDevString(path))) return -1; @@ -1352,8 +1352,8 @@ virCgroupV1GetBlkioDeviceWriteIops(virCgroupPtr group, const char *path, unsigned int *wiops) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *str = NULL; + g_autofree char *value = NULL; if (virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_BLKIO, @@ -1383,8 +1383,8 @@ virCgroupV1SetBlkioDeviceReadBps(virCgroupPtr group, const char *path, unsigned long long rbps) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) blkstr = NULL; + g_autofree char *str = NULL; + g_autofree char *blkstr = NULL; if (!(blkstr = virCgroupGetBlockDevString(path))) return -1; @@ -1404,8 +1404,8 @@ virCgroupV1GetBlkioDeviceReadBps(virCgroupPtr group, const char *path, unsigned long long *rbps) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *str = NULL; + g_autofree char *value = NULL; if (virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_BLKIO, @@ -1435,8 +1435,8 @@ virCgroupV1SetBlkioDeviceWriteBps(virCgroupPtr group, const char *path, unsigned long long wbps) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) blkstr = NULL; + g_autofree char *str = NULL; + g_autofree char *blkstr = NULL; if (!(blkstr = virCgroupGetBlockDevString(path))) return -1; @@ -1456,8 +1456,8 @@ virCgroupV1GetBlkioDeviceWriteBps(virCgroupPtr group, const char *path, unsigned long long *wbps) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *str = NULL; + g_autofree char *value = NULL; if (virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_BLKIO, @@ -1787,9 +1787,9 @@ virCgroupV1AllowDevice(virCgroupPtr group, int minor, int perms) { - VIR_AUTOFREE(char *) devstr = NULL; - VIR_AUTOFREE(char *) majorstr = NULL; - VIR_AUTOFREE(char *) minorstr = NULL; + g_autofree char *devstr = NULL; + g_autofree char *majorstr = NULL; + g_autofree char *minorstr = NULL; if ((major < 0 && VIR_STRDUP(majorstr, "*") < 0) || (major >= 0 && virAsprintf(&majorstr, "%i", major) < 0)) @@ -1820,9 +1820,9 @@ virCgroupV1DenyDevice(virCgroupPtr group, int minor, int perms) { - VIR_AUTOFREE(char *) devstr = NULL; - VIR_AUTOFREE(char *) majorstr = NULL; - VIR_AUTOFREE(char *) minorstr = NULL; + g_autofree char *devstr = NULL; + g_autofree char *majorstr = NULL; + g_autofree char *minorstr = NULL; if ((major < 0 && VIR_STRDUP(majorstr, "*") < 0) || (major >= 0 && virAsprintf(&majorstr, "%i", major) < 0)) @@ -1958,7 +1958,7 @@ virCgroupV1GetCpuCfsQuota(virCgroupPtr group, static bool virCgroupV1SupportsCpuBW(virCgroupPtr cgroup) { - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; if (!cgroup) return false; @@ -1997,7 +1997,7 @@ virCgroupV1GetCpuacctStat(virCgroupPtr group, unsigned long long *user, unsigned long long *sys) { - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; char *p; static double scale = -1.0; diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 5d940b0209..403b3b145e 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -66,8 +66,8 @@ virCgroupV2Available(void) return false; while (getmntent_r(mounts, &entry, buf, sizeof(buf)) != NULL) { - VIR_AUTOFREE(char *) contFile = NULL; - VIR_AUTOFREE(char *) contStr = NULL; + g_autofree char *contFile = NULL; + g_autofree char *contStr = NULL; if (STRNEQ(entry.mnt_type, "cgroup2")) continue; @@ -100,8 +100,8 @@ virCgroupV2ValidateMachineGroup(virCgroupPtr group, const char *drivername, const char *machinename) { - VIR_AUTOFREE(char *) partmachinename = NULL; - VIR_AUTOFREE(char *) scopename = NULL; + g_autofree char *partmachinename = NULL; + g_autofree char *scopename = NULL; char *tmp; if (virAsprintf(&partmachinename, "%s.libvirt-%s", machinename, @@ -255,8 +255,8 @@ virCgroupV2ParseControllersFile(virCgroupPtr group, virCgroupPtr parent) { int rc; - VIR_AUTOFREE(char *) contStr = NULL; - VIR_AUTOFREE(char *) contFile = NULL; + g_autofree char *contStr = NULL; + g_autofree char *contFile = NULL; char **contList = NULL; char **tmp; @@ -379,8 +379,8 @@ virCgroupV2EnableController(virCgroupPtr group, int controller, bool report) { - VIR_AUTOFREE(char *) val = NULL; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *val = NULL; + g_autofree char *path = NULL; if (virAsprintf(&val, "+%s", virCgroupV2ControllerTypeToString(controller)) < 0) { @@ -413,7 +413,7 @@ virCgroupV2MakeGroup(virCgroupPtr parent, bool create, unsigned int flags) { - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; int controller; if (flags & VIR_CGROUP_SYSTEMD) { @@ -490,7 +490,7 @@ virCgroupV2MakeGroup(virCgroupPtr parent, static int virCgroupV2Remove(virCgroupPtr group) { - VIR_AUTOFREE(char *) grppath = NULL; + g_autofree char *grppath = NULL; int controller; /* Don't delete the root group, if we accidentally @@ -525,7 +525,7 @@ virCgroupV2HasEmptyTasks(virCgroupPtr cgroup, int controller) { int ret = -1; - VIR_AUTOFREE(char *) content = NULL; + g_autofree char *content = NULL; ret = virCgroupGetValueStr(cgroup, controller, "cgroup.procs", &content); @@ -556,8 +556,8 @@ virCgroupV2BindMount(virCgroupPtr group, const char *oldroot, const char *mountopts) { - VIR_AUTOFREE(char *) opts = NULL; - VIR_AUTOFREE(char *) src = NULL; + g_autofree char *opts = NULL; + g_autofree char *src = NULL; VIR_DEBUG("Mounting cgroups at '%s'", group->unified.mountPoint); @@ -589,7 +589,7 @@ virCgroupV2SetOwner(virCgroupPtr cgroup, gid_t gid, int controllers G_GNUC_UNUSED) { - VIR_AUTOFREE(char *) base = NULL; + g_autofree char *base = NULL; if (virAsprintf(&base, "%s%s", cgroup->unified.mountPoint, cgroup->unified.placement) < 0) { @@ -613,8 +613,8 @@ static int virCgroupV2SetBlkioWeight(virCgroupPtr group, unsigned int weight) { - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *path = NULL; + g_autofree char *value = NULL; const char *format = "%u"; if (virCgroupV2PathOfController(group, VIR_CGROUP_CONTROLLER_BLKIO, @@ -649,8 +649,8 @@ static int virCgroupV2GetBlkioWeight(virCgroupPtr group, unsigned int *weight) { - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *path = NULL; + g_autofree char *value = NULL; char *tmp; if (virCgroupV2PathOfController(group, VIR_CGROUP_CONTROLLER_BLKIO, @@ -701,7 +701,7 @@ virCgroupV2GetBlkioIoServiced(virCgroupPtr group, long long *requests_write) { long long stats_val; - VIR_AUTOFREE(char *) str1 = NULL; + g_autofree char *str1 = NULL; char *p1; size_t i; @@ -765,8 +765,8 @@ virCgroupV2GetBlkioIoDeviceServiced(virCgroupPtr group, long long *requests_read, long long *requests_write) { - VIR_AUTOFREE(char *) str1 = NULL; - VIR_AUTOFREE(char *) str2 = NULL; + g_autofree char *str1 = NULL; + g_autofree char *str2 = NULL; char *p1; size_t i; @@ -825,9 +825,9 @@ virCgroupV2SetBlkioDeviceWeight(virCgroupPtr group, const char *devPath, unsigned int weight) { - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) blkstr = NULL; + g_autofree char *path = NULL; + g_autofree char *str = NULL; + g_autofree char *blkstr = NULL; if (!(blkstr = virCgroupGetBlockDevString(devPath))) return -1; @@ -855,9 +855,9 @@ virCgroupV2GetBlkioDeviceWeight(virCgroupPtr group, const char *devPath, unsigned int *weight) { - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *path = NULL; + g_autofree char *str = NULL; + g_autofree char *value = NULL; char *tmp; if (virCgroupV2PathOfController(group, VIR_CGROUP_CONTROLLER_BLKIO, @@ -895,8 +895,8 @@ virCgroupV2SetBlkioDeviceReadIops(virCgroupPtr group, const char *path, unsigned int riops) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) blkstr = NULL; + g_autofree char *str = NULL; + g_autofree char *blkstr = NULL; if (!(blkstr = virCgroupGetBlockDevString(path))) return -1; @@ -921,8 +921,8 @@ virCgroupV2GetBlkioDeviceReadIops(virCgroupPtr group, const char *path, unsigned int *riops) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *str = NULL; + g_autofree char *value = NULL; const char *name = "riops="; char *tmp; @@ -966,8 +966,8 @@ virCgroupV2SetBlkioDeviceWriteIops(virCgroupPtr group, const char *path, unsigned int wiops) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) blkstr = NULL; + g_autofree char *str = NULL; + g_autofree char *blkstr = NULL; if (!(blkstr = virCgroupGetBlockDevString(path))) return -1; @@ -992,8 +992,8 @@ virCgroupV2GetBlkioDeviceWriteIops(virCgroupPtr group, const char *path, unsigned int *wiops) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *str = NULL; + g_autofree char *value = NULL; const char *name = "wiops="; char *tmp; @@ -1037,8 +1037,8 @@ virCgroupV2SetBlkioDeviceReadBps(virCgroupPtr group, const char *path, unsigned long long rbps) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) blkstr = NULL; + g_autofree char *str = NULL; + g_autofree char *blkstr = NULL; if (!(blkstr = virCgroupGetBlockDevString(path))) return -1; @@ -1063,8 +1063,8 @@ virCgroupV2GetBlkioDeviceReadBps(virCgroupPtr group, const char *path, unsigned long long *rbps) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *str = NULL; + g_autofree char *value = NULL; const char *name = "rbps="; char *tmp; @@ -1108,8 +1108,8 @@ virCgroupV2SetBlkioDeviceWriteBps(virCgroupPtr group, const char *path, unsigned long long wbps) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) blkstr = NULL; + g_autofree char *str = NULL; + g_autofree char *blkstr = NULL; if (!(blkstr = virCgroupGetBlockDevString(path))) return -1; @@ -1134,8 +1134,8 @@ virCgroupV2GetBlkioDeviceWriteBps(virCgroupPtr group, const char *path, unsigned long long *wbps) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *str = NULL; + g_autofree char *value = NULL; const char *name = "wbps="; char *tmp; @@ -1210,7 +1210,7 @@ virCgroupV2GetMemoryStat(virCgroupPtr group, unsigned long long *inactiveFile, unsigned long long *unevictable) { - VIR_AUTOFREE(char *) stat = NULL; + g_autofree char *stat = NULL; char *line = NULL; unsigned long long cacheVal = 0; unsigned long long activeAnonVal = 0; @@ -1306,7 +1306,7 @@ static int virCgroupV2GetMemoryHardLimit(virCgroupPtr group, unsigned long long *kb) { - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *value = NULL; unsigned long long max; if (virCgroupGetValueStr(group, @@ -1366,7 +1366,7 @@ static int virCgroupV2GetMemorySoftLimit(virCgroupPtr group, unsigned long long *kb) { - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *value = NULL; unsigned long long high; if (virCgroupGetValueStr(group, @@ -1425,7 +1425,7 @@ static int virCgroupV2GetMemSwapHardLimit(virCgroupPtr group, unsigned long long *kb) { - VIR_AUTOFREE(char *) value = NULL; + g_autofree char *value = NULL; unsigned long long max; if (virCgroupGetValueStr(group, @@ -1493,8 +1493,8 @@ static int virCgroupV2SetCpuCfsPeriod(virCgroupPtr group, unsigned long long cfs_period) { - VIR_AUTOFREE(char *) value = NULL; - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *value = NULL; + g_autofree char *str = NULL; char *tmp; /* The cfs_period should be greater or equal than 1ms, and less or equal @@ -1531,7 +1531,7 @@ static int virCgroupV2GetCpuCfsPeriod(virCgroupPtr group, unsigned long long *cfs_period) { - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; char *tmp; if (virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_CPU, @@ -1585,7 +1585,7 @@ static int virCgroupV2GetCpuCfsQuota(virCgroupPtr group, long long *cfs_quota) { - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; char *tmp; if (virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_CPU, @@ -1611,7 +1611,7 @@ virCgroupV2GetCpuCfsQuota(virCgroupPtr group, static bool virCgroupV2SupportsCpuBW(virCgroupPtr cgroup) { - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; if (virCgroupV2PathOfController(cgroup, VIR_CGROUP_CONTROLLER_CPU, "cpu.max", &path) < 0) { @@ -1627,7 +1627,7 @@ static int virCgroupV2GetCpuacctUsage(virCgroupPtr group, unsigned long long *usage) { - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; char *tmp; if (virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_CPUACCT, @@ -1659,7 +1659,7 @@ virCgroupV2GetCpuacctStat(virCgroupPtr group, unsigned long long *user, unsigned long long *sys) { - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; char *tmp; unsigned long long userVal = 0; unsigned long long sysVal = 0; diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 763bcb6d12..a62a513b0c 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -547,11 +547,11 @@ virExec(virCommandPtr cmd) int childin = cmd->infd; int childout = -1; int childerr = -1; - VIR_AUTOFREE(char *) binarystr = NULL; + g_autofree char *binarystr = NULL; const char *binary = NULL; int ret; struct sigaction waxon, waxoff; - VIR_AUTOFREE(gid_t *) groups = NULL; + g_autofree gid_t *groups = NULL; int ngroups; if (cmd->args[0][0] != '/') { @@ -2170,7 +2170,7 @@ virCommandProcessIO(virCommandPtr cmd) size_t inlen = 0, outlen = 0, errlen = 0; size_t inoff = 0; int ret = 0; - VIR_AUTOFREE(struct pollfd *) fds = NULL; + g_autofree struct pollfd *fds = NULL; if (dryRunBuffer || dryRunCallback) { VIR_DEBUG("Dry run requested, skipping I/O processing"); @@ -2541,7 +2541,7 @@ int virCommandRunAsync(virCommandPtr cmd, pid_t *pid) { int ret = -1; - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; size_t i; bool synchronous = false; int infd[2] = {-1, -1}; @@ -2757,8 +2757,8 @@ virCommandWait(virCommandPtr cmd, int *exitstatus) if (exitstatus && (cmd->rawStatus || WIFEXITED(status))) { *exitstatus = cmd->rawStatus ? status : WEXITSTATUS(status); } else if (status) { - VIR_AUTOFREE(char *) str = virCommandToString(cmd, false); - VIR_AUTOFREE(char *) st = virProcessTranslateStatus(status); + g_autofree char *str = virCommandToString(cmd, false); + g_autofree char *st = virProcessTranslateStatus(status); bool haveErrMsg = cmd->errbuf && *cmd->errbuf && (*cmd->errbuf)[0]; virReportError(VIR_ERR_INTERNAL_ERROR, @@ -2885,7 +2885,7 @@ int virCommandHandshakeWait(virCommandPtr cmd) return -1; } if (c != '1') { - VIR_AUTOFREE(char *) msg = NULL; + g_autofree char *msg = NULL; ssize_t len; if (VIR_ALLOC_N(msg, 1024) < 0) { VIR_FORCE_CLOSE(cmd->handshakeWait[0]); @@ -3021,7 +3021,7 @@ virCommandFree(virCommandPtr cmd) * combination with virCommandRunAsync(): * * VIR_AUTOPTR(virCommand) cmd = virCommandNew*(...); - * VIR_AUTOFREE(char *) buf = NULL; + * g_autofree char *buf = NULL; * * ... * @@ -3133,11 +3133,11 @@ virCommandRunRegex(virCommandPtr cmd, { int err; regex_t *reg; - VIR_AUTOFREE(regmatch_t *) vars = NULL; + g_autofree regmatch_t *vars = NULL; size_t i, j, k; int totgroups = 0, ngroup = 0, maxvars = 0; char **groups; - VIR_AUTOFREE(char *) outbuf = NULL; + g_autofree char *outbuf = NULL; VIR_AUTOSTRINGLIST lines = NULL; int ret = -1; diff --git a/src/util/virerror.c b/src/util/virerror.c index 5d69e4e972..f02d6f3b8a 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -1481,8 +1481,8 @@ virLastErrorPrefixMessage(const char *fmt, ...) { int save_errno = errno; virErrorPtr err = virGetLastError(); - VIR_AUTOFREE(char *) fmtmsg = NULL; - VIR_AUTOFREE(char *) newmsg = NULL; + g_autofree char *fmtmsg = NULL; + g_autofree char *newmsg = NULL; va_list args; if (!err) diff --git a/src/util/vireventpoll.c b/src/util/vireventpoll.c index b57b300446..6d3b310bc2 100644 --- a/src/util/vireventpoll.c +++ b/src/util/vireventpoll.c @@ -613,7 +613,7 @@ static void virEventPollCleanupHandles(void) */ int virEventPollRunOnce(void) { - VIR_AUTOFREE(struct pollfd *) fds = NULL; + g_autofree struct pollfd *fds = NULL; int ret, timeout, nfds; virMutexLock(&eventLoop.lock); diff --git a/src/util/virfcp.c b/src/util/virfcp.c index 9fe86e362e..2315b517bd 100644 --- a/src/util/virfcp.c +++ b/src/util/virfcp.c @@ -38,7 +38,7 @@ bool virFCIsCapableRport(const char *rport) { - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; if (virBuildPath(&path, SYSFS_FC_RPORT_PATH, rport) < 0) return false; @@ -51,7 +51,7 @@ virFCReadRportValue(const char *rport, const char *entry, char **result) { - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *buf = NULL; char *p = NULL; if (virFileReadValueString(&buf, "%s/%s/%s", diff --git a/src/util/virfile.c b/src/util/virfile.c index 7d6a9011c6..457235d195 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -216,7 +216,7 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags) bool output = false; int pipefd[2] = { -1, -1 }; int mode = -1; - VIR_AUTOFREE(char *) iohelper_path = NULL; + g_autofree char *iohelper_path = NULL; if (!flags) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -504,7 +504,7 @@ virFileRewrite(const char *path, virFileRewriteFunc rewrite, const void *opaque) { - VIR_AUTOFREE(char *) newfile = NULL; + g_autofree char *newfile = NULL; int fd = -1; int ret = -1; @@ -772,7 +772,7 @@ int virFileLoopDeviceAssociate(const char *file, int lofd = -1; int fsfd = -1; struct loop_info64 lo; - VIR_AUTOFREE(char *) loname = NULL; + g_autofree char *loname = NULL; int ret = -1; if ((lofd = virFileLoopDeviceOpen(&loname)) < 0) @@ -832,7 +832,7 @@ int virFileLoopDeviceAssociate(const char *file, static int virFileNBDDeviceIsBusy(const char *dev_name) { - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; if (virAsprintf(&path, SYSFS_BLOCK_DIR "/%s/pid", dev_name) < 0) @@ -892,7 +892,7 @@ virFileNBDLoadDriver(void) "administratively prohibited")); return false; } else { - VIR_AUTOFREE(char *) errbuf = NULL; + g_autofree char *errbuf = NULL; if ((errbuf = virKModLoad(NBD_DRIVER, true))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -908,8 +908,8 @@ int virFileNBDDeviceAssociate(const char *file, bool readonly, char **dev) { - VIR_AUTOFREE(char *) nbddev = NULL; - VIR_AUTOFREE(char *) qemunbd = NULL; + g_autofree char *nbddev = NULL; + g_autofree char *qemunbd = NULL; VIR_AUTOPTR(virCommand) cmd = NULL; const char *fmtstr = NULL; @@ -1010,7 +1010,7 @@ int virFileDeleteTree(const char *dir) return -1; while ((direrr = virDirRead(dh, &de, dir)) > 0) { - VIR_AUTOFREE(char *) filepath = NULL; + g_autofree char *filepath = NULL; struct stat sb; if (virAsprintf(&filepath, "%s/%s", @@ -1187,7 +1187,7 @@ static int safezero_slow(int fd, off_t offset, off_t len) { int r; - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *buf = NULL; unsigned long long remain, bytes; if (lseek(fd, offset, SEEK_SET) < 0) @@ -1546,7 +1546,7 @@ virFileRelLinkPointsTo(const char *directory, const char *checkLink, const char *checkDest) { - VIR_AUTOFREE(char *) candidate = NULL; + g_autofree char *candidate = NULL; if (*checkLink == '/') return virFileLinkPointsTo(checkLink, checkDest); @@ -1905,7 +1905,7 @@ virFileIsExecutable(const char *file) */ int virFileIsMountPoint(const char *file) { - VIR_AUTOFREE(char *) parent = NULL; + g_autofree char *parent = NULL; int ret; struct stat sb1, sb2; @@ -2114,7 +2114,7 @@ virFileAccessibleAs(const char *path, int mode, { pid_t pid = 0; int status, ret = 0; - VIR_AUTOFREE(gid_t *) groups = NULL; + g_autofree gid_t *groups = NULL; int ngroups; if (uid == geteuid() && @@ -2226,7 +2226,7 @@ virFileOpenForked(const char *path, int openflags, mode_t mode, int recvfd_errno = 0; int fd = -1; int pair[2] = { -1, -1 }; - VIR_AUTOFREE(gid_t *) groups = NULL; + g_autofree gid_t *groups = NULL; int ngroups; bool created = false; @@ -2514,7 +2514,7 @@ virFileRemove(const char *path, { pid_t pid; int status = 0, ret = 0; - VIR_AUTOFREE(gid_t *) groups = NULL; + g_autofree gid_t *groups = NULL; int ngroups; if (!virFileRemoveNeedsSetuid(path, uid, gid)) { @@ -2675,7 +2675,7 @@ virDirCreate(const char *path, struct stat st; pid_t pid; int status = 0, ret = 0; - VIR_AUTOFREE(gid_t *) groups = NULL; + g_autofree gid_t *groups = NULL; int ngroups; bool created = false; @@ -2984,7 +2984,7 @@ int virFileChownFiles(const char *name, return -1; while ((direrr = virDirRead(dir, &ent, name)) > 0) { - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; if (virAsprintf(&path, "%s/%s", name, ent->d_name) < 0) goto cleanup; @@ -3068,7 +3068,7 @@ int virFileMakePathWithMode(const char *path, mode_t mode) { - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree char *tmp = NULL; if (VIR_STRDUP(tmp, path) < 0) { errno = ENOMEM; @@ -3083,7 +3083,7 @@ int virFileMakeParentPath(const char *path) { char *p; - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree char *tmp = NULL; VIR_DEBUG("path=%s", path); @@ -3132,7 +3132,7 @@ virFileOpenTty(int *ttymaster, char **ttyName, int rawmode) * doesn't have to worry about that mess? */ int ret = -1; int slave = -1; - VIR_AUTOFREE(char *) name = NULL; + g_autofree char *name = NULL; /* Unfortunately, we can't use the name argument of openpty, since * there is no guarantee on how large the buffer has to be. @@ -3296,7 +3296,7 @@ virFileAbsPath(const char *path, char **abspath) if (VIR_STRDUP(*abspath, path) < 0) return -1; } else { - VIR_AUTOFREE(char *) buf = getcwd(NULL, 0); + g_autofree char *buf = getcwd(NULL, 0); if (buf == NULL) return -1; @@ -3402,7 +3402,7 @@ virFileRemoveLastComponent(char *path) int virFilePrintf(FILE *fp, const char *msg, ...) { va_list vargs; - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; int ret; va_start(vargs, msg); @@ -3534,7 +3534,7 @@ int virFileIsSharedFSType(const char *path, int fstypes) { - VIR_AUTOFREE(char *) dirpath = NULL; + g_autofree char *dirpath = NULL; char *p = NULL; struct statfs sb; int statfs_ret; @@ -3650,7 +3650,7 @@ virFileGetHugepageSize(const char *path, static int virFileGetDefaultHugepageSize(unsigned long long *size) { - VIR_AUTOFREE(char *) meminfo = NULL; + g_autofree char *meminfo = NULL; char *c; char *n; char *unit; @@ -3999,8 +3999,8 @@ virFileCopyACLs(const char *src, int virFileComparePaths(const char *p1, const char *p2) { - VIR_AUTOFREE(char *) res1 = NULL; - VIR_AUTOFREE(char *) res2 = NULL; + g_autofree char *res1 = NULL; + g_autofree char *res2 = NULL; /* Assume p1 and p2 are symlinks, so try to resolve and canonicalize them. * Canonicalization fails for example on file systems names like 'proc' or @@ -4166,8 +4166,8 @@ virFileInData(int fd G_GNUC_UNUSED, int virFileReadValueInt(int *value, const char *format, ...) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *str = NULL; + g_autofree char *path = NULL; va_list ap; va_start(ap, format); @@ -4209,8 +4209,8 @@ virFileReadValueInt(int *value, const char *format, ...) int virFileReadValueUint(unsigned int *value, const char *format, ...) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *str = NULL; + g_autofree char *path = NULL; va_list ap; va_start(ap, format); @@ -4252,8 +4252,8 @@ virFileReadValueUint(unsigned int *value, const char *format, ...) int virFileReadValueScaledInt(unsigned long long *value, const char *format, ...) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *str = NULL; + g_autofree char *path = NULL; char *endp = NULL; va_list ap; @@ -4299,8 +4299,8 @@ virFileReadValueScaledInt(unsigned long long *value, const char *format, ...) int virFileReadValueBitmap(virBitmapPtr *value, const char *format, ...) { - VIR_AUTOFREE(char *) str = NULL; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *str = NULL; + g_autofree char *path = NULL; va_list ap; va_start(ap, format); @@ -4341,7 +4341,7 @@ int virFileReadValueString(char **value, const char *format, ...) { int ret; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; va_list ap; va_start(ap, format); diff --git a/src/util/virfilecache.c b/src/util/virfilecache.c index fa57e3d620..823d5e15e0 100644 --- a/src/util/virfilecache.c +++ b/src/util/virfilecache.c @@ -100,7 +100,7 @@ static char * virFileCacheGetFileName(virFileCachePtr cache, const char *name) { - VIR_AUTOFREE(char *) namehash = NULL; + g_autofree char *namehash = NULL; virBuffer buf = VIR_BUFFER_INITIALIZER; if (virCryptoHashString(VIR_CRYPTO_HASH_SHA256, name, &namehash) < 0) @@ -130,7 +130,7 @@ virFileCacheLoad(virFileCachePtr cache, const char *name, void **data) { - VIR_AUTOFREE(char *) file = NULL; + g_autofree char *file = NULL; int ret = -1; void *loadData = NULL; @@ -182,7 +182,7 @@ virFileCacheSave(virFileCachePtr cache, const char *name, void *data) { - VIR_AUTOFREE(char *) file = NULL; + g_autofree char *file = NULL; if (!(file = virFileCacheGetFileName(cache, name))) return -1; @@ -335,7 +335,7 @@ virFileCacheLookupByFunc(virFileCachePtr cache, const void *iterData) { void *data = NULL; - VIR_AUTOFREE(char *) name = NULL; + g_autofree char *name = NULL; virObjectLock(cache); diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index 0d4bfae8f8..a38516a1bb 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -504,7 +504,7 @@ void virFirewallRuleAddArgFormat(virFirewallPtr firewall, virFirewallRulePtr rule, const char *fmt, ...) { - VIR_AUTOFREE(char *) arg = NULL; + g_autofree char *arg = NULL; va_list list; VIR_FIREWALL_RULE_RETURN_IF_ERROR(firewall, rule); @@ -668,7 +668,7 @@ virFirewallApplyRuleDirect(virFirewallRulePtr rule, const char *bin = virFirewallLayerCommandTypeToString(rule->layer); VIR_AUTOPTR(virCommand) cmd = NULL; int status; - VIR_AUTOFREE(char *) error = NULL; + g_autofree char *error = NULL; if (!bin) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -692,7 +692,7 @@ virFirewallApplyRuleDirect(virFirewallRulePtr rule, if (ignoreErrors) { VIR_DEBUG("Ignoring error running command"); } else { - VIR_AUTOFREE(char *) args = virCommandToString(cmd, false); + g_autofree char *args = virCommandToString(cmd, false); virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to apply firewall rules %s: %s"), NULLSTR(args), NULLSTR(error)); @@ -719,8 +719,8 @@ virFirewallApplyRule(virFirewallPtr firewall, virFirewallRulePtr rule, bool ignoreErrors) { - VIR_AUTOFREE(char *) output = NULL; - VIR_AUTOFREE(char *) str = virFirewallRuleToString(rule); + g_autofree char *output = NULL; + g_autofree char *str = virFirewallRuleToString(rule); VIR_AUTOSTRINGLIST lines = NULL; VIR_INFO("Applying rule '%s'", NULLSTR(str)); diff --git a/src/util/virfirewalld.c b/src/util/virfirewalld.c index 60b75e7e25..c14a6b6e65 100644 --- a/src/util/virfirewalld.c +++ b/src/util/virfirewalld.c @@ -85,7 +85,7 @@ virFirewallDGetVersion(unsigned long *version) int ret = -1; DBusConnection *sysbus = virDBusGetSystemBus(); DBusMessage *reply = NULL; - VIR_AUTOFREE(char *) versionStr = NULL; + g_autofree char *versionStr = NULL; if (!sysbus) return -1; @@ -132,7 +132,7 @@ virFirewallDGetBackend(void) DBusConnection *sysbus = virDBusGetSystemBus(); DBusMessage *reply = NULL; virError error; - VIR_AUTOFREE(char *) backendStr = NULL; + g_autofree char *backendStr = NULL; int backend = -1; if (!sysbus) diff --git a/src/util/virhook.c b/src/util/virhook.c index 84b3954872..19207c2b25 100644 --- a/src/util/virhook.c +++ b/src/util/virhook.c @@ -131,7 +131,7 @@ static int virHooksFound = -1; static int virHookCheck(int no, const char *driver) { - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; if (driver == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -240,7 +240,7 @@ virHookCall(int driver, char **output) { int ret; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; VIR_AUTOPTR(virCommand) cmd = NULL; const char *drvstr; const char *opstr; diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index 41fcab7222..984f6bb290 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -179,7 +179,7 @@ virHostdevManagerNew(void) return NULL; } } else { - VIR_AUTOFREE(char *) rundir = NULL; + g_autofree char *rundir = NULL; mode_t old_umask; if (!(rundir = virGetUserRuntimeDirectory())) @@ -306,7 +306,7 @@ virHostdevPCISysfsPath(virDomainHostdevDefPtr hostdev, static int virHostdevIsVirtualFunction(virDomainHostdevDefPtr hostdev) { - VIR_AUTOFREE(char *) sysfs_path = NULL; + g_autofree char *sysfs_path = NULL; if (virHostdevPCISysfsPath(hostdev, &sysfs_path) < 0) return -1; @@ -321,7 +321,7 @@ virHostdevNetDevice(virDomainHostdevDefPtr hostdev, char **linkdev, int *vf) { - VIR_AUTOFREE(char *) sysfs_path = NULL; + g_autofree char *sysfs_path = NULL; if (virHostdevPCISysfsPath(hostdev, &sysfs_path) < 0) return -1; @@ -447,7 +447,7 @@ static int virHostdevSaveNetConfig(virDomainHostdevDefPtr hostdev, const char *stateDir) { - VIR_AUTOFREE(char *) linkdev = NULL; + g_autofree char *linkdev = NULL; int vf = -1; if (!virHostdevIsPCINetDevice(hostdev) || @@ -486,7 +486,7 @@ static int virHostdevSetNetConfig(virDomainHostdevDefPtr hostdev, const unsigned char *uuid) { - VIR_AUTOFREE(char *) linkdev = NULL; + g_autofree char *linkdev = NULL; virNetDevVlanPtr vlan; virNetDevVPortProfilePtr virtPort; int vf = -1; @@ -534,9 +534,9 @@ virHostdevRestoreNetConfig(virDomainHostdevDefPtr hostdev, const char *stateDir, const char *oldStateDir) { - VIR_AUTOFREE(char *) linkdev = NULL; - VIR_AUTOFREE(virMacAddrPtr) MAC = NULL; - VIR_AUTOFREE(virMacAddrPtr) adminMAC = NULL; + g_autofree char *linkdev = NULL; + g_autofree virMacAddrPtr MAC = NULL; + g_autofree virMacAddrPtr adminMAC = NULL; VIR_AUTOPTR(virNetDevVlan) vlan = NULL; virNetDevVPortProfilePtr virtPort; int vf = -1; @@ -804,8 +804,8 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr, mgr->inactivePCIHostdevs) < 0) goto reattachdevs; } else { - VIR_AUTOFREE(char *) driverPath = NULL; - VIR_AUTOFREE(char *) driverName = NULL; + g_autofree char *driverPath = NULL; + g_autofree char *driverName = NULL; int stub; /* Unmanaged devices should already have been marked as diff --git a/src/util/virhostmem.c b/src/util/virhostmem.c index 8e86bedaab..938e2fa6b3 100644 --- a/src/util/virhostmem.c +++ b/src/util/virhostmem.c @@ -255,7 +255,7 @@ virHostMemGetStats(int cellNum G_GNUC_UNUSED, #ifdef __linux__ { int ret; - VIR_AUTOFREE(char *) meminfo_path = NULL; + g_autofree char *meminfo_path = NULL; FILE *meminfo; int max_node; @@ -312,8 +312,8 @@ virHostMemGetStats(int cellNum G_GNUC_UNUSED, static int virHostMemSetParameterValue(virTypedParameterPtr param) { - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(char *) strval = NULL; + g_autofree char *path = NULL; + g_autofree char *strval = NULL; int rc = -1; char *field = strchr(param->field, '_'); @@ -341,7 +341,7 @@ virHostMemParametersAreAllSupported(virTypedParameterPtr params, size_t i; for (i = 0; i < nparams; i++) { - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; virTypedParameterPtr param = ¶ms[i]; char *field = strchr(param->field, '_'); @@ -408,8 +408,8 @@ static int virHostMemGetParameterValue(const char *field, void *value) { - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *path = NULL; + g_autofree char *buf = NULL; char *tmp = NULL; int rc = -1; diff --git a/src/util/viriptables.c b/src/util/viriptables.c index e1b876d36c..e240b97d72 100644 --- a/src/util/viriptables.c +++ b/src/util/viriptables.c @@ -344,7 +344,7 @@ static char *iptablesFormatNetwork(virSocketAddr *netaddr, unsigned int prefix) { virSocketAddr network; - VIR_AUTOFREE(char *) netstr = NULL; + g_autofree char *netstr = NULL; char *ret; if (!(VIR_SOCKET_ADDR_IS_FAMILY(netaddr, AF_INET) || @@ -383,7 +383,7 @@ iptablesForwardAllowOut(virFirewallPtr fw, const char *physdev, int action) { - VIR_AUTOFREE(char *) networkstr = NULL; + g_autofree char *networkstr = NULL; virFirewallLayer layer = VIR_SOCKET_ADDR_FAMILY(netaddr) == AF_INET ? VIR_FIREWALL_LAYER_IPV4 : VIR_FIREWALL_LAYER_IPV6; @@ -474,7 +474,7 @@ iptablesForwardAllowRelatedIn(virFirewallPtr fw, { virFirewallLayer layer = VIR_SOCKET_ADDR_FAMILY(netaddr) == AF_INET ? VIR_FIREWALL_LAYER_IPV4 : VIR_FIREWALL_LAYER_IPV6; - VIR_AUTOFREE(char *) networkstr = NULL; + g_autofree char *networkstr = NULL; if (!(networkstr = iptablesFormatNetwork(netaddr, prefix))) return -1; @@ -565,7 +565,7 @@ iptablesForwardAllowIn(virFirewallPtr fw, { virFirewallLayer layer = VIR_SOCKET_ADDR_FAMILY(netaddr) == AF_INET ? VIR_FIREWALL_LAYER_IPV4 : VIR_FIREWALL_LAYER_IPV6; - VIR_AUTOFREE(char *) networkstr = NULL; + g_autofree char *networkstr = NULL; if (!(networkstr = iptablesFormatNetwork(netaddr, prefix))) return -1; @@ -813,11 +813,11 @@ iptablesForwardMasquerade(virFirewallPtr fw, const char *protocol, int action) { - VIR_AUTOFREE(char *) networkstr = NULL; - VIR_AUTOFREE(char *) addrStartStr = NULL; - VIR_AUTOFREE(char *) addrEndStr = NULL; - VIR_AUTOFREE(char *) portRangeStr = NULL; - VIR_AUTOFREE(char *) natRangeStr = NULL; + g_autofree char *networkstr = NULL; + g_autofree char *addrStartStr = NULL; + g_autofree char *addrEndStr = NULL; + g_autofree char *portRangeStr = NULL; + g_autofree char *natRangeStr = NULL; virFirewallRulePtr rule; if (!(networkstr = iptablesFormatNetwork(netaddr, prefix))) @@ -974,7 +974,7 @@ iptablesForwardDontMasquerade(virFirewallPtr fw, const char *destaddr, int action) { - VIR_AUTOFREE(char *) networkstr = NULL; + g_autofree char *networkstr = NULL; if (!(networkstr = iptablesFormatNetwork(netaddr, prefix))) return -1; diff --git a/src/util/viriscsi.c b/src/util/viriscsi.c index 25b77eead7..f2140b47de 100644 --- a/src/util/viriscsi.c +++ b/src/util/viriscsi.c @@ -88,7 +88,7 @@ virISCSIGetSession(const char *devpath, .devpath = devpath, }; int exitstatus = 0; - VIR_AUTOFREE(char *) error = NULL; + g_autofree char *error = NULL; VIR_AUTOPTR(virCommand) cmd = virCommandNewArgList(ISCSIADM, "--mode", "session", NULL); @@ -122,9 +122,9 @@ virStorageBackendIQNFound(const char *initiatoriqn, { int ret = IQN_ERROR; char *line = NULL; - VIR_AUTOFREE(char *) outbuf = NULL; - VIR_AUTOFREE(char *) iface = NULL; - VIR_AUTOFREE(char *) iqn = NULL; + g_autofree char *outbuf = NULL; + g_autofree char *iface = NULL; + g_autofree char *iqn = NULL; VIR_AUTOPTR(virCommand) cmd = virCommandNewArgList(ISCSIADM, "--mode", "iface", NULL); @@ -208,8 +208,8 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriqn, char **ifacename) { int exitstatus = -1; - VIR_AUTOFREE(char *) iface_name = NULL; - VIR_AUTOFREE(char *) temp_ifacename = NULL; + g_autofree char *iface_name = NULL; + g_autofree char *temp_ifacename = NULL; VIR_AUTOPTR(virCommand) cmd = NULL; if (virAsprintf(&temp_ifacename, @@ -286,7 +286,7 @@ virISCSIConnection(const char *portal, NULL }; VIR_AUTOPTR(virCommand) cmd = NULL; - VIR_AUTOFREE(char *) ifacename = NULL; + g_autofree char *ifacename = NULL; cmd = virCommandNewArgs(baseargv); virCommandAddArgSet(cmd, extraargv); @@ -369,7 +369,7 @@ virISCSIGetTargets(char **const groups, void *data) { struct virISCSITargetList *list = data; - VIR_AUTOFREE(char *) target = NULL; + g_autofree char *target = NULL; if (VIR_STRDUP(target, groups[1]) < 0) return -1; @@ -471,7 +471,7 @@ virISCSIScanTargets(const char *portal, size_t *ntargets, char ***targets) { - VIR_AUTOFREE(char *) ifacename = NULL; + g_autofree char *ifacename = NULL; if (ntargets) *ntargets = 0; diff --git a/src/util/virjson.c b/src/util/virjson.c index 5e3c00a19c..c876a4a261 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -502,7 +502,7 @@ virJSONValueNewNumber(const char *data) virJSONValuePtr virJSONValueNewNumberInt(int data) { - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; if (virAsprintf(&str, "%i", data) < 0) return NULL; return virJSONValueNewNumber(str); @@ -512,7 +512,7 @@ virJSONValueNewNumberInt(int data) virJSONValuePtr virJSONValueNewNumberUint(unsigned int data) { - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; if (virAsprintf(&str, "%u", data) < 0) return NULL; return virJSONValueNewNumber(str); @@ -522,7 +522,7 @@ virJSONValueNewNumberUint(unsigned int data) virJSONValuePtr virJSONValueNewNumberLong(long long data) { - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; if (virAsprintf(&str, "%lld", data) < 0) return NULL; return virJSONValueNewNumber(str); @@ -532,7 +532,7 @@ virJSONValueNewNumberLong(long long data) virJSONValuePtr virJSONValueNewNumberUlong(unsigned long long data) { - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; if (virAsprintf(&str, "%llu", data) < 0) return NULL; return virJSONValueNewNumber(str); @@ -542,7 +542,7 @@ virJSONValueNewNumberUlong(unsigned long long data) virJSONValuePtr virJSONValueNewNumberDouble(double data) { - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; if (virDoubleToStr(&str, data) < 0) return NULL; return virJSONValueNewNumber(str); @@ -1215,7 +1215,7 @@ virJSONValueGetArrayAsBitmap(const virJSONValue *val, { virJSONValuePtr elem; size_t i; - VIR_AUTOFREE(unsigned long long *) elems = NULL; + g_autofree unsigned long long *elems = NULL; unsigned long long maxelem = 0; *bitmap = NULL; diff --git a/src/util/virkmod.c b/src/util/virkmod.c index 9d0375b911..56758750ae 100644 --- a/src/util/virkmod.c +++ b/src/util/virkmod.c @@ -146,8 +146,8 @@ bool virKModIsBlacklisted(const char *module) { size_t i; - VIR_AUTOFREE(char *) drvblklst = NULL; - VIR_AUTOFREE(char *) outbuf = NULL; + g_autofree char *drvblklst = NULL; + g_autofree char *outbuf = NULL; if (virAsprintfQuiet(&drvblklst, "blacklist %s\n", module) < 0) return false; diff --git a/src/util/virlease.c b/src/util/virlease.c index 87e9a3ce88..79fdd0699d 100644 --- a/src/util/virlease.c +++ b/src/util/virlease.c @@ -48,7 +48,7 @@ virLeaseReadCustomLeaseFile(virJSONValuePtr leases_array_new, const char *ip_to_delete, char **server_duid) { - VIR_AUTOFREE(char *) lease_entries = NULL; + g_autofree char *lease_entries = NULL; VIR_AUTOPTR(virJSONValue) leases_array = NULL; long long expirytime; int custom_lease_file_len = 0; @@ -215,7 +215,7 @@ virLeaseNew(virJSONValuePtr *lease_ret, VIR_AUTOPTR(virJSONValue) lease_new = NULL; const char *exptime_tmp = getenv("DNSMASQ_LEASE_EXPIRES"); long long expirytime = 0; - VIR_AUTOFREE(char *) exptime = NULL; + g_autofree char *exptime = NULL; /* In case hostname is still unknown, use the last known one */ if (!hostname) diff --git a/src/util/virmdev.c b/src/util/virmdev.c index 7700ae2ae8..7260799e5d 100644 --- a/src/util/virmdev.c +++ b/src/util/virmdev.c @@ -76,8 +76,8 @@ static int virMediatedDeviceGetSysfsDeviceAPI(virMediatedDevicePtr dev, char **device_api) { - VIR_AUTOFREE(char *) buf = NULL; - VIR_AUTOFREE(char *) file = NULL; + g_autofree char *buf = NULL; + g_autofree char *file = NULL; char *tmp = NULL; if (virAsprintf(&file, "%s/mdev_type/device_api", dev->path) < 0) @@ -108,7 +108,7 @@ static int virMediatedDeviceCheckModel(virMediatedDevicePtr dev, virMediatedDeviceModelType model) { - VIR_AUTOFREE(char *) dev_api = NULL; + g_autofree char *dev_api = NULL; int actual_model; if (virMediatedDeviceGetSysfsDeviceAPI(dev, &dev_api) < 0) @@ -142,7 +142,7 @@ virMediatedDeviceNew(const char *uuidstr, virMediatedDeviceModelType model) { virMediatedDevicePtr ret = NULL; VIR_AUTOPTR(virMediatedDevice) dev = NULL; - VIR_AUTOFREE(char *) sysfspath = NULL; + g_autofree char *sysfspath = NULL; if (!(sysfspath = virMediatedDeviceGetSysfsPath(uuidstr))) return NULL; @@ -210,9 +210,9 @@ virMediatedDeviceGetPath(virMediatedDevicePtr dev) char * virMediatedDeviceGetIOMMUGroupDev(const char *uuidstr) { - VIR_AUTOFREE(char *) result_path = NULL; - VIR_AUTOFREE(char *) iommu_path = NULL; - VIR_AUTOFREE(char *) dev_path = virMediatedDeviceGetSysfsPath(uuidstr); + g_autofree char *result_path = NULL; + g_autofree char *iommu_path = NULL; + g_autofree char *dev_path = virMediatedDeviceGetSysfsPath(uuidstr); char *vfio_path = NULL; if (!dev_path) @@ -241,7 +241,7 @@ virMediatedDeviceGetIOMMUGroupDev(const char *uuidstr) int virMediatedDeviceGetIOMMUGroupNum(const char *uuidstr) { - VIR_AUTOFREE(char *) vfio_path = NULL; + g_autofree char *vfio_path = NULL; char *group_num_str = NULL; unsigned int group_num = -1; diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c index 50e90e2792..edaf1e7c34 100644 --- a/src/util/virnetdevbridge.c +++ b/src/util/virnetdevbridge.c @@ -120,7 +120,7 @@ static int virNetDevBridgeSet(const char *brname, int fd, /* control socket */ struct ifreq *ifr) /* pre-filled bridge name */ { - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; if (virAsprintf(&path, SYSFS_NET_DIR "%s/bridge/%s", brname, paramname) < 0) return -1; @@ -162,14 +162,14 @@ static int virNetDevBridgeGet(const char *brname, unsigned long *value) /* current value */ { struct ifreq ifr; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; VIR_AUTOCLOSE fd = -1; if (virAsprintf(&path, SYSFS_NET_DIR "%s/bridge/%s", brname, paramname) < 0) return -1; if (virFileExists(path)) { - VIR_AUTOFREE(char *) valuestr = NULL; + g_autofree char *valuestr = NULL; if (virFileReadAll(path, INT_BUFSIZE_BOUND(unsigned long), &valuestr) < 0) @@ -219,7 +219,7 @@ virNetDevBridgePortSet(const char *brname, { char valuestr[INT_BUFSIZE_BOUND(value)]; int ret = -1; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; snprintf(valuestr, sizeof(valuestr), "%lu", value); @@ -248,8 +248,8 @@ virNetDevBridgePortGet(const char *brname, const char *paramname, unsigned long *value) { - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(char *) valuestr = NULL; + g_autofree char *path = NULL; + g_autofree char *valuestr = NULL; if (virAsprintf(&path, SYSFS_NET_DIR "%s/brif/%s/%s", brname, ifname, paramname) < 0) @@ -953,7 +953,7 @@ virNetDevBridgeFDBAddDel(const virMacAddr *mac, const char *ifname, unsigned int recvbuflen; struct ndmsg ndm = { .ndm_family = PF_BRIDGE, .ndm_state = NUD_NOARP }; VIR_AUTOPTR(virNetlinkMsg) nl_msg = NULL; - VIR_AUTOFREE(struct nlmsghdr *) resp = NULL; + g_autofree struct nlmsghdr *resp = NULL; if (virNetDevGetIndex(ifname, &ndm.ndm_ifindex) < 0) return -1; diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c index dea3de6514..bc31581f77 100644 --- a/src/util/virnetdevip.c +++ b/src/util/virnetdevip.c @@ -168,10 +168,10 @@ virNetDevIPAddrAdd(const char *ifname, unsigned int recvbuflen; VIR_AUTOPTR(virNetlinkMsg) nlmsg = NULL; VIR_AUTOPTR(virSocketAddr) broadcast = NULL; - VIR_AUTOFREE(struct nlmsghdr *) resp = NULL; - VIR_AUTOFREE(char *) ipStr = NULL; - VIR_AUTOFREE(char *) peerStr = NULL; - VIR_AUTOFREE(char *) bcastStr = NULL; + g_autofree struct nlmsghdr *resp = NULL; + g_autofree char *ipStr = NULL; + g_autofree char *peerStr = NULL; + g_autofree char *bcastStr = NULL; ipStr = virSocketAddrFormat(addr); if (peer && VIR_SOCKET_ADDR_VALID(peer)) @@ -240,7 +240,7 @@ virNetDevIPAddrDel(const char *ifname, { unsigned int recvbuflen; VIR_AUTOPTR(virNetlinkMsg) nlmsg = NULL; - VIR_AUTOFREE(struct nlmsghdr *) resp = NULL; + g_autofree struct nlmsghdr *resp = NULL; if (!(nlmsg = virNetDevCreateNetlinkAddressMessage(RTM_DELADDR, ifname, addr, prefix, @@ -290,9 +290,9 @@ virNetDevIPRouteAdd(const char *ifname, virSocketAddr defaultAddr; virSocketAddrPtr actualAddr; VIR_AUTOPTR(virNetlinkMsg) nlmsg = NULL; - VIR_AUTOFREE(char *) toStr = NULL; - VIR_AUTOFREE(char *) viaStr = NULL; - VIR_AUTOFREE(struct nlmsghdr *) resp = NULL; + g_autofree char *toStr = NULL; + g_autofree char *viaStr = NULL; + g_autofree struct nlmsghdr *resp = NULL; actualAddr = addr; @@ -450,7 +450,7 @@ virNetDevIPWaitDadFinish(virSocketAddrPtr *addrs, size_t count) /* Periodically query netlink until DAD finishes on all known addresses. */ while (dad && time(NULL) < max_time) { - VIR_AUTOFREE(struct nlmsghdr *) resp = NULL; + g_autofree struct nlmsghdr *resp = NULL; if (virNetlinkCommand(nlmsg, &resp, &recvbuflen, 0, 0, NETLINK_ROUTE, 0) < 0) @@ -482,8 +482,8 @@ virNetDevIPWaitDadFinish(virSocketAddrPtr *addrs, size_t count) static int virNetDevIPGetAcceptRA(const char *ifname) { - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *path = NULL; + g_autofree char *buf = NULL; char *suffix; int accept_ra = -1; @@ -534,7 +534,7 @@ virNetDevIPCheckIPv6ForwardingCallback(struct nlmsghdr *resp, struct rtattr *rta_attr; int accept_ra = -1; int ifindex = -1; - VIR_AUTOFREE(char *) ifname = NULL; + g_autofree char *ifname = NULL; /* Ignore messages other than route ones */ if (resp->nlmsg_type != RTM_NEWROUTE) @@ -689,9 +689,9 @@ virNetDevIPAddrAdd(const char *ifname, { virSocketAddr broadcast; VIR_AUTOPTR(virCommand) cmd = NULL; - VIR_AUTOFREE(char *) addrstr = NULL; - VIR_AUTOFREE(char *) bcaststr = NULL; - VIR_AUTOFREE(char *) peerstr = NULL; + g_autofree char *addrstr = NULL; + g_autofree char *bcaststr = NULL; + g_autofree char *peerstr = NULL; if (!(addrstr = virSocketAddrFormat(addr))) return -1; @@ -744,7 +744,7 @@ virNetDevIPAddrDel(const char *ifname, unsigned int prefix) { VIR_AUTOPTR(virCommand) cmd = NULL; - VIR_AUTOFREE(char *) addrstr = NULL; + g_autofree char *addrstr = NULL; if (!(addrstr = virSocketAddrFormat(addr))) return -1; @@ -779,8 +779,8 @@ virNetDevIPRouteAdd(const char *ifname, unsigned int metric) { VIR_AUTOPTR(virCommand) cmd = NULL; - VIR_AUTOFREE(char *) addrstr = NULL; - VIR_AUTOFREE(char *) gatewaystr = NULL; + g_autofree char *addrstr = NULL; + g_autofree char *gatewaystr = NULL; if (!(addrstr = virSocketAddrFormat(addr))) return -1; @@ -1072,7 +1072,7 @@ virNetDevIPInfoAddToDev(const char *ifname, { size_t i; int prefix; - VIR_AUTOFREE(char *) ipStr = NULL; + g_autofree char *ipStr = NULL; /* add all IP addresses */ for (i = 0; i < ipInfo->nips; i++) { diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c index 1ee503afb6..0e02824acc 100644 --- a/src/util/virnetdevmacvlan.c +++ b/src/util/virnetdevmacvlan.c @@ -289,7 +289,7 @@ bool virNetDevMacVLanIsMacvtap(const char *ifname) { int ifindex; - VIR_AUTOFREE(char *) tapname = NULL; + g_autofree char *tapname = NULL; if (virNetDevGetIndex(ifname, &ifindex) < 0) return false; @@ -388,7 +388,7 @@ virNetDevMacVLanTapOpen(const char *ifname, int ret = -1; int ifindex; size_t i = 0; - VIR_AUTOFREE(char *) tapname = NULL; + g_autofree char *tapname = NULL; if (virNetDevGetIndex(ifname, &ifindex) < 0) return -1; diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c index 3066ef9cde..a3c0da85a0 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -142,10 +142,10 @@ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname, char ifuuidstr[VIR_UUID_STRING_BUFLEN]; char vmuuidstr[VIR_UUID_STRING_BUFLEN]; VIR_AUTOPTR(virCommand) cmd = NULL; - VIR_AUTOFREE(char *) attachedmac_ex_id = NULL; - VIR_AUTOFREE(char *) ifaceid_ex_id = NULL; - VIR_AUTOFREE(char *) profile_ex_id = NULL; - VIR_AUTOFREE(char *) vmid_ex_id = NULL; + g_autofree char *attachedmac_ex_id = NULL; + g_autofree char *ifaceid_ex_id = NULL; + g_autofree char *profile_ex_id = NULL; + g_autofree char *vmid_ex_id = NULL; virMacAddrFormat(macaddr, macaddrstr); virUUIDFormat(ovsport->interfaceID, ifuuidstr); @@ -387,7 +387,7 @@ virNetDevOpenvswitchInterfaceStats(const char *ifname, virDomainInterfaceStatsPtr stats) { VIR_AUTOPTR(virCommand) cmd = NULL; - VIR_AUTOFREE(char *) output = NULL; + g_autofree char *output = NULL; cmd = virCommandNew(OVSVSCTL); virNetDevOpenvswitchAddTimeout(cmd); diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index c2d7040938..b4637a91f9 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -393,7 +393,7 @@ int virNetDevTapCreate(char **ifname, if (strstr(*ifname, "%d") != NULL) { size_t i; for (i = 0; i <= IF_MAXUNIT; i++) { - VIR_AUTOFREE(char *) newname = NULL; + g_autofree char *newname = NULL; if (virAsprintf(&newname, *ifname, i) < 0) goto cleanup; @@ -415,7 +415,7 @@ int virNetDevTapCreate(char **ifname, } if (tapfd) { - VIR_AUTOFREE(char *) dev_path = NULL; + g_autofree char *dev_path = NULL; if (virAsprintf(&dev_path, "/dev/%s", ifr.ifr_name) < 0) goto cleanup; @@ -580,7 +580,7 @@ virNetDevTapReattachBridge(const char *tapname, unsigned int *actualMTU) { bool useOVS = false; - VIR_AUTOFREE(char *) master = NULL; + g_autofree char *master = NULL; if (virNetDevGetMaster(tapname, &master) < 0) return -1; diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c index 431dc0bff5..36a1e89c9e 100644 --- a/src/util/virnetdevveth.c +++ b/src/util/virnetdevveth.c @@ -42,7 +42,7 @@ virMutex virNetDevVethCreateMutex = VIR_MUTEX_INITIALIZER; static int virNetDevVethExists(int devNum) { int ret; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; if (virAsprintf(&path, SYSFS_NET_DIR "vnet%d/", devNum) < 0) return -1; @@ -118,8 +118,8 @@ int virNetDevVethCreate(char** veth1, char** veth2) #define MAX_VETH_RETRIES 10 for (i = 0; i < MAX_VETH_RETRIES; i++) { - VIR_AUTOFREE(char *) veth1auto = NULL; - VIR_AUTOFREE(char *) veth2auto = NULL; + g_autofree char *veth1auto = NULL; + g_autofree char *veth2auto = NULL; VIR_AUTOPTR(virCommand) cmd = NULL; int status; diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index f07eb2f2e2..901e04845c 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -296,7 +296,7 @@ int virNetlinkCommand(struct nl_msg *nl_msg, .nl_groups = 0, }; struct pollfd fds[1]; - VIR_AUTOFREE(struct nlmsghdr *) temp_resp = NULL; + g_autofree struct nlmsghdr *temp_resp = NULL; VIR_AUTOPTR(virNetlinkHandle) nlhandle = NULL; int len = 0; @@ -345,7 +345,7 @@ virNetlinkDumpCommand(struct nl_msg *nl_msg, return -1; while (!end) { - VIR_AUTOFREE(struct nlmsghdr *) resp = NULL; + g_autofree struct nlmsghdr *resp = NULL; len = nl_recv(nlhandle, &nladdr, (unsigned char **)&resp, NULL); VIR_WARNINGS_NO_CAST_ALIGN @@ -397,7 +397,7 @@ virNetlinkDumpLink(const char *ifname, int ifindex, }; unsigned int recvbuflen; VIR_AUTOPTR(virNetlinkMsg) nl_msg = NULL; - VIR_AUTOFREE(struct nlmsghdr *) resp = NULL; + g_autofree struct nlmsghdr *resp = NULL; if (ifname && ifindex <= 0 && virNetDevGetIndex(ifname, &ifindex) < 0) return -1; @@ -508,7 +508,7 @@ virNetlinkNewLink(const char *ifname, unsigned int buflen; struct ifinfomsg ifinfo = { .ifi_family = AF_UNSPEC }; VIR_AUTOPTR(virNetlinkMsg) nl_msg = NULL; - VIR_AUTOFREE(struct nlmsghdr *) resp = NULL; + g_autofree struct nlmsghdr *resp = NULL; *error = 0; @@ -614,7 +614,7 @@ virNetlinkDelLink(const char *ifname, virNetlinkDelLinkFallback fallback) struct ifinfomsg ifinfo = { .ifi_family = AF_UNSPEC }; unsigned int recvbuflen; VIR_AUTOPTR(virNetlinkMsg) nl_msg = NULL; - VIR_AUTOFREE(struct nlmsghdr *) resp = NULL; + g_autofree struct nlmsghdr *resp = NULL; nl_msg = nlmsg_alloc_simple(RTM_DELLINK, NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL); @@ -698,7 +698,7 @@ virNetlinkGetNeighbor(void **nlData, uint32_t src_pid, uint32_t dst_pid) }; unsigned int recvbuflen; VIR_AUTOPTR(virNetlinkMsg) nl_msg = NULL; - VIR_AUTOFREE(struct nlmsghdr *) resp = NULL; + g_autofree struct nlmsghdr *resp = NULL; nl_msg = nlmsg_alloc_simple(RTM_GETNEIGH, NLM_F_DUMP | NLM_F_REQUEST); if (!nl_msg) { @@ -848,7 +848,7 @@ virNetlinkEventCallback(int watch, size_t i; int length; bool handled = false; - VIR_AUTOFREE(struct nlmsghdr *) msg = NULL; + g_autofree struct nlmsghdr *msg = NULL; length = nl_recv(srv->netlinknh, &peer, (unsigned char **)&msg, &creds); diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c index 9ce3566ecf..c58d429fdb 100644 --- a/src/util/virnodesuspend.c +++ b/src/util/virnodesuspend.c @@ -240,7 +240,7 @@ static int virNodeSuspendSupportsTargetPMUtils(unsigned int target, bool *supported) { VIR_AUTOPTR(virCommand) cmd = NULL; - VIR_AUTOFREE(char *) binary = NULL; + g_autofree char *binary = NULL; int status; *supported = false; diff --git a/src/util/virnuma.c b/src/util/virnuma.c index f5704e7722..37a5fc894b 100644 --- a/src/util/virnuma.c +++ b/src/util/virnuma.c @@ -257,8 +257,8 @@ virNumaGetNodeCPUs(int node, int max_n_cpus = virNumaGetMaxCPUs(); int mask_n_bytes = max_n_cpus / 8; size_t i; - VIR_AUTOFREE(unsigned long *) mask = NULL; - VIR_AUTOFREE(unsigned long *) allonesmask = NULL; + g_autofree unsigned long *mask = NULL; + g_autofree unsigned long *allonesmask = NULL; VIR_AUTOPTR(virBitmap) cpumap = NULL; *cpus = NULL; @@ -612,8 +612,8 @@ virNumaGetHugePageInfo(int node, unsigned long long *page_free) { char *end; - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *path = NULL; + g_autofree char *buf = NULL; if (page_avail) { if (virNumaGetHugePageInfoPath(&path, node, @@ -762,10 +762,10 @@ virNumaGetPages(int node, bool exchange; long system_page_size; unsigned long long huge_page_sum = 0; - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(unsigned int *) tmp_size = NULL; - VIR_AUTOFREE(unsigned long long *) tmp_avail = NULL; - VIR_AUTOFREE(unsigned long long *) tmp_free = NULL; + g_autofree char *path = NULL; + g_autofree unsigned int *tmp_size = NULL; + g_autofree unsigned long long *tmp_avail = NULL; + g_autofree unsigned long long *tmp_free = NULL; /* sysconf() returns page size in bytes, * but we are storing the page size in kibibytes. */ @@ -881,8 +881,8 @@ virNumaSetPagePoolSize(int node, { char *end; unsigned long long nr_count; - VIR_AUTOFREE(char *) nr_path = NULL; - VIR_AUTOFREE(char *) nr_buf = NULL; + g_autofree char *nr_path = NULL; + g_autofree char *nr_buf = NULL; if (page_size == virGetSystemPageSizeKB()) { /* Special case as kernel handles system pages diff --git a/src/util/virpci.c b/src/util/virpci.c index 169501e731..ed053ed9f5 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -239,7 +239,7 @@ int virPCIDeviceGetDriverPathAndName(virPCIDevicePtr dev, char **path, char **name) { int ret = -1; - VIR_AUTOFREE(char *) drvlink = NULL; + g_autofree char *drvlink = NULL; *path = *name = NULL; /* drvlink = "/sys/bus/pci/dddd:bb:ss.ff/driver" */ @@ -378,8 +378,8 @@ virPCIDeviceRead32(virPCIDevicePtr dev, int cfgfd, unsigned int pos) static int virPCIDeviceReadClass(virPCIDevicePtr dev, uint16_t *device_class) { - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(char *) id_str = NULL; + g_autofree char *path = NULL; + g_autofree char *id_str = NULL; unsigned int value; if (!(path = virPCIFile(dev->name, "class"))) @@ -569,7 +569,7 @@ virPCIDeviceDetectFunctionLevelReset(virPCIDevicePtr dev, int cfgfd) { uint32_t caps; uint8_t pos; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; int found; /* The PCIe Function Level Reset capability allows @@ -919,8 +919,8 @@ virPCIDeviceReset(virPCIDevicePtr dev, virPCIDeviceList *activeDevs, virPCIDeviceList *inactiveDevs) { - VIR_AUTOFREE(char *) drvPath = NULL; - VIR_AUTOFREE(char *) drvName = NULL; + g_autofree char *drvPath = NULL; + g_autofree char *drvName = NULL; int ret = -1; int fd = -1; int hdrType = -1; @@ -1002,7 +1002,7 @@ static int virPCIProbeStubDriver(virPCIStubDriver driver) { const char *drvname = NULL; - VIR_AUTOFREE(char *) drvpath = NULL; + g_autofree char *drvpath = NULL; bool probed = false; if (driver == VIR_PCI_STUB_DRIVER_NONE || @@ -1019,7 +1019,7 @@ virPCIProbeStubDriver(virPCIStubDriver driver) return 0; if (!probed) { - VIR_AUTOFREE(char *) errbuf = NULL; + g_autofree char *errbuf = NULL; probed = true; if ((errbuf = virKModLoad(drvname, true))) { VIR_WARN("failed to load driver %s: %s", drvname, errbuf); @@ -1050,9 +1050,9 @@ virPCIProbeStubDriver(virPCIStubDriver driver) int virPCIDeviceUnbind(virPCIDevicePtr dev) { - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(char *) drvpath = NULL; - VIR_AUTOFREE(char *) driver = NULL; + g_autofree char *path = NULL; + g_autofree char *drvpath = NULL; + g_autofree char *driver = NULL; if (virPCIDeviceGetDriverPathAndName(dev, &drvpath, &driver) < 0) return -1; @@ -1116,7 +1116,7 @@ static int virPCIDeviceBindWithDriverOverride(virPCIDevicePtr dev, const char *driverName) { - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; if (!(path = virPCIFile(dev->name, "driver_override"))) return -1; @@ -1150,8 +1150,8 @@ static int virPCIDeviceBindToStub(virPCIDevicePtr dev) { const char *stubDriverName; - VIR_AUTOFREE(char *) stubDriverPath = NULL; - VIR_AUTOFREE(char *) driverLink = NULL; + g_autofree char *stubDriverPath = NULL; + g_autofree char *driverLink = NULL; /* Check the device is configured to use one of the known stub drivers */ if (dev->stubDriver == VIR_PCI_STUB_DRIVER_NONE) { @@ -1263,7 +1263,7 @@ virPCIDeviceReattach(virPCIDevicePtr dev, static char * virPCIDeviceReadID(virPCIDevicePtr dev, const char *id_name) { - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; char *id_str; if (!(path = virPCIFile(dev->name, id_name))) @@ -1371,8 +1371,8 @@ virPCIDeviceNew(unsigned int domain, unsigned int function) { VIR_AUTOPTR(virPCIDevice) dev = NULL; - VIR_AUTOFREE(char *) vendor = NULL; - VIR_AUTOFREE(char *) product = NULL; + g_autofree char *vendor = NULL; + g_autofree char *product = NULL; if (VIR_ALLOC(dev) < 0) return NULL; @@ -1736,7 +1736,7 @@ int virPCIDeviceFileIterate(virPCIDevicePtr dev, virPCIDeviceFileActor actor, void *opaque) { - VIR_AUTOFREE(char *) pcidir = NULL; + g_autofree char *pcidir = NULL; DIR *dir = NULL; int ret = -1; struct dirent *ent; @@ -1751,7 +1751,7 @@ int virPCIDeviceFileIterate(virPCIDevicePtr dev, goto cleanup; while ((direrr = virDirRead(dir, &ent, pcidir)) > 0) { - VIR_AUTOFREE(char *) file = NULL; + g_autofree char *file = NULL; /* Device assignment requires: * $PCIDIR/config, $PCIDIR/resource, $PCIDIR/resourceNNN, * $PCIDIR/rom, $PCIDIR/reset, $PCIDIR/vendor, $PCIDIR/device @@ -1789,7 +1789,7 @@ virPCIDeviceAddressIOMMUGroupIterate(virPCIDeviceAddressPtr orig, virPCIDeviceAddressActor actor, void *opaque) { - VIR_AUTOFREE(char *) groupPath = NULL; + g_autofree char *groupPath = NULL; DIR *groupDir = NULL; int ret = -1; struct dirent *ent; @@ -1939,9 +1939,9 @@ virPCIDeviceAddressGetIOMMUGroupAddresses(virPCIDeviceAddressPtr devAddr, int virPCIDeviceAddressGetIOMMUGroupNum(virPCIDeviceAddressPtr addr) { - VIR_AUTOFREE(char *) devName = NULL; - VIR_AUTOFREE(char *) devPath = NULL; - VIR_AUTOFREE(char *) groupPath = NULL; + g_autofree char *devName = NULL; + g_autofree char *devPath = NULL; + g_autofree char *groupPath = NULL; const char *groupNumStr; unsigned int groupNum; @@ -1980,8 +1980,8 @@ virPCIDeviceAddressGetIOMMUGroupNum(virPCIDeviceAddressPtr addr) char * virPCIDeviceGetIOMMUGroupDev(virPCIDevicePtr dev) { - VIR_AUTOFREE(char *) devPath = NULL; - VIR_AUTOFREE(char *) groupPath = NULL; + g_autofree char *devPath = NULL; + g_autofree char *groupPath = NULL; char *groupDev = NULL; if (!(devPath = virPCIFile(dev->name, "iommu_group"))) @@ -2213,7 +2213,7 @@ virPCIGetDeviceAddressFromSysfsLink(const char *device_link) { virPCIDeviceAddressPtr bdf = NULL; char *config_address = NULL; - VIR_AUTOFREE(char *) device_path = NULL; + g_autofree char *device_path = NULL; if (!virFileExists(device_link)) { VIR_DEBUG("'%s' does not exist", device_link); @@ -2261,7 +2261,7 @@ int virPCIGetPhysicalFunction(const char *vf_sysfs_path, virPCIDeviceAddressPtr *pf) { - VIR_AUTOFREE(char *) device_link = NULL; + g_autofree char *device_link = NULL; *pf = NULL; @@ -2291,8 +2291,8 @@ virPCIGetVirtualFunctions(const char *sysfs_path, { int ret = -1; size_t i; - VIR_AUTOFREE(char *) totalvfs_file = NULL; - VIR_AUTOFREE(char *) totalvfs_str = NULL; + g_autofree char *totalvfs_file = NULL; + g_autofree char *totalvfs_str = NULL; virPCIDeviceAddressPtr config_addr = NULL; *virtual_functions = NULL; @@ -2315,7 +2315,7 @@ virPCIGetVirtualFunctions(const char *sysfs_path, } do { - VIR_AUTOFREE(char *) device_link = NULL; + g_autofree char *device_link = NULL; /* look for virtfn%d links until one isn't found */ if (virAsprintf(&device_link, "%s/virtfn%zu", sysfs_path, *num_virtual_functions) < 0) goto error; @@ -2357,7 +2357,7 @@ virPCIGetVirtualFunctions(const char *sysfs_path, int virPCIIsVirtualFunction(const char *vf_sysfs_device_link) { - VIR_AUTOFREE(char *) vf_sysfs_physfn_link = NULL; + g_autofree char *vf_sysfs_physfn_link = NULL; if (virAsprintf(&vf_sysfs_physfn_link, "%s/physfn", vf_sysfs_device_link) < 0) @@ -2455,9 +2455,9 @@ virPCIGetNetName(const char *device_link_sysfs_path, char *physPortID, char **netname) { - VIR_AUTOFREE(char *) pcidev_sysfs_net_path = NULL; - VIR_AUTOFREE(char *) firstEntryName = NULL; - VIR_AUTOFREE(char *) thisPhysPortID = NULL; + g_autofree char *pcidev_sysfs_net_path = NULL; + g_autofree char *firstEntryName = NULL; + g_autofree char *thisPhysPortID = NULL; int ret = -1; DIR *dir = NULL; struct dirent *entry = NULL; @@ -2545,9 +2545,9 @@ virPCIGetVirtualFunctionInfo(const char *vf_sysfs_device_path, int *vf_index) { virPCIDeviceAddressPtr pf_config_address = NULL; - VIR_AUTOFREE(char *) pf_sysfs_device_path = NULL; - VIR_AUTOFREE(char *) vfname = NULL; - VIR_AUTOFREE(char *) vfPhysPortID = NULL; + g_autofree char *pf_sysfs_device_path = NULL; + g_autofree char *vfname = NULL; + g_autofree char *vfPhysPortID = NULL; int ret = -1; if (virPCIGetPhysicalFunction(vf_sysfs_device_path, &pf_config_address) < 0) @@ -2615,7 +2615,7 @@ virPCIGetMdevTypes(const char *sysfspath, int dirret = -1; DIR *dir = NULL; struct dirent *entry; - VIR_AUTOFREE(char *) types_path = NULL; + g_autofree char *types_path = NULL; VIR_AUTOPTR(virMediatedDeviceType) mdev_type = NULL; virMediatedDeviceTypePtr *mdev_types = NULL; size_t ntypes = 0; @@ -2633,7 +2633,7 @@ virPCIGetMdevTypes(const char *sysfspath, } while ((dirret = virDirRead(dir, &entry, types_path)) > 0) { - VIR_AUTOFREE(char *) tmppath = NULL; + g_autofree char *tmppath = NULL; /* append the type id to the path and read the attributes from there */ if (virAsprintf(&tmppath, "%s/%s", types_path, entry->d_name) < 0) goto cleanup; diff --git a/src/util/virperf.c b/src/util/virperf.c index e334d415e4..fe2c3f8864 100644 --- a/src/util/virperf.c +++ b/src/util/virperf.c @@ -177,7 +177,7 @@ virPerfRdtAttrInit(void) { char *tmp = NULL; unsigned int attr_type = 0; - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *buf = NULL; if (virFileReadAllQuiet("/sys/devices/intel_cqm/type", 10, &buf) < 0) return -1; @@ -221,7 +221,7 @@ virPerfEventEnable(virPerfPtr perf, } if (type == VIR_PERF_EVENT_CMT) { - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *buf = NULL; if (virFileReadAll("/sys/devices/intel_cqm/events/llc_occupancy.scale", 10, &buf) < 0) diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c index 9c2206c618..f7849d91a6 100644 --- a/src/util/virpidfile.c +++ b/src/util/virpidfile.c @@ -97,7 +97,7 @@ int virPidFileWrite(const char *dir, const char *name, pid_t pid) { - VIR_AUTOFREE(char *) pidfile = NULL; + g_autofree char *pidfile = NULL; if (name == NULL || dir == NULL) return -EINVAL; @@ -159,7 +159,7 @@ int virPidFileRead(const char *dir, const char *name, pid_t *pid) { - VIR_AUTOFREE(char *) pidfile = NULL; + g_autofree char *pidfile = NULL; *pid = 0; @@ -204,10 +204,10 @@ int virPidFileReadPathIfAlive(const char *path, const char deletedText[] = " (deleted)"; size_t deletedTextLen = strlen(deletedText); pid_t retPid; - VIR_AUTOFREE(char *) procPath = NULL; - VIR_AUTOFREE(char *) procLink = NULL; - VIR_AUTOFREE(char *) resolvedBinPath = NULL; - VIR_AUTOFREE(char *) resolvedProcLink = NULL; + g_autofree char *procPath = NULL; + g_autofree char *procLink = NULL; + g_autofree char *resolvedBinPath = NULL; + g_autofree char *resolvedProcLink = NULL; /* only set this at the very end on success */ *pid = -1; @@ -300,7 +300,7 @@ int virPidFileReadIfAlive(const char *dir, pid_t *pid, const char *binpath) { - VIR_AUTOFREE(char *) pidfile = NULL; + g_autofree char *pidfile = NULL; if (name == NULL || dir == NULL) return -EINVAL; @@ -326,7 +326,7 @@ int virPidFileDeletePath(const char *pidfile) int virPidFileDelete(const char *dir, const char *name) { - VIR_AUTOFREE(char *) pidfile = NULL; + g_autofree char *pidfile = NULL; if (name == NULL || dir == NULL) return -EINVAL; @@ -426,7 +426,7 @@ int virPidFileAcquire(const char *dir, bool waitForLock, pid_t pid) { - VIR_AUTOFREE(char *) pidfile = NULL; + g_autofree char *pidfile = NULL; if (name == NULL || dir == NULL) return -EINVAL; @@ -465,7 +465,7 @@ int virPidFileRelease(const char *dir, const char *name, int fd) { - VIR_AUTOFREE(char *) pidfile = NULL; + g_autofree char *pidfile = NULL; if (name == NULL || dir == NULL) return -EINVAL; @@ -483,7 +483,7 @@ virPidFileConstructPath(bool privileged, const char *progname, char **pidfile) { - VIR_AUTOFREE(char *) rundir = NULL; + g_autofree char *rundir = NULL; if (privileged) { /* diff --git a/src/util/virprocess.c b/src/util/virprocess.c index e8d4ba08b4..b5fda05e0c 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -158,7 +158,7 @@ virProcessAbort(pid_t pid) int saved_errno; int ret; int status; - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree char *tmp = NULL; if (pid <= 0) return; @@ -237,7 +237,7 @@ virProcessWait(pid_t pid, int *exitstatus, bool raw) { int ret; int status; - VIR_AUTOFREE(char *) st = NULL; + g_autofree char *st = NULL; if (pid <= 0) { if (pid != -1) @@ -581,7 +581,7 @@ int virProcessGetPids(pid_t pid, size_t *npids, pid_t **pids) DIR *dir = NULL; int value; struct dirent *ent; - VIR_AUTOFREE(char *) taskPath = NULL; + g_autofree char *taskPath = NULL; *npids = 0; *pids = NULL; @@ -630,7 +630,7 @@ int virProcessGetNamespaces(pid_t pid, for (i = 0; i < G_N_ELEMENTS(ns); i++) { int fd; - VIR_AUTOFREE(char *) nsfile = NULL; + g_autofree char *nsfile = NULL; if (virAsprintf(&nsfile, "/proc/%llu/ns/%s", (long long) pid, @@ -950,8 +950,8 @@ int virProcessGetStartTime(pid_t pid, { char *tmp; int len; - VIR_AUTOFREE(char *) filename = NULL; - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *filename = NULL; + g_autofree char *buf = NULL; VIR_AUTOSTRINGLIST tokens = NULL; if (virAsprintf(&filename, "/proc/%llu/stat", (long long) pid) < 0) @@ -1052,7 +1052,7 @@ static int virProcessNamespaceHelper(pid_t pid G_GNUC_UNUSED, virProcessNamespaceHelperData *data = opaque; int fd = -1; int ret = -1; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; if (virAsprintf(&path, "/proc/%lld/ns/mnt", (long long) data->pid) < 0) goto cleanup; @@ -1157,7 +1157,7 @@ virProcessRunInFork(virProcessForkCallback cb, _exit(ret < 0 ? EXIT_CANCELED : ret); } else { int status; - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *buf = NULL; VIR_FORCE_CLOSE(errfd[1]); ignore_value(virFileReadHeaderFD(errfd[0], 1024, &buf)); @@ -1237,7 +1237,7 @@ virProcessNamespaceAvailable(unsigned int ns) int cpid; char *childStack; int stacksize = getpagesize() * 4; - VIR_AUTOFREE(char *)stack = NULL; + g_autofree char *stack = NULL; if (ns & VIR_PROCESS_NAMESPACE_MNT) flags |= CLONE_NEWNS; diff --git a/src/util/virqemu.c b/src/util/virqemu.c index 115109cb09..2fccfc24ff 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -87,7 +87,7 @@ virQEMUBuildCommandLineJSONArrayNumbered(const char *key, for (i = 0; i < virJSONValueArraySize(array); i++) { member = virJSONValueArrayGet((virJSONValuePtr) array, i); - VIR_AUTOFREE(char *) prefix = NULL; + g_autofree char *prefix = NULL; if (virAsprintf(&prefix, "%s.%zu", key, i) < 0) return 0; @@ -111,7 +111,7 @@ virQEMUBuildCommandLineJSONIterate(const char *key, struct virQEMUCommandLineJSONIteratorData *data = opaque; if (data->prefix) { - VIR_AUTOFREE(char *) tmpkey = NULL; + g_autofree char *tmpkey = NULL; if (virAsprintf(&tmpkey, "%s.%s", data->prefix, key) < 0) return -1; diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 90b77e6959..9b50c09221 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -2539,7 +2539,7 @@ int virResctrlMonitorDeterminePath(virResctrlMonitorPtr monitor, const char *machinename) { - VIR_AUTOFREE(char *) parentpath = NULL; + g_autofree char *parentpath = NULL; if (!monitor) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/util/virscsi.c b/src/util/virscsi.c index 6e167067e4..d2c68644fa 100644 --- a/src/util/virscsi.c +++ b/src/util/virscsi.c @@ -109,7 +109,7 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix, { DIR *dir = NULL; struct dirent *entry; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; char *sg = NULL; unsigned int adapter_id; const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_DEVICES; @@ -148,7 +148,7 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix, { DIR *dir = NULL; struct dirent *entry; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; char *name = NULL; unsigned int adapter_id; const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_DEVICES; @@ -185,11 +185,11 @@ virSCSIDeviceNew(const char *sysfs_prefix, { VIR_AUTOPTR(virSCSIDevice) dev = NULL; virSCSIDevicePtr ret = NULL; - VIR_AUTOFREE(char *) sg = NULL; - VIR_AUTOFREE(char *) vendor_path = NULL; - VIR_AUTOFREE(char *) model_path = NULL; - VIR_AUTOFREE(char *) vendor = NULL; - VIR_AUTOFREE(char *) model = NULL; + g_autofree char *sg = NULL; + g_autofree char *vendor_path = NULL; + g_autofree char *model_path = NULL; + g_autofree char *vendor = NULL; + g_autofree char *model = NULL; const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_DEVICES; if (VIR_ALLOC(dev) < 0) diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c index 77fadb008e..91e2a8d558 100644 --- a/src/util/virsocketaddr.c +++ b/src/util/virsocketaddr.c @@ -499,7 +499,7 @@ virSocketAddrFormatFull(const virSocketAddr *addr, } if (withService) { - VIR_AUTOFREE(char *) ipv6_host = NULL; + g_autofree char *ipv6_host = NULL; /* sasl_new_client demands the socket address to be in an odd format: * a.b.c.d;port or e:f:g:h:i:j:k:l;port, so use square brackets for * IPv6 only if no separator is passed to the function @@ -841,9 +841,9 @@ virSocketAddrGetRange(virSocketAddrPtr start, virSocketAddrPtr end, int ret = 0; size_t i; virSocketAddr netmask; - VIR_AUTOFREE(char *) startStr = NULL; - VIR_AUTOFREE(char *) endStr = NULL; - VIR_AUTOFREE(char *) netStr = NULL; + g_autofree char *startStr = NULL; + g_autofree char *endStr = NULL; + g_autofree char *netStr = NULL; if (start == NULL || end == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 6c2693fec9..5726e62e68 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -506,7 +506,7 @@ qcow2GetExtensions(const char *buf, switch (magic) { case QCOW2_HDR_EXTENSION_BACKING_FORMAT: { - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree char *tmp = NULL; if (!backingFormat) break; @@ -602,7 +602,7 @@ vmdk4GetBackingStore(char **res, char *start, *end; size_t len; int ret = BACKING_STORE_ERROR; - VIR_AUTOFREE(char *) desc = NULL; + g_autofree char *desc = NULL; if (VIR_ALLOC_N(desc, VIR_STORAGE_MAX_HEADER) < 0) goto cleanup; @@ -1095,7 +1095,7 @@ virStorageFileProbeFormat(const char *path, uid_t uid, gid_t gid) struct stat sb; ssize_t len = VIR_STORAGE_MAX_HEADER; VIR_AUTOCLOSE fd = -1; - VIR_AUTOFREE(char *) header = NULL; + g_autofree char *header = NULL; if ((fd = virFileOpenAs(path, O_RDONLY, 0, uid, gid, 0)) < 0) { virReportSystemError(-fd, _("Failed to open file '%s'"), path); @@ -1218,7 +1218,7 @@ virStorageFileGetMetadataFromFD(const char *path, ssize_t len = VIR_STORAGE_MAX_HEADER; struct stat sb; int dummy; - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *buf = NULL; VIR_AUTOUNREF(virStorageSourcePtr) meta = NULL; if (!backingFormat) @@ -1509,7 +1509,7 @@ virStorageFileGetNPIVKey(const char *path, int status; const char *serial; const char *port; - VIR_AUTOFREE(char *) outbuf = NULL; + g_autofree char *outbuf = NULL; VIR_AUTOPTR(virCommand) cmd = NULL; cmd = virCommandNewArgList("/lib/udev/scsi_id", @@ -1606,7 +1606,7 @@ virStorageFileParseChainIndex(const char *diskTarget, unsigned int *chainIndex) { unsigned int idx = 0; - VIR_AUTOFREE(char *) target = NULL; + g_autofree char *target = NULL; *chainIndex = 0; @@ -1880,7 +1880,7 @@ virStorageAuthDefParse(xmlNodePtr node, virStorageAuthDefPtr ret = NULL; xmlNodePtr secretnode = NULL; VIR_AUTOPTR(virStorageAuthDef) authdef = NULL; - VIR_AUTOFREE(char *) authtype = NULL; + g_autofree char *authtype = NULL; ctxt->node = node; @@ -1970,10 +1970,10 @@ virStoragePRDefParseXML(xmlXPathContextPtr ctxt) { virStoragePRDefPtr prd; virStoragePRDefPtr ret = NULL; - VIR_AUTOFREE(char *) managed = NULL; - VIR_AUTOFREE(char *) type = NULL; - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(char *) mode = NULL; + g_autofree char *managed = NULL; + g_autofree char *type = NULL; + g_autofree char *path = NULL; + g_autofree char *mode = NULL; if (VIR_ALLOC(prd) < 0) return NULL; @@ -2628,7 +2628,7 @@ virStorageSourceNewFromBackingRelative(virStorageSourcePtr parent, const char *rel) { virStorageSourcePtr ret = NULL; - VIR_AUTOFREE(char *) dirname = NULL; + g_autofree char *dirname = NULL; VIR_AUTOUNREF(virStorageSourcePtr) def = NULL; if (!(def = virStorageSourceNew())) @@ -2828,7 +2828,7 @@ virStorageSourceParseRBDColonString(const char *rbdstr, virStorageSourcePtr src) { char *p, *e, *next; - VIR_AUTOFREE(char *) options = NULL; + g_autofree char *options = NULL; VIR_AUTOPTR(virStorageAuthDef) authdef = NULL; /* optionally skip the "rbd:" prefix if provided */ @@ -3004,7 +3004,7 @@ virStorageSourceParseBackingColon(virStorageSourcePtr src, const char *path) { const char *p; - VIR_AUTOFREE(char *) protocol = NULL; + g_autofree char *protocol = NULL; if (!(p = strchr(path, ':'))) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -3619,7 +3619,7 @@ virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src, virJSONValuePtr file; const char *drvname; size_t i; - VIR_AUTOFREE(char *) str = NULL; + g_autofree char *str = NULL; if (!(deflattened = virJSONValueObjectDeflatten(json))) return -1; @@ -4064,8 +4064,8 @@ virStorageFileCanonicalizePath(const char *path, size_t j = 0; int rc; char *ret = NULL; - VIR_AUTOFREE(char *) linkpath = NULL; - VIR_AUTOFREE(char *) currentpath = NULL; + g_autofree char *linkpath = NULL; + g_autofree char *currentpath = NULL; if (path[0] == '/') { beginSlash = true; @@ -4236,8 +4236,8 @@ virStorageFileGetRelativeBackingPath(virStorageSourcePtr top, char **relpath) { virStorageSourcePtr next; - VIR_AUTOFREE(char *) tmp = NULL; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *tmp = NULL; + g_autofree char *path = NULL; *relpath = NULL; @@ -4942,7 +4942,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src, ssize_t headerLen; int backingFormat; int rv; - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *buf = NULL; VIR_AUTOUNREF(virStorageSourcePtr) backingStore = NULL; VIR_DEBUG("path=%s format=%d uid=%u gid=%u", @@ -5120,7 +5120,7 @@ virStorageFileGetBackingStoreStr(virStorageSourcePtr src, { ssize_t headerLen; int rv; - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *buf = NULL; VIR_AUTOUNREF(virStorageSourcePtr) tmp = NULL; *backing = NULL; diff --git a/src/util/virtpm.c b/src/util/virtpm.c index 26056bf503..9d5e36ba7b 100644 --- a/src/util/virtpm.c +++ b/src/util/virtpm.c @@ -173,7 +173,7 @@ virTPMExecGetCaps(virCommandPtr cmd, { int exitstatus; virBitmapPtr bitmap; - VIR_AUTOFREE(char *) outbuf = NULL; + g_autofree char *outbuf = NULL; VIR_AUTOPTR(virJSONValue) json = NULL; virJSONValuePtr featureList; virJSONValuePtr item; @@ -291,7 +291,7 @@ virTPMEmulatorInit(void) virMutexLock(&swtpm_tools_lock); for (i = 0; i < G_N_ELEMENTS(prgs); i++) { - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; bool findit = *prgs[i].path == NULL; struct stat statbuf; char *tmp; diff --git a/src/util/virusb.c b/src/util/virusb.c index d1a414af41..9ff16a769c 100644 --- a/src/util/virusb.c +++ b/src/util/virusb.c @@ -86,8 +86,8 @@ static int virUSBSysReadFile(const char *f_name, const char *d_name, int base, unsigned int *value) { int tmp; - VIR_AUTOFREE(char *) buf = NULL; - VIR_AUTOFREE(char *) filename = NULL; + g_autofree char *buf = NULL; + g_autofree char *filename = NULL; char *ignore = NULL; tmp = virAsprintf(&filename, USB_SYSFS "/devices/%s/%s", d_name, f_name); diff --git a/src/util/virutil.c b/src/util/virutil.c index 940c6d70e1..742acd8b9b 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -1482,7 +1482,7 @@ virSetUIDGIDWithCaps(uid_t uid, gid_t gid, gid_t *groups, int ngroups, void virWaitForDevices(void) { VIR_AUTOPTR(virCommand) cmd = NULL; - VIR_AUTOFREE(char *) udev = NULL; + g_autofree char *udev = NULL; int exitstatus; if (!(udev = virFindFileInPath(UDEVADM))) diff --git a/tests/cputest.c b/tests/cputest.c index e3937c6fd6..ab68c3b4af 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -656,8 +656,8 @@ static int cpuTestCompareSignature(const struct data *data, virCPUDataPtr hostData) { - VIR_AUTOFREE(char *) result = NULL; - VIR_AUTOFREE(char *) sigStr = NULL; + g_autofree char *result = NULL; + g_autofree char *sigStr = NULL; unsigned long signature; unsigned int family; unsigned int model; diff --git a/tests/networkxml2firewalltest.c b/tests/networkxml2firewalltest.c index 579eb2ec60..e49eef6162 100644 --- a/tests/networkxml2firewalltest.c +++ b/tests/networkxml2firewalltest.c @@ -144,8 +144,8 @@ static int mymain(void) { int ret = 0; - VIR_AUTOFREE(char *)basefile = NULL; - VIR_AUTOFREE(char *)baseargs = NULL; + g_autofree char *basefile = NULL; + g_autofree char *baseargs = NULL; # define DO_TEST(name) \ do { \ diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 2056eeb2e9..e8c892fdd6 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -51,9 +51,9 @@ testBackingXMLjsonXML(const void *args) g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; VIR_AUTOPTR(virJSONValue) backendprops = NULL; VIR_AUTOPTR(virJSONValue) wrapper = NULL; - VIR_AUTOFREE(char *) propsstr = NULL; - VIR_AUTOFREE(char *) protocolwrapper = NULL; - VIR_AUTOFREE(char *) actualxml = NULL; + g_autofree char *propsstr = NULL; + g_autofree char *protocolwrapper = NULL; + g_autofree char *actualxml = NULL; VIR_AUTOUNREF(virStorageSourcePtr) xmlsrc = NULL; VIR_AUTOUNREF(virStorageSourcePtr) jsonsrc = NULL; @@ -366,7 +366,7 @@ testQemuImageCreateLoadDiskXML(const char *name, VIR_AUTOPTR(xmlDoc) doc = NULL; VIR_AUTOPTR(xmlXPathContext) ctxt = NULL; xmlNodePtr node; - VIR_AUTOFREE(char *) xmlpath = NULL; + g_autofree char *xmlpath = NULL; virStorageSourcePtr ret = NULL; if (virAsprintf(&xmlpath, "%s%s.xml", @@ -403,10 +403,10 @@ testQemuImageCreate(const void *opaque) VIR_AUTOUNREF(virStorageSourcePtr) src = NULL; g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) actualbuf = VIR_BUFFER_INITIALIZER; - VIR_AUTOFREE(char *) jsonprotocol = NULL; - VIR_AUTOFREE(char *) jsonformat = NULL; - VIR_AUTOFREE(char *) actual = NULL; - VIR_AUTOFREE(char *) jsonpath = NULL; + g_autofree char *jsonprotocol = NULL; + g_autofree char *jsonformat = NULL; + g_autofree char *actual = NULL; + g_autofree char *jsonpath = NULL; if (!(src = testQemuImageCreateLoadDiskXML(data->name, data->driver->xmlopt))) return -1; @@ -438,7 +438,7 @@ testQemuImageCreate(const void *opaque) if (testQEMUSchemaValidate(formatprops, data->schemaroot, data->schema, &debug) < 0) { - VIR_AUTOFREE(char *) debugmsg = virBufferContentAndReset(&debug); + g_autofree char *debugmsg = virBufferContentAndReset(&debug); VIR_TEST_VERBOSE("blockdev-create format json does not conform to QAPI schema"); VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output:\n %s", jsonformat, NULLSTR(debugmsg)); @@ -453,7 +453,7 @@ testQemuImageCreate(const void *opaque) if (testQEMUSchemaValidate(protocolprops, data->schemaroot, data->schema, &debug) < 0) { - VIR_AUTOFREE(char *) debugmsg = virBufferContentAndReset(&debug); + g_autofree char *debugmsg = virBufferContentAndReset(&debug); VIR_TEST_VERBOSE("blockdev-create protocol json does not conform to QAPI schema"); VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output:\n %s", jsonprotocol, NULLSTR(debugmsg)); @@ -483,8 +483,8 @@ testQemuDiskXMLToPropsValidateFileSrcOnly(const void *opaque) { struct testQemuDiskXMLToJSONData *data = (void *) opaque; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - VIR_AUTOFREE(char *) jsonpath = NULL; - VIR_AUTOFREE(char *) actual = NULL; + g_autofree char *jsonpath = NULL; + g_autofree char *actual = NULL; size_t i; if (data->fail) @@ -495,7 +495,7 @@ testQemuDiskXMLToPropsValidateFileSrcOnly(const void *opaque) return -1; for (i = 0; i < data->npropssrc; i++) { - VIR_AUTOFREE(char *) jsonstr = NULL; + g_autofree char *jsonstr = NULL; if (!(jsonstr = virJSONValueToString(data->propssrc[i], true))) return -1; diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c index 1a785d8e39..a9a1e75587 100644 --- a/tests/qemucapabilitiestest.c +++ b/tests/qemucapabilitiestest.c @@ -183,8 +183,8 @@ doCapsTest(const char *base, void *opaque) { testQemuDataPtr data = (testQemuDataPtr) opaque; - VIR_AUTOFREE(char *) title = NULL; - VIR_AUTOFREE(char *) copyTitle = NULL; + g_autofree char *title = NULL; + g_autofree char *copyTitle = NULL; if (virAsprintf(&title, "%s (%s)", base, archName) < 0 || virAsprintf(©Title, "copy %s (%s)", base, archName) < 0) { diff --git a/tests/qemucaps2xmltest.c b/tests/qemucaps2xmltest.c index e36ba06eeb..f5aecaa391 100644 --- a/tests/qemucaps2xmltest.c +++ b/tests/qemucaps2xmltest.c @@ -100,7 +100,7 @@ testGetCaps(char *capsData, const testQemuData *data) virQEMUCapsPtr qemuCaps = NULL; virCapsPtr caps = NULL; virArch arch = virArchFromString(data->archName); - VIR_AUTOFREE(char *) binary = NULL; + g_autofree char *binary = NULL; if (virAsprintf(&binary, "/usr/bin/qemu-system-%s", data->archName) < 0) goto error; @@ -179,7 +179,7 @@ doCapsTest(const char *base, void *opaque) { testQemuDataPtr data = (testQemuDataPtr) opaque; - VIR_AUTOFREE(char *) title = NULL; + g_autofree char *title = NULL; if (virAsprintf(&title, "%s (%s)", base, archName) < 0) return -1; diff --git a/tests/qemudomaincheckpointxml2xmltest.c b/tests/qemudomaincheckpointxml2xmltest.c index 9dabe92ab9..72d1eeaea5 100644 --- a/tests/qemudomaincheckpointxml2xmltest.c +++ b/tests/qemudomaincheckpointxml2xmltest.c @@ -38,9 +38,9 @@ testCompareXMLToXMLFiles(const char *inxml, { unsigned int parseflags = 0; unsigned int formatflags = VIR_DOMAIN_CHECKPOINT_FORMAT_SECURE; - VIR_AUTOFREE(char *) inXmlData = NULL; - VIR_AUTOFREE(char *) outXmlData = NULL; - VIR_AUTOFREE(char *) actual = NULL; + g_autofree char *inXmlData = NULL; + g_autofree char *outXmlData = NULL; + g_autofree char *actual = NULL; VIR_AUTOUNREF(virDomainCheckpointDefPtr) def = NULL; if (flags & TEST_REDEFINE) diff --git a/tests/qemufirmwaretest.c b/tests/qemufirmwaretest.c index e4d867c1b2..ca396b36b1 100644 --- a/tests/qemufirmwaretest.c +++ b/tests/qemufirmwaretest.c @@ -17,12 +17,12 @@ static int testParseFormatFW(const void *opaque) { const char *filename = opaque; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; VIR_AUTOPTR(qemuFirmware) fw = NULL; - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *buf = NULL; VIR_AUTOPTR(virJSONValue) json = NULL; - VIR_AUTOFREE(char *) expected = NULL; - VIR_AUTOFREE(char *) actual = NULL; + g_autofree char *expected = NULL; + g_autofree char *actual = NULL; if (virAsprintf(&path, "%s/qemufirmwaredata/%s", abs_srcdir, filename) < 0) @@ -57,7 +57,7 @@ testParseFormatFW(const void *opaque) static int testFWPrecedence(const void *opaque G_GNUC_UNUSED) { - VIR_AUTOFREE(char *) fakehome = NULL; + g_autofree char *fakehome = NULL; VIR_AUTOSTRINGLIST fwList = NULL; size_t nfwList; size_t i; diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 1248db59f2..b989e3897f 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2949,10 +2949,10 @@ testQueryJobs(const void *opaque) { const struct testQueryJobsData *data = opaque; qemuMonitorTestPtr test = qemuMonitorTestNewSimple(data->xmlopt); - VIR_AUTOFREE(char *) filenameJSON = NULL; - VIR_AUTOFREE(char *) fileJSON = NULL; - VIR_AUTOFREE(char *) filenameResult = NULL; - VIR_AUTOFREE(char *) actual = NULL; + g_autofree char *filenameJSON = NULL; + g_autofree char *fileJSON = NULL; + g_autofree char *filenameResult = NULL; + g_autofree char *actual = NULL; qemuMonitorJobInfoPtr *jobs = NULL; virBuffer buf = VIR_BUFFER_INITIALIZER; size_t njobs = 0; diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 52e4619f38..cc196263f3 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -123,8 +123,8 @@ qemuMonitorTestAddErrorResponse(qemuMonitorTestPtr test, const char *usermsg) { virBuffer buf = VIR_BUFFER_INITIALIZER; - VIR_AUTOFREE(char *) escapemsg = NULL; - VIR_AUTOFREE(char *) jsonmsg = NULL; + g_autofree char *escapemsg = NULL; + g_autofree char *jsonmsg = NULL; char *tmp; if (!usermsg) @@ -159,7 +159,7 @@ static int qemuMonitorTestAddUnexpectedErrorResponse(qemuMonitorTestPtr test, const char *command) { - VIR_AUTOFREE(char *) msg = NULL; + g_autofree char *msg = NULL; if (virAsprintf(&msg, "unexpected command: '%s'", command) < 0) return -1; @@ -173,7 +173,7 @@ qemuMonitorTestAddInvalidCommandResponse(qemuMonitorTestPtr test, const char *expectedcommand, const char *actualcommand) { - VIR_AUTOFREE(char *) msg = NULL; + g_autofree char *msg = NULL; if (virAsprintf(&msg, "expected command '%s' got '%s'", expectedcommand, actualcommand) < 0) @@ -187,8 +187,8 @@ int G_GNUC_PRINTF(2, 3) qemuMonitorReportError(qemuMonitorTestPtr test, const char *errmsg, ...) { va_list msgargs; - VIR_AUTOFREE(char *) msg = NULL; - VIR_AUTOFREE(char *) jsonmsg = NULL; + g_autofree char *msg = NULL; + g_autofree char *jsonmsg = NULL; int ret = -1; va_start(msgargs, errmsg); @@ -514,7 +514,7 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test, g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER; virJSONValuePtr schemaroot; VIR_AUTOPTR(virJSONValue) emptyargs = NULL; - VIR_AUTOFREE(char *) schemapath = NULL; + g_autofree char *schemapath = NULL; if (!test->qapischema) return 0; @@ -622,8 +622,8 @@ qemuMonitorTestProcessCommandVerbatim(qemuMonitorTestPtr test, const char *cmdstr) { struct qemuMonitorTestHandlerData *data = item->opaque; - VIR_AUTOFREE(char *) reformatted = NULL; - VIR_AUTOFREE(char *) errmsg = NULL; + g_autofree char *reformatted = NULL; + g_autofree char *errmsg = NULL; VIR_AUTOPTR(virJSONValue) json = NULL; virJSONValuePtr cmdargs; const char *cmdname; diff --git a/tests/qemusecuritytest.c b/tests/qemusecuritytest.c index 9efc15c105..83719a28f2 100644 --- a/tests/qemusecuritytest.c +++ b/tests/qemusecuritytest.c @@ -41,9 +41,9 @@ prepareObjects(virQEMUDriverPtr driver, { qemuDomainObjPrivatePtr priv; VIR_AUTOUNREF(virDomainObjPtr) vm = NULL; - VIR_AUTOFREE(char *) filename = NULL; - VIR_AUTOFREE(char *) domxml = NULL; - VIR_AUTOFREE(char *) latestCapsFile = NULL; + g_autofree char *filename = NULL; + g_autofree char *domxml = NULL; + g_autofree char *latestCapsFile = NULL; if (virAsprintf(&filename, "%s/qemuxml2argvdata/%s.xml", abs_srcdir, xmlname) < 0) return -1; diff --git a/tests/qemuvhostusertest.c b/tests/qemuvhostusertest.c index b5a7d9bbd2..b25f7f65b0 100644 --- a/tests/qemuvhostusertest.c +++ b/tests/qemuvhostusertest.c @@ -17,12 +17,12 @@ static int testParseFormatVU(const void *opaque) { const char *filename = opaque; - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; VIR_AUTOPTR(qemuVhostUser) vu = NULL; - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *buf = NULL; VIR_AUTOPTR(virJSONValue) json = NULL; - VIR_AUTOFREE(char *) expected = NULL; - VIR_AUTOFREE(char *) actual = NULL; + g_autofree char *expected = NULL; + g_autofree char *actual = NULL; if (virAsprintf(&path, "%s/qemuvhostuserdata/%s", abs_srcdir, filename) < 0) @@ -57,7 +57,7 @@ testParseFormatVU(const void *opaque) static int testVUPrecedence(const void *opaque G_GNUC_UNUSED) { - VIR_AUTOFREE(char *) fakehome = NULL; + g_autofree char *fakehome = NULL; VIR_AUTOSTRINGLIST vuList = NULL; size_t nvuList; size_t i; diff --git a/tests/storagebackendsheepdogtest.c b/tests/storagebackendsheepdogtest.c index 1806f9725f..ae038a78ea 100644 --- a/tests/storagebackendsheepdogtest.c +++ b/tests/storagebackendsheepdogtest.c @@ -57,7 +57,7 @@ test_node_info_parser(const void *opaque) { const struct testNodeInfoParserData *data = opaque; collie_test test = data->data; - VIR_AUTOFREE(char *) output = NULL; + g_autofree char *output = NULL; VIR_AUTOPTR(virStoragePoolDef) pool = NULL; if (!(pool = virStoragePoolDefParseFile(data->poolxml))) @@ -85,7 +85,7 @@ test_vdi_list_parser(const void *opaque) { const struct testVDIListParserData *data = opaque; collie_test test = data->data; - VIR_AUTOFREE(char *) output = NULL; + g_autofree char *output = NULL; VIR_AUTOPTR(virStoragePoolDef) pool = NULL; VIR_AUTOPTR(virStorageVolDef) vol = NULL; @@ -117,8 +117,8 @@ static int mymain(void) { int ret = 0; - VIR_AUTOFREE(char *) poolxml = NULL; - VIR_AUTOFREE(char *) volxml = NULL; + g_autofree char *poolxml = NULL; + g_autofree char *volxml = NULL; collie_test node_info_tests[] = { {"", -1, 0, 0}, diff --git a/tests/storagepoolcapstest.c b/tests/storagepoolcapstest.c index 518a5fdfe7..185372e939 100644 --- a/tests/storagepoolcapstest.c +++ b/tests/storagepoolcapstest.c @@ -55,8 +55,8 @@ test_virStoragePoolCapsFormat(const void *opaque) (struct test_virStoragePoolCapsFormatData *) opaque; virCapsPtr driverCaps = data->driverCaps; VIR_AUTOUNREF(virStoragePoolCapsPtr) poolCaps = NULL; - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(char *) poolCapsXML = NULL; + g_autofree char *path = NULL; + g_autofree char *poolCapsXML = NULL; if (!(poolCaps = virStoragePoolCapsNew(driverCaps))) diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtest.c index 8e09149906..766588c369 100644 --- a/tests/storagepoolxml2argvtest.c +++ b/tests/storagepoolxml2argvtest.c @@ -26,8 +26,8 @@ testCompareXMLToArgvFiles(bool shouldFail, virStoragePoolDefPtr def = NULL; virStoragePoolObjPtr pool = NULL; const char *defTypeStr; - VIR_AUTOFREE(char *) actualCmdline = NULL; - VIR_AUTOFREE(char *) src = NULL; + g_autofree char *actualCmdline = NULL; + g_autofree char *src = NULL; VIR_AUTOPTR(virCommand) cmd = NULL; if (!(def = virStoragePoolDefParseFile(poolxml))) @@ -105,8 +105,8 @@ static int testCompareXMLToArgvHelper(const void *data) { const struct testInfo *info = data; - VIR_AUTOFREE(char *) poolxml = NULL; - VIR_AUTOFREE(char *) cmdline = NULL; + g_autofree char *poolxml = NULL; + g_autofree char *cmdline = NULL; if (virAsprintf(&poolxml, "%s/storagepoolxml2xmlin/%s.xml", abs_srcdir, info->pool) < 0) diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c index 96dd04faec..4fb37c976a 100644 --- a/tests/storagepoolxml2xmltest.c +++ b/tests/storagepoolxml2xmltest.c @@ -18,7 +18,7 @@ static int testCompareXMLToXMLFiles(const char *inxml, const char *outxml) { - VIR_AUTOFREE(char *) actual = NULL; + g_autofree char *actual = NULL; VIR_AUTOPTR(virStoragePoolDef) dev = NULL; if (!(dev = virStoragePoolDefParseFile(inxml))) @@ -36,8 +36,8 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml) static int testCompareXMLToXMLHelper(const void *data) { - VIR_AUTOFREE(char *) inxml = NULL; - VIR_AUTOFREE(char *) outxml = NULL; + g_autofree char *inxml = NULL; + g_autofree char *outxml = NULL; if (virAsprintf(&inxml, "%s/storagepoolxml2xmlin/%s.xml", abs_srcdir, (const char*)data) < 0 || diff --git a/tests/storagevolxml2argvtest.c b/tests/storagevolxml2argvtest.c index 20d986b524..955620eb47 100644 --- a/tests/storagevolxml2argvtest.c +++ b/tests/storagevolxml2argvtest.c @@ -46,7 +46,7 @@ testCompareXMLToArgvFiles(bool shouldFail, int ret = -1; virStoragePoolDefPtr def = NULL; virStoragePoolObjPtr obj = NULL; - VIR_AUTOFREE(char *) actualCmdline = NULL; + g_autofree char *actualCmdline = NULL; VIR_AUTOPTR(virStorageVolDef) vol = NULL; VIR_AUTOPTR(virStorageVolDef) inputvol = NULL; VIR_AUTOPTR(virStoragePoolDef) inputpool = NULL; @@ -108,7 +108,7 @@ testCompareXMLToArgvFiles(bool shouldFail, goto cleanup; } else { char *createCmdline = actualCmdline; - VIR_AUTOFREE(char *) cvtCmdline = NULL; + g_autofree char *cvtCmdline = NULL; int rc; if (!(cvtCmdline = virCommandToString(cmd, false))) @@ -156,11 +156,11 @@ static int testCompareXMLToArgvHelper(const void *data) { const struct testInfo *info = data; - VIR_AUTOFREE(char *) poolxml = NULL; - VIR_AUTOFREE(char *) inputpoolxml = NULL; - VIR_AUTOFREE(char *) volxml = NULL; - VIR_AUTOFREE(char *) inputvolxml = NULL; - VIR_AUTOFREE(char *) cmdline = NULL; + g_autofree char *poolxml = NULL; + g_autofree char *inputpoolxml = NULL; + g_autofree char *volxml = NULL; + g_autofree char *inputvolxml = NULL; + g_autofree char *cmdline = NULL; if (info->inputvol && virAsprintf(&inputvolxml, "%s/storagevolxml2xmlin/%s.xml", diff --git a/tests/storagevolxml2xmltest.c b/tests/storagevolxml2xmltest.c index 7c5d8e7e38..2d15480c96 100644 --- a/tests/storagevolxml2xmltest.c +++ b/tests/storagevolxml2xmltest.c @@ -17,7 +17,7 @@ static int testCompareXMLToXMLFiles(const char *poolxml, const char *inxml, const char *outxml, unsigned int flags) { - VIR_AUTOFREE(char *) actual = NULL; + g_autofree char *actual = NULL; VIR_AUTOPTR(virStoragePoolDef) pool = NULL; VIR_AUTOPTR(virStorageVolDef) dev = NULL; @@ -46,9 +46,9 @@ static int testCompareXMLToXMLHelper(const void *data) { const struct testInfo *info = data; - VIR_AUTOFREE(char *) poolxml = NULL; - VIR_AUTOFREE(char *) inxml = NULL; - VIR_AUTOFREE(char *) outxml = NULL; + g_autofree char *poolxml = NULL; + g_autofree char *inxml = NULL; + g_autofree char *outxml = NULL; if (virAsprintf(&poolxml, "%s/storagepoolxml2xmlin/%s.xml", abs_srcdir, info->pool) < 0 || diff --git a/tests/testutils.c b/tests/testutils.c index 8997274621..287567ab73 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -688,8 +688,8 @@ int virTestCompareToULL(unsigned long long expect, unsigned long long actual) { - VIR_AUTOFREE(char *) expectStr = NULL; - VIR_AUTOFREE(char *) actualStr = NULL; + g_autofree char *expectStr = NULL; + g_autofree char *actualStr = NULL; if (virAsprintf(&expectStr, "%llu", expect) < 0) return -1; diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 68a0b15cd0..6eda8daafe 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -965,7 +965,7 @@ testQemuInfoSetArgs(struct testQemuInfo *info, int gic = GIC_NONE; char *capsarch = NULL; char *capsver = NULL; - VIR_AUTOFREE(char *) capsfile = NULL; + g_autofree char *capsfile = NULL; int flag; int ret = -1; diff --git a/tests/virfilewrapper.c b/tests/virfilewrapper.c index 3d3f319f2c..b6032f88fd 100644 --- a/tests/virfilewrapper.c +++ b/tests/virfilewrapper.c @@ -145,7 +145,7 @@ virMockStatRedirect(const char *path, char **newpath) FILE *fopen(const char *path, const char *mode) { - VIR_AUTOFREE(char *) newpath = NULL; + g_autofree char *newpath = NULL; PATH_OVERRIDE(newpath, path); @@ -154,7 +154,7 @@ FILE *fopen(const char *path, const char *mode) int access(const char *path, int mode) { - VIR_AUTOFREE(char *) newpath = NULL; + g_autofree char *newpath = NULL; PATH_OVERRIDE(newpath, path); @@ -168,7 +168,7 @@ int _open(const char *path, int flags, ...) int open(const char *path, int flags, ...) # endif { - VIR_AUTOFREE(char *) newpath = NULL; + g_autofree char *newpath = NULL; va_list ap; mode_t mode = 0; @@ -188,7 +188,7 @@ int open(const char *path, int flags, ...) DIR *opendir(const char *path) { - VIR_AUTOFREE(char *) newpath = NULL; + g_autofree char *newpath = NULL; PATH_OVERRIDE(newpath, path); @@ -197,7 +197,7 @@ DIR *opendir(const char *path) int execv(const char *path, char *const argv[]) { - VIR_AUTOFREE(char *) newpath = NULL; + g_autofree char *newpath = NULL; PATH_OVERRIDE(newpath, path); @@ -206,7 +206,7 @@ int execv(const char *path, char *const argv[]) int execve(const char *path, char *const argv[], char *const envp[]) { - VIR_AUTOFREE(char *) newpath = NULL; + g_autofree char *newpath = NULL; PATH_OVERRIDE(newpath, path); diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c index 2cf2a6decf..8e21d3eae4 100644 --- a/tests/virhostdevtest.c +++ b/tests/virhostdevtest.c @@ -499,7 +499,7 @@ static int mymain(void) { int ret = 0; - VIR_AUTOFREE(char *) fakerootdir = NULL; + g_autofree char *fakerootdir = NULL; if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) { fprintf(stderr, "Out of memory\n"); diff --git a/tests/virjsontest.c b/tests/virjsontest.c index 2fe0ea1fb6..13717ad522 100644 --- a/tests/virjsontest.c +++ b/tests/virjsontest.c @@ -21,10 +21,10 @@ testJSONFromFile(const void *data) { const struct testInfo *info = data; VIR_AUTOPTR(virJSONValue) injson = NULL; - VIR_AUTOFREE(char *) infile = NULL; - VIR_AUTOFREE(char *) indata = NULL; - VIR_AUTOFREE(char *) outfile = NULL; - VIR_AUTOFREE(char *) actual = NULL; + g_autofree char *infile = NULL; + g_autofree char *indata = NULL; + g_autofree char *outfile = NULL; + g_autofree char *actual = NULL; if (virAsprintf(&infile, "%s/virjsondata/parse-%s-in.json", abs_srcdir, info->name) < 0 || @@ -68,7 +68,7 @@ testJSONFromString(const void *data) const struct testInfo *info = data; VIR_AUTOPTR(virJSONValue) json = NULL; const char *expectstr = info->expect ? info->expect : info->doc; - VIR_AUTOFREE(char *) formatted = NULL; + g_autofree char *formatted = NULL; json = virJSONValueFromString(info->doc); @@ -109,10 +109,10 @@ testJSONAddRemove(const void *data) const struct testInfo *info = data; VIR_AUTOPTR(virJSONValue) json = NULL; VIR_AUTOPTR(virJSONValue) name = NULL; - VIR_AUTOFREE(char *) infile = NULL; - VIR_AUTOFREE(char *) indata = NULL; - VIR_AUTOFREE(char *) outfile = NULL; - VIR_AUTOFREE(char *) actual = NULL; + g_autofree char *infile = NULL; + g_autofree char *indata = NULL; + g_autofree char *outfile = NULL; + g_autofree char *actual = NULL; if (virAsprintf(&infile, "%s/virjsondata/add-remove-%s-in.json", abs_srcdir, info->name) < 0 || @@ -180,7 +180,7 @@ testJSONLookup(const void *data) const struct testInfo *info = data; VIR_AUTOPTR(virJSONValue) json = NULL; virJSONValuePtr value = NULL; - VIR_AUTOFREE(char *) result = NULL; + g_autofree char *result = NULL; int rc; int number; const char *str; @@ -281,8 +281,8 @@ testJSONCopy(const void *data) const struct testInfo *info = data; VIR_AUTOPTR(virJSONValue) json = NULL; VIR_AUTOPTR(virJSONValue) jsonCopy = NULL; - VIR_AUTOFREE(char *) result = NULL; - VIR_AUTOFREE(char *) resultCopy = NULL; + g_autofree char *result = NULL; + g_autofree char *resultCopy = NULL; json = virJSONValueFromString(info->doc); if (!json) { @@ -345,10 +345,10 @@ testJSONDeflatten(const void *data) const struct testInfo *info = data; VIR_AUTOPTR(virJSONValue) injson = NULL; VIR_AUTOPTR(virJSONValue) deflattened = NULL; - VIR_AUTOFREE(char *) infile = NULL; - VIR_AUTOFREE(char *) indata = NULL; - VIR_AUTOFREE(char *) outfile = NULL; - VIR_AUTOFREE(char *) actual = NULL; + g_autofree char *infile = NULL; + g_autofree char *indata = NULL; + g_autofree char *outfile = NULL; + g_autofree char *actual = NULL; if (virAsprintf(&infile, "%s/virjsondata/deflatten-%s-in.json", abs_srcdir, info->name) < 0 || @@ -390,8 +390,8 @@ testJSONEscapeObj(const void *data G_GNUC_UNUSED) VIR_AUTOPTR(virJSONValue) json = NULL; VIR_AUTOPTR(virJSONValue) nestjson = NULL; VIR_AUTOPTR(virJSONValue) parsejson = NULL; - VIR_AUTOFREE(char *) neststr = NULL; - VIR_AUTOFREE(char *) result = NULL; + g_autofree char *neststr = NULL; + g_autofree char *result = NULL; const char *parsednestedstr; if (virJSONValueObjectCreate(&nestjson, diff --git a/tests/virmockstathelpers.c b/tests/virmockstathelpers.c index 0e13ce60b7..ba26e7bd45 100644 --- a/tests/virmockstathelpers.c +++ b/tests/virmockstathelpers.c @@ -199,7 +199,7 @@ int _stat(const char *path, struct stat *sb) int stat(const char *path, struct stat *sb) # endif { - VIR_AUTOFREE(char *) newpath = NULL; + g_autofree char *newpath = NULL; virMockStatInit(); @@ -216,7 +216,7 @@ int stat(const char *path, struct stat *sb) #ifdef MOCK_STAT64 int stat64(const char *path, struct stat64 *sb) { - VIR_AUTOFREE(char *) newpath = NULL; + g_autofree char *newpath = NULL; virMockStatInit(); @@ -234,7 +234,7 @@ int stat64(const char *path, struct stat64 *sb) int __xstat(int ver, const char *path, struct stat *sb) { - VIR_AUTOFREE(char *) newpath = NULL; + g_autofree char *newpath = NULL; virMockStatInit(); @@ -252,7 +252,7 @@ __xstat(int ver, const char *path, struct stat *sb) int __xstat64(int ver, const char *path, struct stat64 *sb) { - VIR_AUTOFREE(char *) newpath = NULL; + g_autofree char *newpath = NULL; virMockStatInit(); @@ -275,7 +275,7 @@ int lstat(const char *path, struct stat *sb) # endif { - VIR_AUTOFREE(char *) newpath = NULL; + g_autofree char *newpath = NULL; virMockStatInit(); @@ -293,7 +293,7 @@ lstat(const char *path, struct stat *sb) int lstat64(const char *path, struct stat64 *sb) { - VIR_AUTOFREE(char *) newpath = NULL; + g_autofree char *newpath = NULL; virMockStatInit(); @@ -311,7 +311,7 @@ lstat64(const char *path, struct stat64 *sb) int __lxstat(int ver, const char *path, struct stat *sb) { - VIR_AUTOFREE(char *) newpath = NULL; + g_autofree char *newpath = NULL; virMockStatInit(); @@ -329,7 +329,7 @@ __lxstat(int ver, const char *path, struct stat *sb) int __lxstat64(int ver, const char *path, struct stat64 *sb) { - VIR_AUTOFREE(char *) newpath = NULL; + g_autofree char *newpath = NULL; virMockStatInit(); diff --git a/tests/virnetdevopenvswitchtest.c b/tests/virnetdevopenvswitchtest.c index f01e77cbba..3beb4af149 100644 --- a/tests/virnetdevopenvswitchtest.c +++ b/tests/virnetdevopenvswitchtest.c @@ -34,8 +34,8 @@ static int testInterfaceParseStats(const void *opaque) { const InterfaceParseStatsData *data = opaque; - VIR_AUTOFREE(char *) filename = NULL; - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *filename = NULL; + g_autofree char *buf = NULL; virDomainInterfaceStatsStruct actual; if (virAsprintf(&filename, "%s/virnetdevopenvswitchdata/%s", diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 8f860bb917..ba4256e2fb 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -182,7 +182,7 @@ make_file(const char *path, ssize_t len) { int fd = -1; - VIR_AUTOFREE(char *) filepath = NULL; + g_autofree char *filepath = NULL; if (value && len == -1) len = strlen(value); @@ -202,7 +202,7 @@ static void make_dir(const char *path, const char *name) { - VIR_AUTOFREE(char *) dirpath = NULL; + g_autofree char *dirpath = NULL; if (virAsprintfQuiet(&dirpath, "%s/%s", path, name) < 0) ABORT_OOM(); @@ -216,7 +216,7 @@ make_symlink(const char *path, const char *name, const char *target) { - VIR_AUTOFREE(char *) filepath = NULL; + g_autofree char *filepath = NULL; if (virAsprintfQuiet(&filepath, "%s/%s", path, name) < 0) ABORT_OOM(); @@ -233,7 +233,7 @@ pci_read_file(const char *path, { int ret = -1; int fd = -1; - VIR_AUTOFREE(char *) newpath = NULL; + g_autofree char *newpath = NULL; if (virAsprintfQuiet(&newpath, "%s/%s", fakerootdir, path) < 0) { errno = ENOMEM; @@ -394,7 +394,7 @@ pci_device_get_path(const struct pciDevice *dev, { char *ret = NULL; const char *prefix = ""; - VIR_AUTOFREE(char *) devid = NULL; + g_autofree char *devid = NULL; if (faked) prefix = fakerootdir; @@ -424,7 +424,7 @@ pci_device_create_iommu(const struct pciDevice *dev, const char *devid) { struct pciIommuGroup *iommuGroup; - VIR_AUTOFREE(char *) iommuPath = NULL; + g_autofree char *iommuPath = NULL; char tmp[256]; size_t i; @@ -467,12 +467,12 @@ static void pci_device_new_from_stub(const struct pciDevice *data) { struct pciDevice *dev; - VIR_AUTOFREE(char *) devpath = NULL; - VIR_AUTOFREE(char *) devsympath = NULL; - VIR_AUTOFREE(char *) id = NULL; - VIR_AUTOFREE(char *) devid = NULL; + g_autofree char *devpath = NULL; + g_autofree char *devsympath = NULL; + g_autofree char *id = NULL; + g_autofree char *devid = NULL; char *c; - VIR_AUTOFREE(char *) configSrc = NULL; + g_autofree char *configSrc = NULL; char tmp[256]; struct stat sb; bool configSrcExists = false; @@ -516,7 +516,7 @@ pci_device_new_from_stub(const struct pciDevice *data) * file, and parallel VPATH builds must not stomp on the * original; besides, 'make distcheck' requires the original * to be read-only */ - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *buf = NULL; ssize_t len; if ((len = virFileReadAll(configSrc, 4096, &buf)) < 0) @@ -624,7 +624,7 @@ pci_device_autobind(struct pciDevice *dev) static int pci_vfio_release_iommu(struct pciDevice *device) { - VIR_AUTOFREE(char *) vfiopath = NULL; + g_autofree char *vfiopath = NULL; size_t i = 0; for (i = 0; i < npciIommuGroups; i++) { @@ -658,7 +658,7 @@ pci_vfio_release_iommu(struct pciDevice *device) static int pci_vfio_lock_iommu(struct pciDevice *device) { - VIR_AUTOFREE(char *) vfiopath = NULL; + g_autofree char *vfiopath = NULL; int ret = -1; size_t i = 0; int fd = -1; @@ -722,7 +722,7 @@ pci_driver_new(const char *name, ...) struct pciDriver *driver; va_list args; int vendor, device; - VIR_AUTOFREE(char *) driverpath = NULL; + g_autofree char *driverpath = NULL; if (VIR_ALLOC_QUIET(driver) < 0 || VIR_STRDUP_QUIET(driver->name, name) < 0 || @@ -793,7 +793,7 @@ pci_driver_find_by_path(const char *path) static struct pciDriver * pci_driver_find_by_driver_override(struct pciDevice *dev) { - VIR_AUTOFREE(char *) path = NULL; + g_autofree char *path = NULL; char tmp[32]; size_t i; @@ -817,9 +817,9 @@ static int pci_driver_bind(struct pciDriver *driver, struct pciDevice *dev) { - VIR_AUTOFREE(char *) devid = NULL; - VIR_AUTOFREE(char *) devpath = NULL; - VIR_AUTOFREE(char *) driverpath = NULL; + g_autofree char *devid = NULL; + g_autofree char *devpath = NULL; + g_autofree char *driverpath = NULL; if (dev->driver) { /* Device already bound */ @@ -862,9 +862,9 @@ static int pci_driver_unbind(struct pciDriver *driver, struct pciDevice *dev) { - VIR_AUTOFREE(char *) devid = NULL; - VIR_AUTOFREE(char *) devpath = NULL; - VIR_AUTOFREE(char *) driverpath = NULL; + g_autofree char *devid = NULL; + g_autofree char *devpath = NULL; + g_autofree char *driverpath = NULL; if (dev->driver != driver) { /* Device not bound to the @driver */ @@ -985,7 +985,7 @@ init_syms(void) static void init_env(void) { - VIR_AUTOFREE(char *) tmp = NULL; + g_autofree char *tmp = NULL; if (!(fakerootdir = getenv("LIBVIRT_FAKE_ROOT_DIR"))) ABORT("Missing LIBVIRT_FAKE_ROOT_DIR env variable\n"); @@ -1064,7 +1064,7 @@ init_env(void) int access(const char *path, int mode) { - VIR_AUTOFREE(char *) newpath = NULL; + g_autofree char *newpath = NULL; init_syms(); @@ -1089,7 +1089,7 @@ int open(const char *path, int flags, ...) { int ret; - VIR_AUTOFREE(char *) newpath = NULL; + g_autofree char *newpath = NULL; init_syms(); @@ -1128,7 +1128,7 @@ __open_2(const char *path, int flags); int __open_2(const char *path, int flags) { - VIR_AUTOFREE(char *) newpath = NULL; + g_autofree char *newpath = NULL; int ret; init_syms(); @@ -1153,7 +1153,7 @@ __open_2(const char *path, int flags) DIR * opendir(const char *path) { - VIR_AUTOFREE(char *) newpath = NULL; + g_autofree char *newpath = NULL; init_syms(); @@ -1174,7 +1174,7 @@ close(int fd) char * virFileCanonicalizePath(const char *path) { - VIR_AUTOFREE(char *) newpath = NULL; + g_autofree char *newpath = NULL; init_syms(); diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index af435189f1..c3a2cc10c8 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -118,7 +118,7 @@ testPrepImages(void) int ret = EXIT_FAILURE; bool compat = false; VIR_AUTOPTR(virCommand) cmd = NULL; - VIR_AUTOFREE(char *) buf = NULL; + g_autofree char *buf = NULL; qemuimg = virFindFileInPath("qemu-img"); if (!qemuimg) @@ -279,7 +279,7 @@ testStorageChain(const void *args) virStorageSourcePtr elt; size_t i = 0; VIR_AUTOUNREF(virStorageSourcePtr) meta = NULL; - VIR_AUTOFREE(char *) broken = NULL; + g_autofree char *broken = NULL; meta = testStorageFileGetMetadata(data->start, data->format, -1, -1); if (!meta) { @@ -315,8 +315,8 @@ testStorageChain(const void *args) elt = meta; while (virStorageSourceIsBacking(elt)) { - VIR_AUTOFREE(char *) expect = NULL; - VIR_AUTOFREE(char *) actual = NULL; + g_autofree char *expect = NULL; + g_autofree char *actual = NULL; if (i == data->nfiles) { fprintf(stderr, "probed chain was too long\n"); @@ -495,7 +495,7 @@ static int testPathCanonicalize(const void *args) { const struct testPathCanonicalizeData *data = args; - VIR_AUTOFREE(char *) canon = NULL; + g_autofree char *canon = NULL; canon = virStorageFileCanonicalizePath(data->path, testPathCanonicalizeReadlink, @@ -579,7 +579,7 @@ static int testPathRelative(const void *args) { const struct testPathRelativeBacking *data = args; - VIR_AUTOFREE(char *) actual = NULL; + g_autofree char *actual = NULL; if (virStorageFileGetRelativeBackingPath(data->top, data->base, @@ -611,7 +611,7 @@ testBackingParse(const void *args) { const struct testBackingParseData *data = args; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - VIR_AUTOFREE(char *) xml = NULL; + g_autofree char *xml = NULL; VIR_AUTOUNREF(virStorageSourcePtr) src = NULL; int rc; int erc = data->rv; diff --git a/tests/virstorageutiltest.c b/tests/virstorageutiltest.c index 94d8b9b091..d4ab818f5f 100644 --- a/tests/virstorageutiltest.c +++ b/tests/virstorageutiltest.c @@ -46,8 +46,8 @@ testGlusterExtractPoolSources(const void *opaque) }; size_t i; int ret = -1; - VIR_AUTOFREE(char *) srcxmldata = NULL; - VIR_AUTOFREE(char *) actual = NULL; + g_autofree char *srcxmldata = NULL; + g_autofree char *actual = NULL; if (virTestLoadFile(data->srcxml, &srcxmldata) < 0) goto cleanup; diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 8f5c711097..68ccd73056 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -85,7 +85,7 @@ virshDomainInterfaceCompleter(vshControl *ctl, VIR_AUTOPTR(xmlDoc) xmldoc = NULL; VIR_AUTOPTR(xmlXPathContext) ctxt = NULL; int ninterfaces; - VIR_AUTOFREE(xmlNodePtr *) interfaces = NULL; + g_autofree xmlNodePtr *interfaces = NULL; size_t i; unsigned int domainXMLFlags = 0; char **ret = NULL; @@ -135,7 +135,7 @@ virshDomainDiskTargetCompleter(vshControl *ctl, virshControlPtr priv = ctl->privData; VIR_AUTOPTR(xmlDoc) xmldoc = NULL; VIR_AUTOPTR(xmlXPathContext) ctxt = NULL; - VIR_AUTOFREE(xmlNodePtr *) disks = NULL; + g_autofree xmlNodePtr *disks = NULL; int ndisks; size_t i; VIR_AUTOSTRINGLIST tmp = NULL; @@ -204,9 +204,9 @@ virshDomainInterfaceStateCompleter(vshControl *ctl, virMacAddr macaddr; char macstr[VIR_MAC_STRING_BUFLEN] = ""; int ninterfaces; - VIR_AUTOFREE(xmlNodePtr *) interfaces = NULL; - VIR_AUTOFREE(char *) xpath = NULL; - VIR_AUTOFREE(char *) state = NULL; + g_autofree xmlNodePtr *interfaces = NULL; + g_autofree char *xpath = NULL; + g_autofree char *state = NULL; VIR_AUTOSTRINGLIST tmp = NULL; virCheckFlags(0, NULL); @@ -263,7 +263,7 @@ virshDomainDeviceAliasCompleter(vshControl *ctl, VIR_AUTOPTR(xmlDoc) xmldoc = NULL; VIR_AUTOPTR(xmlXPathContext) ctxt = NULL; int naliases; - VIR_AUTOFREE(xmlNodePtr *) aliases = NULL; + g_autofree xmlNodePtr *aliases = NULL; size_t i; unsigned int domainXMLFlags = 0; char **ret = NULL; diff --git a/tools/virsh-completer-host.c b/tools/virsh-completer-host.c index 839c8cc420..5a54c0a3a0 100644 --- a/tools/virsh-completer-host.c +++ b/tools/virsh-completer-host.c @@ -30,8 +30,8 @@ static char * virshPagesizeNodeToString(xmlNodePtr node) { - VIR_AUTOFREE(char *) pagesize = NULL; - VIR_AUTOFREE(char *) unit = NULL; + g_autofree char *pagesize = NULL; + g_autofree char *unit = NULL; unsigned long long byteval = 0; const char *suffix = NULL; double size = 0; @@ -57,13 +57,13 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl, VIR_AUTOPTR(xmlXPathContext) ctxt = NULL; virshControlPtr priv = ctl->privData; unsigned int npages = 0; - VIR_AUTOFREE(xmlNodePtr *) pages = NULL; + g_autofree xmlNodePtr *pages = NULL; VIR_AUTOPTR(xmlDoc) doc = NULL; size_t i = 0; const char *cellnum = NULL; bool cellno = vshCommandOptBool(cmd, "cellno"); - VIR_AUTOFREE(char *) path = NULL; - VIR_AUTOFREE(char *) cap_xml = NULL; + g_autofree char *path = NULL; + g_autofree char *cap_xml = NULL; char **ret = NULL; VIR_AUTOSTRINGLIST tmp = NULL; @@ -113,10 +113,10 @@ virshCellnoCompleter(vshControl *ctl, VIR_AUTOPTR(xmlXPathContext) ctxt = NULL; virshControlPtr priv = ctl->privData; unsigned int ncells = 0; - VIR_AUTOFREE(xmlNodePtr *) cells = NULL; + g_autofree xmlNodePtr *cells = NULL; VIR_AUTOPTR(xmlDoc) doc = NULL; size_t i = 0; - VIR_AUTOFREE(char *) cap_xml = NULL; + g_autofree char *cap_xml = NULL; char **ret = NULL; VIR_AUTOSTRINGLIST tmp = NULL; diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c index 1fa66b4081..b7d347b389 100644 --- a/tools/virsh-completer.c +++ b/tools/virsh-completer.c @@ -88,7 +88,7 @@ virshCommaStringListComplete(const char *input, const char **options) { const size_t optionsLen = virStringListLength(options); - VIR_AUTOFREE(char *) inputCopy = NULL; + g_autofree char *inputCopy = NULL; VIR_AUTOSTRINGLIST inputList = NULL; VIR_AUTOSTRINGLIST ret = NULL; size_t nret = 0; diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 92dcbd1eb7..b2bb85cd96 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -731,11 +731,11 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd) goto cleanup; for (i = 0; i < ninterfaces; i++) { - VIR_AUTOFREE(char *) type = NULL; - VIR_AUTOFREE(char *) source = NULL; - VIR_AUTOFREE(char *) target = NULL; - VIR_AUTOFREE(char *) model = NULL; - VIR_AUTOFREE(char *) mac = NULL; + g_autofree char *type = NULL; + g_autofree char *source = NULL; + g_autofree char *target = NULL; + g_autofree char *model = NULL; + g_autofree char *mac = NULL; ctxt->node = interfaces[i]; type = virXPathString("string(./@type)", ctxt); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index a83c47a162..e8097bb165 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6960,8 +6960,8 @@ virshVcpuPinQuery(vshControl *ctl, goto cleanup; for (i = 0; i < ncpus; i++) { - VIR_AUTOFREE(char *) pinInfo = NULL; - VIR_AUTOFREE(char *) vcpuStr = NULL; + g_autofree char *pinInfo = NULL; + g_autofree char *vcpuStr = NULL; if (got_vcpu && i != vcpu) continue; @@ -7583,8 +7583,8 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd) goto cleanup; for (i = 0; i < niothreads; i++) { - VIR_AUTOFREE(char *) pinInfo = NULL; - VIR_AUTOFREE(char *) iothreadIdStr = NULL; + g_autofree char *pinInfo = NULL; + g_autofree char *iothreadIdStr = NULL; if (virAsprintf(&iothreadIdStr, "%u", info[i]->iothread_id) < 0) goto cleanup; @@ -9507,8 +9507,8 @@ static bool cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd) { VIR_AUTOPTR(virshDomain) dom = NULL; - VIR_AUTOFREE(char *) monitor_cmd = NULL; - VIR_AUTOFREE(char *) result = NULL; + g_autofree char *monitor_cmd = NULL; + g_autofree char *result = NULL; unsigned int flags = 0; const vshCmdOpt *opt = NULL; virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -13999,7 +13999,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) for (i = 0; i < ninfos; i++) { virBuffer targetsBuff = VIR_BUFFER_INITIALIZER; - VIR_AUTOFREE(char *) targets = NULL; + g_autofree char *targets = NULL; for (j = 0; j < info[i]->ndevAlias; j++) virBufferAsprintf(&targetsBuff, "%s,", info[i]->devAlias[j]); diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 3589d84116..64b733adcc 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -1434,7 +1434,7 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd *cmd) for (i = 0; i < nleases; i++) { const char *typestr = NULL; - VIR_AUTOFREE(char *) cidr_format = NULL; + g_autofree char *cidr_format = NULL; virNetworkDHCPLeasePtr lease = leases[i]; time_t expirytime_tmp = lease->expirytime; struct tm ts; diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index b01186f339..bb25840943 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -2130,7 +2130,7 @@ cmdPoolCapabilities(vshControl *ctl, { const unsigned int flags = 0; /* No flags so far */ virshControlPtr priv = ctl->privData; - VIR_AUTOFREE(char *) caps = NULL; + g_autofree char *caps = NULL; caps = virConnectGetStoragePoolCapabilities(priv->conn, flags); if (!caps) { diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index f0446c83ae..66369a25dc 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -521,7 +521,7 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) const char *usageStr = virSecretUsageTypeToString(usageType); char uuid[VIR_UUID_STRING_BUFLEN]; virBuffer buf = VIR_BUFFER_INITIALIZER; - VIR_AUTOFREE(char *) usage = NULL; + g_autofree char *usage = NULL; if (virSecretGetUUIDString(sec, uuid) < 0) { vshError(ctl, "%s", _("Failed to get uuid of secret")); diff --git a/tools/virt-admin.c b/tools/virt-admin.c index c0cc0999cb..e2ed272a04 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -396,7 +396,7 @@ cmdSrvList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) goto cleanup; for (i = 0; i < nsrvs; i++) { - VIR_AUTOFREE(char *) idStr = NULL; + g_autofree char *idStr = NULL; if (virAsprintf(&idStr, "%zu", i) < 0) goto cleanup; @@ -650,8 +650,8 @@ cmdSrvClientsList(vshControl *ctl, const vshCmd *cmd) goto cleanup; for (i = 0; i < nclts; i++) { - VIR_AUTOFREE(char *) timestr = NULL; - VIR_AUTOFREE(char *) idStr = NULL; + g_autofree char *timestr = NULL; + g_autofree char *idStr = NULL; virAdmClientPtr client = clts[i]; id = virAdmClientGetID(client); transport = virAdmClientGetTransport(client); -- 2.19.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list