[DRBD-user] [PATCH] Fixes malformed json output of drbdsetup show for an empty resource.
Roland Kammerer
roland.kammerer at linbit.com
Wed Feb 12 14:02:12 CET 2020
On Wed, Feb 12, 2020 at 01:52:44PM +0100, Roland Kammerer wrote:
> On Wed, Feb 12, 2020 at 01:08:02PM +0200, Anton Tykhyy 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
>
> Hi Anton,
>
> pretty obscure use case, but LGTM at a first glance :)
Nah, it does not. The problem is not printing an ',', not the empty
volumes section. Anyways, thanks, I will prepare a proper fix for that.
Thanks, rck
More information about the drbd-user
mailing list