Re: [PATCH 8/9] util: storage: Always deflatten JSON pseudo-protocol objects

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

 




On 06/27/2017 08:46 AM, Peter Krempa wrote:
> Now that the JSON deflattener is working sanely we can always attempt
> the deflattening so that we can then parse the tree as expected.
> ---
>  src/util/virstoragefile.c | 22 ++++++++++------------
>  1 file changed, 10 insertions(+), 12 deletions(-)
> 

I'm assuming you'll end up with an adjustment in this patch too since
patch 4 will have aligned the error properly... [1]


Reviewed-by: John Ferlan <jferlan@xxxxxxxxxx>

John


> diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
> index d24502fbf..f3dc860ae 100644
> --- a/src/util/virstoragefile.c
> +++ b/src/util/virstoragefile.c
> @@ -3249,24 +3249,22 @@ static int
>  virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src,
>                                           virJSONValuePtr json)
>  {
> -    virJSONValuePtr fixedroot = NULL;
> +    virJSONValuePtr deflattened = NULL;
>      virJSONValuePtr file;
>      const char *drvname;
>      char *str = NULL;
>      size_t i;
>      int ret = -1;
> 
> -    if (!(file = virJSONValueObjectGetObject(json, "file"))) {
> -        if (!(fixedroot = virJSONValueObjectDeflatten(json)))
> -            goto cleanup;
> +    if (!(deflattened = virJSONValueObjectDeflatten(json)))
> +        goto cleanup;
> 
> -        if (!(file = virJSONValueObjectGetObject(fixedroot, "file"))) {
> -            str = virJSONValueToString(json, false);
> -            virReportError(VIR_ERR_INVALID_ARG,
> -                _("JSON backing volume defintion '%s' lacks 'file' object"),
> -                str);
> -            goto cleanup;
> -        }
> +    if (!(file = virJSONValueObjectGetObject(deflattened, "file"))) {
> +        str = virJSONValueToString(json, false);
> +        virReportError(VIR_ERR_INVALID_ARG,
> +            _("JSON backing volume defintion '%s' lacks 'file' object"),
> +            str);

[1]

> +        goto cleanup;
>      }
> 
>      if (!(drvname = virJSONValueObjectGetString(file, "driver"))) {
> @@ -3290,7 +3288,7 @@ virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src,
> 
>   cleanup:
>      VIR_FREE(str);
> -    virJSONValueFree(fixedroot);
> +    virJSONValueFree(deflattened);
>      return ret;
>  }
> 

--
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]
  Powered by Linux