1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 07:59:00 +00:00

conf: use glib allocation when parsing video props

In preparation for some other improvements, switch to using glib
allocation and g_autofree when parsing the 'acceleration' and
'resolution' properties of the video device.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
Jonathon Jongsma 2019-10-23 12:46:47 -05:00 committed by Cole Robinson
parent 90c737bbd9
commit 4670f062c2

View File

@ -15257,7 +15257,7 @@ static virDomainVideoAccelDefPtr
virDomainVideoAccelDefParseXML(xmlNodePtr node) virDomainVideoAccelDefParseXML(xmlNodePtr node)
{ {
xmlNodePtr cur; xmlNodePtr cur;
virDomainVideoAccelDefPtr def; g_autofree virDomainVideoAccelDefPtr def = NULL;
int val; int val;
g_autofree char *accel2d = NULL; g_autofree char *accel2d = NULL;
g_autofree char *accel3d = NULL; g_autofree char *accel3d = NULL;
@ -15279,8 +15279,7 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node)
if (!accel3d && !accel2d && !rendernode) if (!accel3d && !accel2d && !rendernode)
return NULL; return NULL;
if (VIR_ALLOC(def) < 0) def = g_new0(virDomainVideoAccelDef, 1);
goto cleanup;
if (accel3d) { if (accel3d) {
if ((val = virTristateBoolTypeFromString(accel3d)) <= 0) { if ((val = virTristateBoolTypeFromString(accel3d)) <= 0) {
@ -15304,14 +15303,14 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node)
def->rendernode = virFileSanitizePath(rendernode); def->rendernode = virFileSanitizePath(rendernode);
cleanup: cleanup:
return def; return g_steal_pointer(&def);
} }
static virDomainVideoResolutionDefPtr static virDomainVideoResolutionDefPtr
virDomainVideoResolutionDefParseXML(xmlNodePtr node) virDomainVideoResolutionDefParseXML(xmlNodePtr node)
{ {
xmlNodePtr cur; xmlNodePtr cur;
virDomainVideoResolutionDefPtr def; g_autofree virDomainVideoResolutionDefPtr def = NULL;
g_autofree char *x = NULL; g_autofree char *x = NULL;
g_autofree char *y = NULL; g_autofree char *y = NULL;
@ -15330,8 +15329,7 @@ virDomainVideoResolutionDefParseXML(xmlNodePtr node)
if (!x || !y) if (!x || !y)
return NULL; return NULL;
if (VIR_ALLOC(def) < 0) def = g_new0(virDomainVideoResolutionDef, 1);
goto cleanup;
if (virStrToLong_uip(x, NULL, 10, &def->x) < 0) { if (virStrToLong_uip(x, NULL, 10, &def->x) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@ -15346,7 +15344,7 @@ virDomainVideoResolutionDefParseXML(xmlNodePtr node)
} }
cleanup: cleanup:
return def; return g_steal_pointer(&def);
} }
static virDomainVideoDriverDefPtr static virDomainVideoDriverDefPtr