[libvirt] [PATCH 02/15] conf: Refactor virCPUDefParseXML

Pavel Hrdina phrdina at redhat.com
Tue Jun 6 07:56:29 UTC 2017


On Mon, Jun 05, 2017 at 11:26:50AM +0200, Jiri Denemark wrote:
> Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
> ---
>  src/conf/cpu_conf.c    | 105 +++++++++++++++++++++++++++----------------------
>  src/conf/cpu_conf.h    |   9 +++--
>  src/conf/domain_conf.c |  12 +-----
>  src/cpu/cpu.c          |   5 +--
>  tests/cputest.c        |   5 +--
>  5 files changed, 68 insertions(+), 68 deletions(-)
> 
> diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
> index 79ed5e646..f7f726761 100644
> --- a/src/conf/cpu_conf.c
> +++ b/src/conf/cpu_conf.c
> @@ -245,12 +245,21 @@ virCPUDefCopy(const virCPUDef *cpu)
>  }
>  
>  
> -virCPUDefPtr
> -virCPUDefParseXML(xmlNodePtr node,
> -                  xmlXPathContextPtr ctxt,
> -                  virCPUType type)
> +/*
> + * Parses CPU definition XML from a node pointed to by @xpath. If @xpath is
> + * NULL, the current node of @ctxt is used (i.e., it is a shortcut to ".").
> + *
> + * Returns  0 on success,
> + *          1 when @xpath element cannot be found in @ctxt,
> + *         -1 on error.
> + */

All the paths in the whole series checks only for return value < 0 so
there is no reason to return 1.  Another thing is that if the return
value is 1 the @cpu would be NULL and that isn't documented.  So we can
return only 0|-1 and document that the @cpu can be NULL if @xpath was
provided but not found in ctxt.

Pavel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170606/21f198b3/attachment-0001.sig>


More information about the libvir-list mailing list