diff options
author | Marc-Antoine Perennou <Marc-Antoine@Perennou.com> | 2013-11-07 13:49:00 +0900 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-11-07 18:55:21 +0100 |
commit | 261afec5ae96297b567c3735dc2cbd8bcf57d0c4 (patch) | |
tree | 3ca60fe8c652a9840ef30a6f1b939b9ce0019217 /src | |
parent | 405cd3aa0b80706331bb0255b95e3265ba8c264e (diff) |
bus: fix bus_print_property with strv
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd-bus/bus-util.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/libsystemd-bus/bus-util.c b/src/libsystemd-bus/bus-util.c index bf8fb40905..2b1cd0bc83 100644 --- a/src/libsystemd-bus/bus-util.c +++ b/src/libsystemd-bus/bus-util.c @@ -545,33 +545,28 @@ int bus_print_property(const char *name, sd_bus_message *property, bool all) { case SD_BUS_TYPE_ARRAY: if (streq(contents, "s")) { - bool space = false; - char tp; - const char *cnt; + bool first = true; + const char *str; r = sd_bus_message_enter_container(property, SD_BUS_TYPE_ARRAY, contents); if (r < 0) return r; - r = sd_bus_message_peek_type(property, &tp, &cnt); + while((r = sd_bus_message_read_basic(property, SD_BUS_TYPE_STRING, &str)) > 0) { + if (first) + printf("%s=", name); + + printf("%s%s", first ? "" : " ", str); + + first = false; + } if (r < 0) return r; - if (all || cnt) { - const char *str; - + if (first && all) printf("%s=", name); - - while((r = sd_bus_message_read_basic(property, SD_BUS_TYPE_STRING, &str)) >= 0) { - printf("%s%s", space ? " " : "", str); - - space = true; - } - if (r < 0) - return r; - + if (!first || all) puts(""); - } r = sd_bus_message_exit_container(property); if (r < 0) |