From 9228fef0d6ba495b6c1bc697b88d8728421b5394 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 16 Jul 2019 12:08:47 +0200 Subject: [PATCH] tree-wide: use empty-to-root a bit more --- coccinelle/empty-to-root.cocci | 11 +++++++++++ src/shared/bus-unit-procs.c | 6 ++---- 2 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 coccinelle/empty-to-root.cocci diff --git a/coccinelle/empty-to-root.cocci b/coccinelle/empty-to-root.cocci new file mode 100644 index 0000000000..45627c9801 --- /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 054a1410ac..b9be8fe1be 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)