1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 02:21:44 +03:00

networkd: network-bus - use sd_bus_path_{en,de}code

This commit is contained in:
Tom Gundersen 2015-02-10 16:36:58 +01:00
parent 699eee62d1
commit f6f8d466bd

View File

@ -40,10 +40,9 @@ const sd_bus_vtable network_vtable[] = {
}; };
static char *network_bus_path(Network *network) { static char *network_bus_path(Network *network) {
_cleanup_free_ char *e = NULL;
_cleanup_free_ char *name = NULL; _cleanup_free_ char *name = NULL;
char *networkname; char *networkname, *d, *path;
char *d; int r;
assert(network); assert(network);
assert(network->filename); assert(network->filename);
@ -62,11 +61,11 @@ static char *network_bus_path(Network *network) {
*d = '\0'; *d = '\0';
e = bus_label_escape(networkname); r = sd_bus_path_encode("/org/freedesktop/network1/network", networkname, &path);
if (!e) if (r < 0)
return NULL; 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) { 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; Manager *m = userdata;
Network *network; Network *network;
_cleanup_free_ char *name = NULL; _cleanup_free_ char *name = NULL;
_cleanup_free_ char *e = NULL;
int r; int r;
assert(bus); assert(bus);
@ -111,14 +109,11 @@ int network_object_find(sd_bus *bus, const char *path, const char *interface, vo
assert(m); assert(m);
assert(found); 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; return 0;
e = bus_label_unescape(name); r = network_get_by_name(m, name, &network);
if (!e)
return -ENOMEM;
r = network_get_by_name(m, e, &network);
if (r < 0) if (r < 0)
return 0; return 0;