From c125556c12cacee1ce7bb6aec906f586b1c2f05c Mon Sep 17 00:00:00 2001 From: Shalini Chellathurai Saroja Date: Thu, 18 Jun 2020 10:25:14 +0200 Subject: [PATCH] conf: use g_autofree to ensure automatic cleanup Signed-off-by: Bjoern Walk Signed-off-by: Shalini Chellathurai Saroja Reviewed-by: Boris Fiuczynski Reviewed-by: Andrea Bolognani --- src/conf/device_conf.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index 4dbd5c1ac9..1d06981a61 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -53,9 +53,8 @@ virZPCIDeviceAddressParseXML(xmlNodePtr node, virPCIDeviceAddressPtr addr) { virZPCIDeviceAddress def = { 0 }; - char *uid; - char *fid; - int ret = -1; + g_autofree char *uid = NULL; + g_autofree char *fid = NULL; uid = virXMLPropString(node, "uid"); fid = virXMLPropString(node, "fid"); @@ -64,27 +63,23 @@ virZPCIDeviceAddressParseXML(xmlNodePtr node, virStrToLong_uip(uid, NULL, 0, &def.uid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot parse
'uid' attribute")); - goto cleanup; + return -1; } if (fid && virStrToLong_uip(fid, NULL, 0, &def.fid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot parse
'fid' attribute")); - goto cleanup; + return -1; } if (!virZPCIDeviceAddressIsEmpty(&def) && !virZPCIDeviceAddressIsValid(&def)) - goto cleanup; + return -1; addr->zpci = def; - ret = 0; - cleanup: - VIR_FREE(uid); - VIR_FREE(fid); - return ret; + return 0; } void