return 0;
}
+ /* Note that 'e' might be an empty string here. That's expected. E.g. a case where the subtree
+ * corresponds to a subtree on a disk, and we want to return something that represents the root
+ * of the filesystem. */
+
ret = bus_label_unescape(e);
if (!ret)
return -ENOMEM;
}
static void test_bus_path_encode(void) {
- _cleanup_free_ char *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL, *f = NULL;
+ _cleanup_free_ char *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL, *f = NULL, *g = NULL;
assert_se(sd_bus_path_encode("/foo/bar", "waldo", &a) >= 0 && streq(a, "/foo/bar/waldo"));
assert_se(sd_bus_path_decode(a, "/waldo", &b) == 0 && b == NULL);
assert_se(sd_bus_path_encode("/foo/bar", "foo.bar", &e) >= 0 && streq(e, "/foo/bar/foo_2ebar"));
assert_se(sd_bus_path_decode(e, "/foo/bar", &f) > 0 && streq(f, "foo.bar"));
+
+ assert_se(sd_bus_path_decode("/waldo", "/waldo", &g) > 0 && streq(g, ""));
}
static void test_bus_path_encode_many(void) {