[PATCH 07/37] virDomainNetDefParseXML: Use virXMLPropEnumDefault for parsing 'def->type'

Peter Krempa posted 37 patches 3 years, 4 months ago
[PATCH 07/37] virDomainNetDefParseXML: Use virXMLPropEnumDefault for parsing 'def->type'
Posted by Peter Krempa 3 years, 4 months ago
Replace ad-hoc logic that fills the default by use of the proper helper
function.

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

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 621b1df6c8..745a7e428c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9002,13 +9002,10 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt,

     ctxt->node = node;

-    if ((rv = virXMLPropEnum(node, "type", virDomainNetTypeFromString,
-                             VIR_XML_PROP_NONE, &def->type)) < 0)
+    if (virXMLPropEnumDefault(node, "type", virDomainNetTypeFromString,
+                              VIR_XML_PROP_NONE, &def->type, VIR_DOMAIN_NET_TYPE_USER) < 0)
         return NULL;

-    if (rv == 0)
-        def->type = VIR_DOMAIN_NET_TYPE_USER;
-
     if (virXMLPropTristateBool(node, "trustGuestRxFilters", VIR_XML_PROP_NONE,
                                &def->trustGuestRxFilters) < 0)
         return NULL;
-- 
2.37.1
Re: [PATCH 07/37] virDomainNetDefParseXML: Use virXMLPropEnumDefault for parsing 'def->type'
Posted by Ján Tomko 3 years, 4 months ago
On a Monday in 2022, Peter Krempa wrote:
>Replace ad-hoc logic that fills the default by use of the proper helper
>function.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/conf/domain_conf.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano