]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/dbus-path: use structured initialization in one more place
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 21 Sep 2023 15:44:38 +0000 (17:44 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 21 Sep 2023 16:01:03 +0000 (18:01 +0200)
src/core/dbus-path.c

index 22de551c548e967c615735d2b0fc6f18fa8923a2..ced40e70d09e7222327ddacbd3b7d453ffe3f777 100644 (file)
@@ -97,7 +97,6 @@ static int bus_path_set_transient_property(
 
                         if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
                                 _cleanup_free_ char *k = NULL;
-                                PathSpec *s;
 
                                 k = strdup(path);
                                 if (!k)
@@ -105,14 +104,16 @@ static int bus_path_set_transient_property(
 
                                 path_simplify(k);
 
-                                s = new0(PathSpec, 1);
+                                PathSpec *s = new(PathSpec, 1);
                                 if (!s)
                                         return -ENOMEM;
 
-                                s->unit = u;
-                                s->path = TAKE_PTR(k);
-                                s->type = t;
-                                s->inotify_fd = -EBADF;
+                                *s = (PathSpec) {
+                                        .unit = u,
+                                        .path = TAKE_PTR(k),
+                                        .type = t,
+                                        .inotify_fd = -EBADF,
+                                };
 
                                 LIST_PREPEND(spec, p->specs, s);