]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/journal/mmap-cache.c
udev: fix codesonar warnings
[thirdparty/systemd.git] / src / journal / mmap-cache.c
index 90549f1c9f820d76591225b687cca331f6c4e02d..9eb3e1a62625d5510f2480c8e7bff55e61ee7ba2 100644 (file)
@@ -5,14 +5,15 @@
 #include <sys/mman.h>
 
 #include "alloc-util.h"
+#include "errno-util.h"
 #include "fd-util.h"
 #include "hashmap.h"
 #include "list.h"
 #include "log.h"
 #include "macro.h"
+#include "memory-util.h"
 #include "mmap-cache.h"
 #include "sigbus.h"
-#include "util.h"
 
 typedef struct Window Window;
 typedef struct Context Context;
@@ -132,7 +133,7 @@ static void window_free(Window *w) {
         free(w);
 }
 
-_pure_ static inline bool window_matches(Window *w, int prot, uint64_t offset, size_t size) {
+_pure_ static bool window_matches(Window *w, int prot, uint64_t offset, size_t size) {
         assert(w);
         assert(size > 0);
 
@@ -161,7 +162,7 @@ static Window *window_add(MMapCache *m, MMapFileDescriptor *f, int prot, bool ke
         if (!m->last_unused || m->n_windows <= WINDOWS_MIN) {
 
                 /* Allocate a new window */
-                w = new0(Window, 1);
+                w = new(Window, 1);
                 if (!w)
                         return NULL;
                 m->n_windows++;
@@ -170,16 +171,17 @@ static Window *window_add(MMapCache *m, MMapFileDescriptor *f, int prot, bool ke
                 /* Reuse an existing one */
                 w = m->last_unused;
                 window_unlink(w);
-                zero(*w);
         }
 
-        w->cache = m;
-        w->fd = f;
-        w->prot = prot;
-        w->keep_always = keep_always;
-        w->offset = offset;
-        w->size = size;
-        w->ptr = ptr;
+        *w = (Window) {
+                .cache = m,
+                .fd = f,
+                .prot = prot,
+                .keep_always = keep_always,
+                .offset = offset,
+                .size = size,
+                .ptr = ptr,
+        };
 
         LIST_PREPEND(by_fd, f->windows, w);