]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: use structured initialization
authorLennart Poettering <lennart@poettering.net>
Wed, 27 Nov 2019 11:08:39 +0000 (12:08 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 31 Jan 2020 14:02:25 +0000 (15:02 +0100)
src/journal/sd-journal.c

index 093eb6619e09a8e3cc59093775f5cf5c0687788d..d2df5ee3b380c367bfa25ee2c101b9897a34a68a 100644 (file)
@@ -204,16 +204,17 @@ static bool same_field(const void *_a, size_t s, const void *_b, size_t t) {
 static Match *match_new(Match *p, MatchType t) {
         Match *m;
 
-        m = new0(Match, 1);
+        m = new(Match, 1);
         if (!m)
                 return NULL;
 
-        m->type = t;
+        *m = (Match) {
+                .type = t,
+                .parent = p,
+        };
 
-        if (p) {
-                m->parent = p;
+        if (p)
                 LIST_PREPEND(matches, p->matches, m);
-        }
 
         return m;
 }
@@ -1573,14 +1574,16 @@ static int add_directory(sd_journal *j, const char *prefix, const char *dirname)
 
         m = hashmap_get(j->directories_by_path, path);
         if (!m) {
-                m = new0(Directory, 1);
+                m = new(Directory, 1);
                 if (!m) {
                         r = -ENOMEM;
                         goto fail;
                 }
 
-                m->is_root = false;
-                m->path = path;
+                *m = (Directory) {
+                        .is_root = false,
+                        .path = path,
+                };
 
                 if (hashmap_put(j->directories_by_path, m->path, m) < 0) {
                         free(m);