btrfs-progs: initialize formatter context properly

In cases where the compiler does not initialize the formatter context to
all zeros, there could be garbage values left on the depth 0 that is not
explicitly initialized. This could lead to mistakenly printing a ","
separator before the last closing "}", like

{
  "__header": {
    "version": "1"
  },
}

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2020-12-16 18:41:31 +01:00
parent 8b7d1fc918
commit 29e2dd7a23
1 changed files with 1 additions and 0 deletions

View File

@ -98,6 +98,7 @@ static void fmt_separator(struct format_ctx *fctx)
void fmt_start(struct format_ctx *fctx, const struct rowspec *spec, int width,
int indent)
{
memset(fctx, 0, sizeof(*fctx));
fctx->width = width;
fctx->indent = indent;
fctx->rowspec = spec;