]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #13073 from poettering/variety-galore
authorLennart Poettering <lennart@poettering.net>
Tue, 16 Jul 2019 13:59:31 +0000 (15:59 +0200)
committerGitHub <noreply@github.com>
Tue, 16 Jul 2019 13:59:31 +0000 (15:59 +0200)
Variety galore

coccinelle/empty-to-root.cocci [new file with mode: 0644]
src/cryptsetup/cryptsetup-generator.c
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 127b3c5380c8187452064703816eb5c776f65f4a..2197160c0fac65fa574ca832d2bc787fb21bc526 100644 (file)
@@ -369,9 +369,6 @@ static crypto_device *get_crypto_device(const char *uuid) {
                 if (!d)
                         return NULL;
 
-                d->create = false;
-                d->keyfile = d->options = d->name = NULL;
-
                 d->uuid = strdup(uuid);
                 if (!d->uuid)
                         return mfree(d);
index 054a1410acc564a7066ca3bd682b99d4d3e6e809..b21fe393265f576f27ddffc2d9a5cde03a272e22 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) {
@@ -48,8 +47,6 @@ static int add_cgroup(Hashmap *cgroups, const char *path, bool is_const, struct
                         return -EINVAL;
 
                 pp = strndupa(path, e - path);
-                if (!pp)
-                        return -ENOMEM;
 
                 r = add_cgroup(cgroups, pp, false, &parent);
                 if (r < 0)
@@ -150,8 +147,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)