On 5/19/21 4:10 PM, Tim Wiederhake wrote:
> Signed-off-by: Tim Wiederhake <twied...@redhat.com>
> ---
>  src/conf/storage_adapter_conf.c | 30 +++++++++++-------------------
>  1 file changed, 11 insertions(+), 19 deletions(-)
> 
> diff --git a/src/conf/storage_adapter_conf.c b/src/conf/storage_adapter_conf.c
> index a834eee81f..e93b26f06f 100644
> --- a/src/conf/storage_adapter_conf.c
> +++ b/src/conf/storage_adapter_conf.c
> @@ -170,31 +170,23 @@ virStorageAdapterParseXML(virStorageAdapter *adapter,
>  {
>      int type;
>      VIR_XPATH_NODE_AUTORESTORE(ctxt)
> -    g_autofree char *adapter_type = NULL;
>  
>      ctxt->node = node;
>  
> -    if ((adapter_type = virXMLPropString(node, "type"))) {
> -        if ((type = virStorageAdapterTypeFromString(adapter_type)) <= 0) {
> -            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> -                           _("Unknown pool adapter type '%s'"),
> -                           adapter_type);
> +    if ((type = virXMLPropEnum(node, "type", 
> virStorageAdapterTypeFromString, VIR_XML_PROP_NONZERO, &adapter->type)) < 0)

Whoa, that's a very long line :-)

>              return -1;
> -        }
> -        adapter->type = type;
>  
> -        if ((adapter->type == VIR_STORAGE_ADAPTER_TYPE_FC_HOST) &&
> -            (virStorageAdapterParseXMLFCHost(node, &adapter->data.fchost)) < 
> 0)
> -            return -1;
> +    if (type == 0)
> +        return virStorageAdapterParseXMLLegacy(node, ctxt, adapter);
>  
> -        if ((adapter->type == VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST) &&
> -            (virStorageAdapterParseXMLSCSIHost(node, ctxt,
> -                                               &adapter->data.scsi_host)) < 
> 0)
> -            return -1;
> -    } else {
> -        if (virStorageAdapterParseXMLLegacy(node, ctxt, adapter) < 0)
> -            return -1;
> -    }
> +    if ((adapter->type == VIR_STORAGE_ADAPTER_TYPE_FC_HOST) &&
> +        (virStorageAdapterParseXMLFCHost(node, &adapter->data.fchost)) < 0)
> +        return -1;
> +
> +    if ((adapter->type == VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST) &&
> +        (virStorageAdapterParseXMLSCSIHost(node, ctxt,
> +                                           &adapter->data.scsi_host)) < 0)
> +        return -1;
>  
>      return 0;
>  }
> 

Michal

Reply via email to