From: Michal Privoznik Date: Fri, 26 Nov 2021 13:11:25 +0000 (+0100) Subject: virdomainobjlist: Use g_autofree X-Git-Tag: v8.0.0-rc1~377 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f80ff3d9685d900e7b87ff7473fe5f8a9dbdd12;p=thirdparty%2Flibvirt.git virdomainobjlist: Use g_autofree Instead of calling VIR_FREE() explicitly, we can annotate variables with g_autofree. Signed-off-by: Michal Privoznik Reviewed-by: Ján Tomko --- diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index 9be1e7ad7d..a0cffac1b8 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -423,7 +423,7 @@ virDomainObjListRename(virDomainObjList *doms, void *opaque) { int ret = -1; - char *old_name = NULL; + g_autofree char *old_name = NULL; int rc; if (STREQ(dom->def->name, new_name)) { @@ -468,7 +468,6 @@ virDomainObjListRename(virDomainObjList *doms, ret = 0; cleanup: virObjectRWUnlock(doms); - VIR_FREE(old_name); return ret; } @@ -482,7 +481,8 @@ virDomainObjListLoadConfig(virDomainObjList *doms, virDomainLoadConfigNotify notify, void *opaque) { - char *configFile = NULL, *autostartLink = NULL; + g_autofree char *configFile = NULL; + g_autofree char *autostartLink = NULL; virDomainDef *def = NULL; virDomainObj *dom; int autostart; @@ -511,13 +511,9 @@ virDomainObjListLoadConfig(virDomainObjList *doms, (*notify)(dom, oldDef == NULL, opaque); virDomainDefFree(oldDef); - VIR_FREE(configFile); - VIR_FREE(autostartLink); return dom; error: - VIR_FREE(configFile); - VIR_FREE(autostartLink); virDomainDefFree(def); return NULL; } @@ -531,7 +527,7 @@ virDomainObjListLoadStatus(virDomainObjList *doms, virDomainLoadConfigNotify notify, void *opaque) { - char *statusFile = NULL; + g_autofree char *statusFile = NULL; virDomainObj *obj = NULL; char uuidstr[VIR_UUID_STRING_BUFLEN]; @@ -561,12 +557,10 @@ virDomainObjListLoadStatus(virDomainObjList *doms, if (notify) (*notify)(obj, 1, opaque); - VIR_FREE(statusFile); return obj; error: virDomainObjEndAPI(&obj); - VIR_FREE(statusFile); return NULL; }