From 688b3c5ed447af39fc5d50e1f6c2b5d3e0c313d5 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 14 Jan 2021 20:17:22 +0100 Subject: [PATCH] pw-dump: only output [] when something changed --- src/tools/pw-dump.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tools/pw-dump.c b/src/tools/pw-dump.c index da95268fc..f0fc8fb22 100644 --- a/src/tools/pw-dump.c +++ b/src/tools/pw-dump.c @@ -1265,12 +1265,13 @@ static void dump_objects(struct data *d) { NULL, }, }; d->state = STATE_FIRST; - put_begin(d, NULL, "[", 0); spa_list_for_each(o, &d->object_list, link) { if (d->id != SPA_ID_INVALID && d->id != o->id) continue; if (o->changed == 0) continue; + if (d->state == STATE_FIRST) + put_begin(d, NULL, "[", 0); put_begin(d, NULL, "{", 0); put_int(d, "id", o->id); put_value(d, "type", o->type); @@ -1283,7 +1284,8 @@ static void dump_objects(struct data *d) put_end(d, "}", 0); o->changed = 0; } - put_end(d, "]\n", 0); + if (d->state != STATE_FIRST) + put_end(d, "]\n", 0); } static void on_core_error(void *data, uint32_t id, int seq, int res, const char *message)