qemuMonitorGetAllBlockStatsInfo: Use automatic memory management

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Tim Wiederhake 2021-07-06 14:37:52 +02:00 committed by Michal Privoznik
parent 00a7e385f1
commit 389049a4db
1 changed files with 5 additions and 9 deletions

View File

@ -2155,26 +2155,22 @@ qemuMonitorGetAllBlockStatsInfo(qemuMonitor *mon,
bool backingChain)
{
int ret;
GHashTable *stats = NULL;
g_autoptr(GHashTable) stats = NULL;
VIR_DEBUG("ret_stats=%p, backing=%d", ret_stats, backingChain);
QEMU_CHECK_MONITOR(mon);
if (!(stats = virHashNew(g_free)))
goto error;
return -1;
ret = qemuMonitorJSONGetAllBlockStatsInfo(mon, stats, backingChain);
if (ret < 0)
goto error;
return -1;
*ret_stats = stats;
*ret_stats = g_steal_pointer(&stats);
return ret;
error:
virHashFree(stats);
*ret_stats = NULL;
return -1;
}