Re: [PATCHv1 05/13] Split out storage format 'compat' attribute sanity check

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

 



On Fri, Apr 10, 2015 at 14:58:57 +0200, Ján Tomko wrote:
> For future reuse in the snapshot XML.
> ---
>  src/conf/storage_conf.c   | 16 ++--------------
>  src/util/virstoragefile.c | 29 +++++++++++++++++++++++++++++
>  src/util/virstoragefile.h |  1 +
>  3 files changed, 32 insertions(+), 14 deletions(-)
> 

...

> diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
> index 96be02e..c1246e7 100644
> --- a/src/util/virstoragefile.c
> +++ b/src/util/virstoragefile.c
> @@ -2873,3 +2873,32 @@ virStorageFileGetRelativeBackingPath(virStorageSourcePtr top,
>      VIR_FREE(tmp);
>      return ret;
>  }
> +
> +
> +/*
> + * virStorageFileCheckCompat
> + */
> +bool
> +virStorageFileCheckCompat(const char *compat)
> +{
> +    char **version;
> +    unsigned int result;
> +    bool ret;
> +
> +    if (!compat)
> +        return true;
> +
> +    version = virStringSplit(compat, ".", 2);
> +    if (!version || !version[1] ||
> +        virStrToLong_ui(version[0], NULL, 10, &result) < 0 ||
> +        virStrToLong_ui(version[1], NULL, 10, &result) < 0) {
> +        virReportError(VIR_ERR_XML_ERROR, "%s",
> +                       _("forbidden characters in 'compat' attribute"));
> +        goto cleanup;

Functions that set errors usually return an integer despite only
returning two possible values in total.


> +    }
> +    ret = true;
> +
> + cleanup:
> +    virStringFreeList(version);
> +    return ret;
> +}

ACK if you change the return type to 'int' or add a documentation
comment explaining when the error is set.

Peter

Attachment: signature.asc
Description: 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]