[PATCH 09/11] conf: domain: Parse 'type' attribute via virXMLPropEnum in virSysinfoParseXML

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

 



Rewrite the code to use the simple helper.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6379cfda7c..b9494500e2 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12451,8 +12451,6 @@ virSysinfoParseXML(xmlNodePtr node,
 {
     VIR_XPATH_NODE_AUTORESTORE(ctxt)
     virSysinfoDef *def;
-    g_autofree char *typeStr = NULL;
-    int type;

     ctxt->node = node;

@@ -12464,18 +12462,9 @@ virSysinfoParseXML(xmlNodePtr node,

     def = g_new0(virSysinfoDef, 1);

-    typeStr = virXMLPropString(node, "type");
-    if (typeStr == NULL) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("sysinfo must contain a type attribute"));
-        goto error;
-    }
-    if ((type = virSysinfoTypeFromString(typeStr)) < 0) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("unknown sysinfo type '%s'"), typeStr);
+    if (virXMLPropEnum(node, "type", virSysinfoTypeFromString,
+                       VIR_XML_PROP_REQUIRED, &def->type) < 0)
         goto error;
-    }
-    def->type = type;

     switch (def->type) {
     case VIR_SYSINFO_SMBIOS:
-- 
2.37.3




[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