summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniel Mack <zonque@gmail.com>2013-10-25 16:33:17 +0100
committerDaniel Mack <zonque@gmail.com>2013-10-25 16:33:17 +0100
commitfd2101167e6673a1cfa860f0ee9668f51a2e050d (patch)
treeeec206f39f82e44baf746f61183b99ae405f2208 /test
parent3bcbfc513453abcbf9725530c896a7581574576f (diff)
downloadkdbus-bus-fd2101167e6673a1cfa860f0ee9668f51a2e050d.tar.gz
kdbus-bus-fd2101167e6673a1cfa860f0ee9668f51a2e050d.tar.bz2
kdbus-bus-fd2101167e6673a1cfa860f0ee9668f51a2e050d.zip
test/monitor: fix some brainos
Diffstat (limited to 'test')
-rw-r--r--test/test-kdbus-monitor.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/test/test-kdbus-monitor.c b/test/test-kdbus-monitor.c
index 2b97721daa2..5694b3b3c99 100644
--- a/test/test-kdbus-monitor.c
+++ b/test/test-kdbus-monitor.c
@@ -68,27 +68,23 @@ static int dump_packet(struct conn *conn, int fd)
msg = (struct kdbus_msg *)(conn->buf + off);
item = msg->items;
- /* calculate total size first, as we have to write it to the header */
- size = 0;
+ entry.len = msg->size;
+ entry.total_len = msg->size;
- KDBUS_PART_FOREACH(item, msg, items)
- size += item->size;
-
- entry.len = size;
- entry.total_len = size;
+ size = write(fd, &entry, sizeof(entry));
+ if (size != sizeof(entry)) {
+ fprintf(stderr, "Unable to write: %m\n");
+ return EXIT_FAILURE;
+ }
- ret = write(fd, &entry, sizeof(entry));
- if (ret != sizeof(entry)) {
+ size = write(fd, msg, msg->size);
+ if (size != msg->size) {
fprintf(stderr, "Unable to write: %m\n");
return EXIT_FAILURE;
}
- /* walk the items again to actually write them out */
+ /* walk the items and close all memfds */
KDBUS_PART_FOREACH(item, msg, items) {
- size = write(fd, item, item->size);
- if (size != item->size)
- return EXIT_FAILURE;
-
if (item->type == KDBUS_MSG_PAYLOAD_MEMFD)
close(item->memfd.fd);
}