[PATCH 5/5] conf: report errors when parsing video accel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If any of the values are invalid, report an error and return NULL rather
than returning a partially-specified accel object. Convert to g_autofree
as well to simplify logic and remove the goto.

Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 38f8b37b69..aa8a38a849 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15295,7 +15295,7 @@ static virDomainVideoAccelDefPtr
 virDomainVideoAccelDefParseXML(xmlNodePtr node)
 {
     xmlNodePtr cur;
-    virDomainVideoAccelDefPtr def;
+    g_autofree virDomainVideoAccelDefPtr def = NULL;
     int val;
     g_autofree char *accel2d = NULL;
     g_autofree char *accel3d = NULL;
@@ -15317,14 +15317,13 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node)
     if (!accel3d && !accel2d && !rendernode)
         return NULL;
 
-    if (VIR_ALLOC(def) < 0)
-        goto cleanup;
+    def = g_new0(virDomainVideoAccelDef, 1);
 
     if (accel3d) {
         if ((val = virTristateBoolTypeFromString(accel3d)) <= 0) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("unknown accel3d value '%s'"), accel3d);
-            goto cleanup;
+            return NULL;
         }
         def->accel3d = val;
     }
@@ -15333,7 +15332,7 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node)
         if ((val = virTristateBoolTypeFromString(accel2d)) <= 0) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("unknown accel2d value '%s'"), accel2d);
-            goto cleanup;
+            return NULL;
         }
         def->accel2d = val;
     }
@@ -15341,8 +15340,7 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node)
     if (rendernode)
         def->rendernode = virFileSanitizePath(rendernode);
 
- cleanup:
-    return def;
+    return g_steal_pointer(&def);
 }
 
 static virDomainVideoResolutionDefPtr
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux