summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/bus-message.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2015-04-08 11:20:10 +0200
committerDavid Herrmann <dh.herrmann@gmail.com>2015-04-09 22:59:59 +0200
commit43ef76037696cb238ef0e2a0fb84f982f41c31d8 (patch)
tree5b4ab9fb6df71f10e6b9ebc1f1b8ba7e5f9b7ec1 /src/libsystemd/sd-bus/bus-message.c
parent0704ea57b7ed3f9c46f30afea3329a4e5a9d0ea9 (diff)
bus: simplify bus_message_read_strv_extend()
Avoid unbound for(;;) loop and use the established coding-style: while ((r = sd_bus_message_read*(...)) > 0) { } if (r < 0) return r; This is much easier to read and used all over the code base.
Diffstat (limited to 'src/libsystemd/sd-bus/bus-message.c')
-rw-r--r--src/libsystemd/sd-bus/bus-message.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index 70c38cf487..6ee209dd1b 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -5550,6 +5550,7 @@ int bus_message_get_blob(sd_bus_message *m, void **buffer, size_t *sz) {
}
int bus_message_read_strv_extend(sd_bus_message *m, char ***l) {
+ const char *s;
int r;
assert(m);
@@ -5559,19 +5560,13 @@ int bus_message_read_strv_extend(sd_bus_message *m, char ***l) {
if (r <= 0)
return r;
- for (;;) {
- const char *s;
-
- r = sd_bus_message_read_basic(m, 's', &s);
- if (r < 0)
- return r;
- if (r == 0)
- break;
-
+ while ((r = sd_bus_message_read_basic(m, 's', &s)) > 0) {
r = strv_extend(l, s);
if (r < 0)
return r;
}
+ if (r < 0)
+ return r;
r = sd_bus_message_exit_container(m);
if (r < 0)