summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-02-10 16:36:58 +0100
committerTom Gundersen <teg@jklm.no>2015-02-10 22:30:35 +0100
commitf6f8d466bd6ce5f737d66a076c1f9e40d8ec9d7f (patch)
treeaacc96662a1d0d3d5e9d1c326829c5954caf6b2c /src
parent699eee62d1b1ad8af1ca944a1b500b6c3096de0d (diff)
networkd: network-bus - use sd_bus_path_{en,de}code
Diffstat (limited to 'src')
-rw-r--r--src/network/networkd-network-bus.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/network/networkd-network-bus.c b/src/network/networkd-network-bus.c
index a167857e77..6e7cbc5a45 100644
--- a/src/network/networkd-network-bus.c
+++ b/src/network/networkd-network-bus.c
@@ -40,10 +40,9 @@ const sd_bus_vtable network_vtable[] = {
};
static char *network_bus_path(Network *network) {
- _cleanup_free_ char *e = NULL;
_cleanup_free_ char *name = NULL;
- char *networkname;
- char *d;
+ char *networkname, *d, *path;
+ int r;
assert(network);
assert(network->filename);
@@ -62,11 +61,11 @@ static char *network_bus_path(Network *network) {
*d = '\0';
- e = bus_label_escape(networkname);
- if (!e)
+ r = sd_bus_path_encode("/org/freedesktop/network1/network", networkname, &path);
+ if (r < 0)
return NULL;
- return strappend("/org/freedesktop/network1/network/", e);
+ return path;
}
int network_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {
@@ -102,7 +101,6 @@ int network_object_find(sd_bus *bus, const char *path, const char *interface, vo
Manager *m = userdata;
Network *network;
_cleanup_free_ char *name = NULL;
- _cleanup_free_ char *e = NULL;
int r;
assert(bus);
@@ -111,14 +109,11 @@ int network_object_find(sd_bus *bus, const char *path, const char *interface, vo
assert(m);
assert(found);
- if (sscanf(path, "/org/freedesktop/network1/network/%ms", &name) != 1)
+ r = sd_bus_path_decode(path, "/org/freedesktop/network1/network", &name);
+ if (r < 0)
return 0;
- e = bus_label_unescape(name);
- if (!e)
- return -ENOMEM;
-
- r = network_get_by_name(m, e, &network);
+ r = network_get_by_name(m, name, &network);
if (r < 0)
return 0;