1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 19:21:53 +03:00

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.
This commit is contained in:
Lennart Poettering 2016-02-13 20:32:11 +01:00
parent c3be369faa
commit 317f2fc9e7

View File

@ -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;