mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
virdomainobjlist: Use g_autofree
Instead of calling VIR_FREE() explicitly, we can annotate variables with g_autofree. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
38929464c5
commit
7f80ff3d96
@ -423,7 +423,7 @@ virDomainObjListRename(virDomainObjList *doms,
|
|||||||
void *opaque)
|
void *opaque)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *old_name = NULL;
|
g_autofree char *old_name = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (STREQ(dom->def->name, new_name)) {
|
if (STREQ(dom->def->name, new_name)) {
|
||||||
@ -468,7 +468,6 @@ virDomainObjListRename(virDomainObjList *doms,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
virObjectRWUnlock(doms);
|
virObjectRWUnlock(doms);
|
||||||
VIR_FREE(old_name);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -482,7 +481,8 @@ virDomainObjListLoadConfig(virDomainObjList *doms,
|
|||||||
virDomainLoadConfigNotify notify,
|
virDomainLoadConfigNotify notify,
|
||||||
void *opaque)
|
void *opaque)
|
||||||
{
|
{
|
||||||
char *configFile = NULL, *autostartLink = NULL;
|
g_autofree char *configFile = NULL;
|
||||||
|
g_autofree char *autostartLink = NULL;
|
||||||
virDomainDef *def = NULL;
|
virDomainDef *def = NULL;
|
||||||
virDomainObj *dom;
|
virDomainObj *dom;
|
||||||
int autostart;
|
int autostart;
|
||||||
@ -511,13 +511,9 @@ virDomainObjListLoadConfig(virDomainObjList *doms,
|
|||||||
(*notify)(dom, oldDef == NULL, opaque);
|
(*notify)(dom, oldDef == NULL, opaque);
|
||||||
|
|
||||||
virDomainDefFree(oldDef);
|
virDomainDefFree(oldDef);
|
||||||
VIR_FREE(configFile);
|
|
||||||
VIR_FREE(autostartLink);
|
|
||||||
return dom;
|
return dom;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
VIR_FREE(configFile);
|
|
||||||
VIR_FREE(autostartLink);
|
|
||||||
virDomainDefFree(def);
|
virDomainDefFree(def);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -531,7 +527,7 @@ virDomainObjListLoadStatus(virDomainObjList *doms,
|
|||||||
virDomainLoadConfigNotify notify,
|
virDomainLoadConfigNotify notify,
|
||||||
void *opaque)
|
void *opaque)
|
||||||
{
|
{
|
||||||
char *statusFile = NULL;
|
g_autofree char *statusFile = NULL;
|
||||||
virDomainObj *obj = NULL;
|
virDomainObj *obj = NULL;
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
|
|
||||||
@ -561,12 +557,10 @@ virDomainObjListLoadStatus(virDomainObjList *doms,
|
|||||||
if (notify)
|
if (notify)
|
||||||
(*notify)(obj, 1, opaque);
|
(*notify)(obj, 1, opaque);
|
||||||
|
|
||||||
VIR_FREE(statusFile);
|
|
||||||
return obj;
|
return obj;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
virDomainObjEndAPI(&obj);
|
virDomainObjEndAPI(&obj);
|
||||||
VIR_FREE(statusFile);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user