qemu_monitor: Declare and use g_autoptr for qemuMonitorEventPanicInfo

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
This commit is contained in:
Michal Privoznik 2021-10-22 09:31:22 +02:00
parent 4b1b14170a
commit 3dfc47c1fd
2 changed files with 7 additions and 16 deletions

View File

@ -194,6 +194,7 @@ struct _qemuMonitorJobInfo {
char *qemuMonitorGuestPanicEventInfoFormatMsg(qemuMonitorEventPanicInfo *info);
void qemuMonitorEventPanicInfoFree(qemuMonitorEventPanicInfo *info);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuMonitorEventPanicInfo, qemuMonitorEventPanicInfoFree);
void qemuMonitorEventRdmaGidStatusFree(qemuMonitorRdmaGidStatus *info);
void qemuMonitorMemoryDeviceSizeChangeFree(qemuMonitorMemoryDeviceSizeChange *info);

View File

@ -605,9 +605,7 @@ static void qemuMonitorJSONHandleResume(qemuMonitor *mon, virJSONValue *data G_G
static qemuMonitorEventPanicInfo *
qemuMonitorJSONGuestPanicExtractInfoHyperv(virJSONValue *data)
{
qemuMonitorEventPanicInfo *ret;
ret = g_new0(qemuMonitorEventPanicInfo, 1);
g_autoptr(qemuMonitorEventPanicInfo) ret = g_new0(qemuMonitorEventPanicInfo, 1);
ret->type = QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_HYPERV;
@ -618,20 +616,16 @@ qemuMonitorJSONGuestPanicExtractInfoHyperv(virJSONValue *data)
virJSONValueObjectGetNumberUlong(data, "arg5", &ret->data.hyperv.arg5) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed hyperv panic data"));
goto error;
return NULL;
}
return ret;
error:
qemuMonitorEventPanicInfoFree(ret);
return NULL;
return g_steal_pointer(&ret);
}
static qemuMonitorEventPanicInfo *
qemuMonitorJSONGuestPanicExtractInfoS390(virJSONValue *data)
{
qemuMonitorEventPanicInfo *ret;
g_autoptr(qemuMonitorEventPanicInfo) ret = NULL;
int core;
unsigned long long psw_mask, psw_addr;
const char *reason = NULL;
@ -645,7 +639,7 @@ qemuMonitorJSONGuestPanicExtractInfoS390(virJSONValue *data)
virJSONValueObjectGetNumberUlong(data, "psw-addr", &psw_addr) < 0 ||
!(reason = virJSONValueObjectGetString(data, "reason"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed s390 panic data"));
goto error;
return NULL;
}
ret->data.s390.core = core;
@ -654,11 +648,7 @@ qemuMonitorJSONGuestPanicExtractInfoS390(virJSONValue *data)
ret->data.s390.reason = g_strdup(reason);
return ret;
error:
qemuMonitorEventPanicInfoFree(ret);
return NULL;
return g_steal_pointer(&ret);
}
static qemuMonitorEventPanicInfo *