From: Lennart Poettering Date: Tue, 16 Jul 2019 10:08:47 +0000 (+0200) Subject: tree-wide: use empty-to-root a bit more X-Git-Tag: v243-rc1~115^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9228fef0d6ba495b6c1bc697b88d8728421b5394;p=thirdparty%2Fsystemd.git tree-wide: use empty-to-root a bit more --- diff --git a/coccinelle/empty-to-root.cocci b/coccinelle/empty-to-root.cocci new file mode 100644 index 00000000000..45627c98019 --- /dev/null +++ b/coccinelle/empty-to-root.cocci @@ -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) diff --git a/src/shared/bus-unit-procs.c b/src/shared/bus-unit-procs.c index 054a1410acc..b9be8fe1bef 100644 --- a/src/shared/bus-unit-procs.c +++ b/src/shared/bus-unit-procs.c @@ -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)