summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-10-26 17:30:56 +0100
committerLennart Poettering <lennart@poettering.net>2015-10-27 13:25:55 +0100
commit5f311f8c0e51e2f13773823feb6a71f7c6f2838c (patch)
tree6edfc648016e7000715e11c1ede94fde32e88d82 /src/core
parente4e73a632524c382139034d4271f53b6089ab4cb (diff)
util: remove path_get_parent(), in favour of dirname_malloc()
We don't need two functions that do essentialy the same, hence drop path_get_parent(), and stick to dirname_malloc(), but move it to path-util.[ch].
Diffstat (limited to 'src/core')
-rw-r--r--src/core/automount.c7
-rw-r--r--src/core/mount.c7
-rw-r--r--src/core/socket.c6
-rw-r--r--src/core/unit.c5
4 files changed, 12 insertions, 13 deletions
diff --git a/src/core/automount.c b/src/core/automount.c
index 2ee32312fb..df98711d96 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -141,13 +141,12 @@ static void automount_done(Unit *u) {
static int automount_add_mount_links(Automount *a) {
_cleanup_free_ char *parent = NULL;
- int r;
assert(a);
- r = path_get_parent(a->where, &parent);
- if (r < 0)
- return r;
+ parent = dirname_malloc(a->where);
+ if (!parent)
+ return -ENOMEM;
return unit_require_mounts_for(UNIT(a), parent);
}
diff --git a/src/core/mount.c b/src/core/mount.c
index 59f56bdefa..9d8b55da58 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -252,9 +252,10 @@ static int mount_add_mount_links(Mount *m) {
if (!path_equal(m->where, "/")) {
/* Adds in links to other mount points that might lie further
* up in the hierarchy */
- r = path_get_parent(m->where, &parent);
- if (r < 0)
- return r;
+
+ parent = dirname_malloc(m->where);
+ if (!parent)
+ return -ENOMEM;
r = unit_require_mounts_for(UNIT(m), parent);
if (r < 0)
diff --git a/src/core/socket.c b/src/core/socket.c
index 49cef210dc..8ea7bd9af4 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -1169,9 +1169,9 @@ static int usbffs_dispatch_eps(SocketPort *p) {
_cleanup_free_ char *path = NULL;
int r, i, n, k;
- r = path_get_parent(p->path, &path);
- if (r < 0)
- return r;
+ path = dirname_malloc(p->path);
+ if (!path)
+ return -ENOMEM;
r = scandir(path, &ent, usbffs_select_ep, alphasort);
if (r < 0)
diff --git a/src/core/unit.c b/src/core/unit.c
index 17c135cf3f..b44a2a5e2d 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -417,12 +417,11 @@ static void unit_remove_transient(Unit *u) {
STRV_FOREACH(i, u->dropin_paths) {
_cleanup_free_ char *p = NULL;
- int r;
(void) unlink(*i);
- r = path_get_parent(*i, &p);
- if (r >= 0)
+ p = dirname_malloc(*i);
+ if (p)
(void) rmdir(p);
}
}