From 0e3cb57dae357d15d7e333d71fc7d6f72e8d8134 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 16 Jul 2019 11:54:12 +0200 Subject: [PATCH 1/3] cryptsetup: no need to zero-initialize zero-initialized structures --- src/cryptsetup/cryptsetup-generator.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c index 127b3c5380c..2197160c0fa 100644 --- a/src/cryptsetup/cryptsetup-generator.c +++ b/src/cryptsetup/cryptsetup-generator.c @@ -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); From 9228fef0d6ba495b6c1bc697b88d8728421b5394 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 16 Jul 2019 12:08:47 +0200 Subject: [PATCH 2/3] 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 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) From 525e9b7991878ab448462ff20ab5d54960ecad01 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 16 Jul 2019 12:09:02 +0200 Subject: [PATCH 3/3] shared: no need to check result of strndupa() --- src/shared/bus-unit-procs.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/shared/bus-unit-procs.c b/src/shared/bus-unit-procs.c index b9be8fe1bef..b21fe393265 100644 --- a/src/shared/bus-unit-procs.c +++ b/src/shared/bus-unit-procs.c @@ -47,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)