[libvirt PATCH 07/10] virStorageAdapterParseXMLFCHost: Use virXMLProp*

Tim Wiederhake posted 10 patches 4 years, 9 months ago
There is a newer version of this series
[libvirt PATCH 07/10] virStorageAdapterParseXMLFCHost: Use virXMLProp*
Posted by Tim Wiederhake 4 years, 9 months ago
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
---
 src/conf/storage_adapter_conf.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/src/conf/storage_adapter_conf.c b/src/conf/storage_adapter_conf.c
index 142489f6cd..6b5a58e1e7 100644
--- a/src/conf/storage_adapter_conf.c
+++ b/src/conf/storage_adapter_conf.c
@@ -64,28 +64,17 @@ static int
 virStorageAdapterParseXMLFCHost(xmlNodePtr node,
                                 virStorageAdapterFCHost *fchost)
 {
-    char *managed = NULL;
+    if (virXMLPropTristateBool(node, "managed", VIR_XML_PROP_NONE,
+                               &fchost->managed) < 0)
+        return -1;
 
     fchost->parent = virXMLPropString(node, "parent");
-    if ((managed = virXMLPropString(node, "managed"))) {
-        int value;
-        if ((value = virTristateBoolTypeFromString(managed)) < 0) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("unknown fc_host managed setting '%s'"),
-                           managed);
-            VIR_FREE(managed);
-            return -1;
-        }
-        fchost->managed = value;
-    }
-
     fchost->parent_wwnn = virXMLPropString(node, "parent_wwnn");
     fchost->parent_wwpn = virXMLPropString(node, "parent_wwpn");
     fchost->parent_fabric_wwn = virXMLPropString(node, "parent_fabric_wwn");
     fchost->wwpn = virXMLPropString(node, "wwpn");
     fchost->wwnn = virXMLPropString(node, "wwnn");
 
-    VIR_FREE(managed);
     return 0;
 }
 
-- 
2.26.3

Re: [libvirt PATCH 07/10] virStorageAdapterParseXMLFCHost: Use virXMLProp*
Posted by Laine Stump 4 years, 9 months ago
On 5/11/21 11:01 AM, Tim Wiederhake wrote:
> Signed-off-by: Tim Wiederhake <twiederh@redhat.com>

Reviewed-by: Laine Stump <laine@redhat.com>

> ---
>   src/conf/storage_adapter_conf.c | 17 +++--------------
>   1 file changed, 3 insertions(+), 14 deletions(-)
> 
> diff --git a/src/conf/storage_adapter_conf.c b/src/conf/storage_adapter_conf.c
> index 142489f6cd..6b5a58e1e7 100644
> --- a/src/conf/storage_adapter_conf.c
> +++ b/src/conf/storage_adapter_conf.c
> @@ -64,28 +64,17 @@ static int
>   virStorageAdapterParseXMLFCHost(xmlNodePtr node,
>                                   virStorageAdapterFCHost *fchost)
>   {
> -    char *managed = NULL;
> +    if (virXMLPropTristateBool(node, "managed", VIR_XML_PROP_NONE,
> +                               &fchost->managed) < 0)
> +        return -1;
>   
>       fchost->parent = virXMLPropString(node, "parent");
> -    if ((managed = virXMLPropString(node, "managed"))) {
> -        int value;
> -        if ((value = virTristateBoolTypeFromString(managed)) < 0) {
> -            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> -                           _("unknown fc_host managed setting '%s'"),
> -                           managed);
> -            VIR_FREE(managed);
> -            return -1;
> -        }
> -        fchost->managed = value;
> -    }
> -
>       fchost->parent_wwnn = virXMLPropString(node, "parent_wwnn");
>       fchost->parent_wwpn = virXMLPropString(node, "parent_wwpn");
>       fchost->parent_fabric_wwn = virXMLPropString(node, "parent_fabric_wwn");
>       fchost->wwpn = virXMLPropString(node, "wwpn");
>       fchost->wwnn = virXMLPropString(node, "wwnn");
>   
> -    VIR_FREE(managed);
>       return 0;
>   }
>   
>