[DRBD-user] [PATCH] Fixes malformed json output of drbdsetup show for an empty resource.

Anton Tykhyy atykhyy at gmail.com
Fri Feb 14 21:15:26 CET 2020


@Roland Kammerer: yes, that works too.

On Wed, Feb 12, 2020 at 1:08 PM Anton Tykhyy <atykhyy at gmail.com> wrote:

> To reproduce the bug:
> >> drbdsetup new-resource test 0; drbdsetup show --json|jq
> > parse error: Expected separator between values at line 6, column 21
> ---
>  user/v9/drbdsetup.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/user/v9/drbdsetup.c b/user/v9/drbdsetup.c
> index de752484..4798cf62 100644
> --- a/user/v9/drbdsetup.c
> +++ b/user/v9/drbdsetup.c
> @@ -2401,13 +2401,16 @@ static void show_resource_list_json(struct
> resources_list *resources_list, char*
>                         printf("\n");
>                 }
>
> -               printI(QUOTED("volumes") ": [\n");
> -               indent++;
> -               for (device = devices; device; device = device->next)
> -                       show_volume_json(device);
> +               if (devices)
> +               {
> +                       printI(QUOTED("volumes") ": [\n");
> +                       indent++;
> +                       for (device = devices; device; device =
> device->next)
> +                               show_volume_json(device);
>
> -               --indent;
> -               printI("]\n");
> +                       --indent;
> +                       printI("]\n");
> +               }
>
>                 --indent;
>                 printI("}");
> --
> 2.21.0.windows.1
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linbit.com/pipermail/drbd-user/attachments/20200214/8969cb22/attachment.htm>


More information about the drbd-user mailing list