diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-02-13 20:32:11 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-02-13 20:33:49 +0100 |
commit | 317f2fc9e71c39eb5b3c2269b25f7f977e61db34 (patch) | |
tree | 94b977396cc0031fd62e62c225fa4baac3e991cb /src/libsystemd/sd-bus | |
parent | c3be369faa5f73c3b97c0088876bafdbfef43dae (diff) |
busctl: when formatting message contents, make sure to print all whitespaces
Previously we'd miss a necessary whitespace at the end of arrays, if more data
was following.
Diffstat (limited to 'src/libsystemd/sd-bus')
-rw-r--r-- | src/libsystemd/sd-bus/busctl.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c index 35fabf038c..772ab62d5b 100644 --- a/src/libsystemd/sd-bus/busctl.c +++ b/src/libsystemd/sd-bus/busctl.c @@ -501,8 +501,10 @@ static int format_cmdline(sd_bus_message *m, FILE *f, bool needs_space) { } basic; r = sd_bus_message_peek_type(m, &type, &contents); - if (r <= 0) + if (r < 0) return r; + if (r == 0) + return needs_space; if (bus_type_is_container(type) > 0) { @@ -533,18 +535,23 @@ static int format_cmdline(sd_bus_message *m, FILE *f, bool needs_space) { fputc(' ', f); fprintf(f, "%u", n); + needs_space = true; + } else if (type == SD_BUS_TYPE_VARIANT) { if (needs_space) fputc(' ', f); fprintf(f, "%s", contents); + needs_space = true; } - r = format_cmdline(m, f, needs_space || IN_SET(type, SD_BUS_TYPE_ARRAY, SD_BUS_TYPE_VARIANT)); + r = format_cmdline(m, f, needs_space); if (r < 0) return r; + needs_space = r > 0; + r = sd_bus_message_exit_container(m); if (r < 0) return r; |