summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/test-bus-match.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-06-06 18:30:01 +0200
committerLennart Poettering <lennart@poettering.net>2014-06-06 18:30:01 +0200
commit2a0958d2d011b2debdb266144754bb5cdc4da65d (patch)
treeaaf8733e5299e0e4700d0427e4277be72a82f73c /src/libsystemd/sd-bus/test-bus-match.c
parent55152b6ede680b9ac947c49d7dfa31cd3abe594e (diff)
sd-bus: don't allow creating message objects that are not attached to a bus
It seems unnecessary to support this, and we rather should avoid allowing this at all, so that people don't program against this sloppily and we end up remarshalling all the time...
Diffstat (limited to 'src/libsystemd/sd-bus/test-bus-match.c')
-rw-r--r--src/libsystemd/sd-bus/test-bus-match.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/libsystemd/sd-bus/test-bus-match.c b/src/libsystemd/sd-bus/test-bus-match.c
index a62de502f9..6c5d35b3d3 100644
--- a/src/libsystemd/sd-bus/test-bus-match.c
+++ b/src/libsystemd/sd-bus/test-bus-match.c
@@ -80,13 +80,19 @@ static int match_add(sd_bus_slot *slots, struct bus_match_node *root, const char
}
int main(int argc, char *argv[]) {
- struct bus_match_node root;
+ struct bus_match_node root = {
+ .type = BUS_MATCH_ROOT,
+ };
+
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
+ _cleanup_bus_unref_ sd_bus *bus = NULL;
enum bus_match_node_type i;
sd_bus_slot slots[15];
+ int r;
- zero(root);
- root.type = BUS_MATCH_ROOT;
+ r = sd_bus_open_system(&bus);
+ if (r < 0)
+ return EXIT_TEST_SKIP;
assert_se(match_add(slots, &root, "arg2='wal\\'do',sender='foo',type='signal',interface='bar.x',", 1) >= 0);
assert_se(match_add(slots, &root, "arg2='wal\\'do2',sender='foo',type='signal',interface='bar.x',", 2) >= 0);
@@ -105,7 +111,7 @@ int main(int argc, char *argv[]) {
bus_match_dump(&root, 0);
- assert_se(sd_bus_message_new_signal(NULL, &m, "/foo/bar", "bar.x", "waldo") >= 0);
+ assert_se(sd_bus_message_new_signal(bus, &m, "/foo/bar", "bar.x", "waldo") >= 0);
assert_se(sd_bus_message_append(m, "ssss", "one", "two", "/prefix/three", "prefix.four") >= 0);
assert_se(bus_message_seal(m, 1, 0) >= 0);