Re: [PATCHv2 3/3] conf: Refactor virDomainDiskSourceDefParse

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

 



On 11/07/2013 11:16 AM, Peter Krempa wrote:
> Now that the function is separate clean out a few ugly places and fix up
> error messages.
> ---
> 
> Notes:
>     Version 2:
>     - rebased to changes in 1/3 of this series
> 
>  src/conf/domain_conf.c | 119 ++++++++++++++++++++++++-------------------------
>  1 file changed, 59 insertions(+), 60 deletions(-)
> 

>                  VIR_FREE(transport);
> -                if (hosts[nhosts - 1].transport != VIR_DOMAIN_DISK_PROTO_TRANS_UNIX) {
> -                    hosts[nhosts - 1].name = virXMLPropString(child, "name");
> -                    if (!hosts[nhosts - 1].name) {
> -                        virReportError(VIR_ERR_XML_ERROR,
> -                                       "%s", _("missing name for host"));
> -                        goto error;
> +
> +                if (host.transport != VIR_DOMAIN_DISK_PROTO_TRANS_UNIX) {
> +                    if (!(host.name = virXMLPropString(child, "name"))) {
> +                        virReportError(VIR_ERR_XML_ERROR, "%s",
> +                                       _("missing name for host"));
> +                        goto cleanup;
>                      }
> -                    hosts[nhosts - 1].port = virXMLPropString(child, "port");
> +
> +                    host.port = virXMLPropString(child, "port");
>                  }
> +
> +                if (VIR_APPEND_ELEMENT(*hosts, *nhosts, host))

if (VIR_APPEND_ELEMENT(..) < 0) would look clearer.

> +                    goto cleanup;
>              }
>              child = child->next;
>          }
>          break;

ACK with the following code dropped:

>  error:
> -    VIR_FREE(protocol);
> -    VIR_FREE(transport);
> -    while (nhosts > 0) {
> +   while (nhosts > 0) {
>          virDomainDiskHostDefClear(&hosts[nhosts - 1]);
>          nhosts--;
>      }


Attachment: signature.asc
Description: OpenPGP digital signature

--
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]