]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: use empty-to-root a bit more
authorLennart Poettering <lennart@poettering.net>
Tue, 16 Jul 2019 10:08:47 +0000 (12:08 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 16 Jul 2019 10:40:22 +0000 (12:40 +0200)
coccinelle/empty-to-root.cocci [new file with mode: 0644]
src/shared/bus-unit-procs.c

diff --git a/coccinelle/empty-to-root.cocci b/coccinelle/empty-to-root.cocci
new file mode 100644 (file)
index 0000000..45627c9
--- /dev/null
@@ -0,0 +1,11 @@
+@@
+expression s;
+@@
+- if (empty_or_root(s))
+-         s = "/";
++ s = empty_to_root(s);
+@@
+expression s;
+@@
+- (empty_or_root(s) ? "/" : s)
++ empty_to_root(s)
index 054a1410acc564a7066ca3bd682b99d4d3e6e809..b9be8fe1bef231fbcd0c82c4053ce3d2b73db4cc 100644 (file)
@@ -31,8 +31,7 @@ static int add_cgroup(Hashmap *cgroups, const char *path, bool is_const, struct
         assert(cgroups);
         assert(ret);
 
-        if (empty_or_root(path))
-                path = "/";
+        path = empty_to_root(path);
 
         cg = hashmap_get(cgroups, path);
         if (cg) {
@@ -150,8 +149,7 @@ static int dump_processes(
 
         assert(prefix);
 
-        if (empty_or_root(cgroup_path))
-                cgroup_path = "/";
+        cgroup_path = empty_to_root(cgroup_path);
 
         cg = hashmap_get(cgroups, cgroup_path);
         if (!cg)