Use glib alloc API for virDomainFSInfo

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Jonathon Jongsma 2020-01-10 17:32:17 -06:00 committed by Michal Privoznik
parent 9a7d618c79
commit b28bf62b3f
3 changed files with 12 additions and 20 deletions

View File

@ -11925,15 +11925,15 @@ virDomainFSInfoFree(virDomainFSInfoPtr info)
if (!info) if (!info)
return; return;
VIR_FREE(info->mountpoint); g_free(info->mountpoint);
VIR_FREE(info->name); g_free(info->name);
VIR_FREE(info->fstype); g_free(info->fstype);
for (i = 0; i < info->ndevAlias; i++) for (i = 0; i < info->ndevAlias; i++)
VIR_FREE(info->devAlias[i]); g_free(info->devAlias[i]);
VIR_FREE(info->devAlias); g_free(info->devAlias);
VIR_FREE(info); g_free(info);
} }
/** /**

View File

@ -21938,17 +21938,14 @@ qemuAgentFSInfoToPublic(qemuAgentFSInfoPtr agent,
virDomainFSInfoPtr ret = NULL; virDomainFSInfoPtr ret = NULL;
size_t i; size_t i;
if (VIR_ALLOC(ret) < 0) ret = g_new0(virDomainFSInfo, 1);
goto error;
ret->mountpoint = g_strdup(agent->mountpoint); ret->mountpoint = g_strdup(agent->mountpoint);
ret->name = g_strdup(agent->name); ret->name = g_strdup(agent->name);
ret->fstype = g_strdup(agent->fstype); ret->fstype = g_strdup(agent->fstype);
if (agent->disks && if (agent->disks)
VIR_ALLOC_N(ret->devAlias, agent->ndisks) < 0) ret->devAlias = g_new0(char *, agent->ndisks);
goto error;
ret->ndevAlias = agent->ndisks; ret->ndevAlias = agent->ndisks;
for (i = 0; i < ret->ndevAlias; i++) { for (i = 0; i < ret->ndevAlias; i++) {
@ -21966,10 +21963,6 @@ qemuAgentFSInfoToPublic(qemuAgentFSInfoPtr agent,
} }
return ret; return ret;
error:
virDomainFSInfoFree(ret);
return NULL;
} }
/* Returns: 0 on success /* Returns: 0 on success
@ -21987,8 +21980,7 @@ virDomainFSInfoFormat(qemuAgentFSInfoPtr *agentinfo,
if (nagentinfo < 0) if (nagentinfo < 0)
return ret; return ret;
if (VIR_ALLOC_N(info_ret, nagentinfo) < 0) info_ret = g_new0(virDomainFSInfoPtr, nagentinfo);
goto cleanup;
for (i = 0; i < nagentinfo; i++) { for (i = 0; i < nagentinfo; i++) {
if (!(info_ret[i] = qemuAgentFSInfoToPublic(agentinfo[i], vmdef))) if (!(info_ret[i] = qemuAgentFSInfoToPublic(agentinfo[i], vmdef)))
@ -22006,7 +21998,7 @@ virDomainFSInfoFormat(qemuAgentFSInfoPtr *agentinfo,
if (info_ret) if (info_ret)
virDomainFSInfoFree(info_ret[i]); virDomainFSInfoFree(info_ret[i]);
} }
VIR_FREE(info_ret); g_free(info_ret);
return ret; return ret;
} }

View File

@ -7032,7 +7032,7 @@ remoteDispatchDomainGetFSInfo(virNetServerPtr server G_GNUC_UNUSED,
if (ninfo >= 0) if (ninfo >= 0)
for (i = 0; i < ninfo; i++) for (i = 0; i < ninfo; i++)
virDomainFSInfoFree(info[i]); virDomainFSInfoFree(info[i]);
VIR_FREE(info); g_free(info);
return rv; return rv;
} }