summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-03-13 12:02:21 +0100
committerLennart Poettering <lennart@poettering.net>2019-03-13 12:16:43 +0100
commit0a9707187b7d7b02751b068336fa27757797d44c (patch)
treed3273629ef7ef4f45d3153c83ca8e81a814c92b9
parenteefc66aa8f77c96a13a78d6c40c79ed7f3d6dc9d (diff)
downloadsystemd-0a9707187b7d7b02751b068336fa27757797d44c.tar.gz
util: split out memcmp()/memset() related calls into memory-util.[ch]
Just some source rearranging.
-rw-r--r--src/basic/alloc-util.c2
-rw-r--r--src/basic/hashmap.c2
-rw-r--r--src/basic/hexdecoct.c2
-rw-r--r--src/basic/limits-util.c1
-rw-r--r--src/basic/memory-util.c39
-rw-r--r--src/basic/memory-util.h53
-rw-r--r--src/basic/mempool.c1
-rw-r--r--src/basic/meson.build2
-rw-r--r--src/basic/process-util.c2
-rw-r--r--src/basic/sigbus.c2
-rw-r--r--src/basic/socket-util.c2
-rw-r--r--src/basic/stdio-util.h2
-rw-r--r--src/basic/util.c36
-rw-r--r--src/basic/util.h44
-rw-r--r--src/core/bpf-firewall.c1
-rw-r--r--src/core/execute.c2
-rw-r--r--src/core/manager.c2
-rw-r--r--src/coredump/coredump-vacuum.c2
-rw-r--r--src/coredump/coredump.c2
-rw-r--r--src/fuzz/fuzz-dns-packet.c1
-rw-r--r--src/initctl/initctl.c4
-rw-r--r--src/journal/catalog.c2
-rw-r--r--src/journal/fsprg.c1
-rw-r--r--src/journal/journal-authenticate.c1
-rw-r--r--src/journal/journal-file.c1
-rw-r--r--src/journal/journalctl.c1
-rw-r--r--src/journal/journald-native.c1
-rw-r--r--src/journal/mmap-cache.c2
-rw-r--r--src/journal/test-compress-benchmark.c1
-rw-r--r--src/journal/test-compress.c2
-rw-r--r--src/libsystemd-network/dhcp-option.c6
-rw-r--r--src/libsystemd-network/dhcp6-option.c2
-rw-r--r--src/libsystemd-network/lldp-neighbor.c2
-rw-r--r--src/libsystemd-network/ndisc-router.c1
-rw-r--r--src/libsystemd-network/sd-dhcp-client.c2
-rw-r--r--src/libsystemd-network/sd-lldp.c1
-rw-r--r--src/libsystemd-network/sd-ndisc.c2
-rw-r--r--src/libsystemd-network/sd-radv.c2
-rw-r--r--src/libsystemd-network/test-dhcp-option.c2
-rw-r--r--src/libsystemd-network/test-dhcp6-client.c3
-rw-r--r--src/libsystemd/sd-bus/bus-introspect.c2
-rw-r--r--src/libsystemd/sd-bus/bus-kernel.c2
-rw-r--r--src/libsystemd/sd-bus/bus-message.c2
-rw-r--r--src/libsystemd/sd-bus/bus-socket.c2
-rw-r--r--src/libsystemd/sd-bus/sd-bus.c2
-rw-r--r--src/libsystemd/sd-bus/test-bus-match.c1
-rw-r--r--src/libsystemd/sd-bus/test-bus-server.c2
-rw-r--r--src/libsystemd/sd-event/sd-event.c2
-rw-r--r--src/libsystemd/sd-netlink/netlink-message.c2
-rw-r--r--src/libsystemd/sd-resolve/sd-resolve.c4
-rw-r--r--src/libudev/libudev-list.c2
-rw-r--r--src/locale/localectl.c2
-rw-r--r--src/login/loginctl.c2
-rw-r--r--src/network/netdev/wireguard.c3
-rw-r--r--src/network/networkd-address.c2
-rw-r--r--src/nss-mymachines/nss-mymachines.c2
-rw-r--r--src/resolve/resolved-bus.c3
-rw-r--r--src/resolve/resolved-dns-dnssec.c1
-rw-r--r--src/resolve/resolved-dns-packet.c1
-rw-r--r--src/shared/ask-password-api.c2
-rw-r--r--src/shared/bitmap.c1
-rw-r--r--src/shared/bpf-program.c2
-rw-r--r--src/shared/format-table.c2
-rw-r--r--src/shared/json.c1
-rw-r--r--src/shared/utmp-wtmp.c2
-rw-r--r--src/systemctl/systemctl.c4
-rw-r--r--src/test/test-alloc-util.c2
-rw-r--r--src/test/test-fd-util.c2
-rw-r--r--src/test/test-seccomp.c2
-rw-r--r--src/test/test-sigbus.c4
-rw-r--r--src/test/test-siphash24.c2
-rw-r--r--src/test/test-sleep.c2
-rw-r--r--src/test/test-unaligned.c2
-rw-r--r--src/test/test-unit-file.c2
-rw-r--r--src/test/test-util.c2
-rw-r--r--src/timedate/timedated.c2
-rw-r--r--src/tty-ask-password-agent/tty-ask-password-agent.c2
-rw-r--r--src/udev/ata_id/ata_id.c2
-rw-r--r--src/udev/cdrom_id/cdrom_id.c2
-rw-r--r--src/udev/net/ethtool-util.c2
-rw-r--r--src/udev/net/link-config.c2
-rw-r--r--src/udev/scsi_id/scsi_serial.c2
82 files changed, 181 insertions, 145 deletions
diff --git a/src/basic/alloc-util.c b/src/basic/alloc-util.c
index ab7a42c4e2..b28fb95ccf 100644
--- a/src/basic/alloc-util.c
+++ b/src/basic/alloc-util.c
@@ -5,7 +5,7 @@
#include "alloc-util.h"
#include "macro.h"
-#include "util.h"
+#include "memory-util.h"
void* memdup(const void *p, size_t l) {
void *ret;
diff --git a/src/basic/hashmap.c b/src/basic/hashmap.c
index 24bdc33cec..c7bd7323a1 100644
--- a/src/basic/hashmap.c
+++ b/src/basic/hashmap.c
@@ -9,6 +9,7 @@
#include "fileio.h"
#include "hashmap.h"
#include "macro.h"
+#include "memory-util.h"
#include "mempool.h"
#include "process-util.h"
#include "random-util.h"
@@ -16,7 +17,6 @@
#include "siphash24.h"
#include "string-util.h"
#include "strv.h"
-#include "util.h"
#if ENABLE_DEBUG_HASHMAP
#include <pthread.h>
diff --git a/src/basic/hexdecoct.c b/src/basic/hexdecoct.c
index 8aedc0d583..a5660a0ff3 100644
--- a/src/basic/hexdecoct.c
+++ b/src/basic/hexdecoct.c
@@ -8,8 +8,8 @@
#include "alloc-util.h"
#include "hexdecoct.h"
#include "macro.h"
+#include "memory-util.h"
#include "string-util.h"
-#include "util.h"
char octchar(int x) {
return '0' + (x & 7);
diff --git a/src/basic/limits-util.c b/src/basic/limits-util.c
index 0cd59f97ac..fbf52e55f1 100644
--- a/src/basic/limits-util.c
+++ b/src/basic/limits-util.c
@@ -3,6 +3,7 @@
#include "alloc-util.h"
#include "cgroup-util.h"
#include "limits-util.h"
+#include "memory-util.h"
#include "parse-util.h"
#include "process-util.h"
#include "procfs-util.h"
diff --git a/src/basic/memory-util.c b/src/basic/memory-util.c
new file mode 100644
index 0000000000..3b078af20b
--- /dev/null
+++ b/src/basic/memory-util.c
@@ -0,0 +1,39 @@
+#include <unistd.h>
+
+#include "memory-util.h"
+
+size_t page_size(void) {
+ static thread_local size_t pgsz = 0;
+ long r;
+
+ if (_likely_(pgsz > 0))
+ return pgsz;
+
+ r = sysconf(_SC_PAGESIZE);
+ assert(r > 0);
+
+ pgsz = (size_t) r;
+ return pgsz;
+}
+
+bool memeqzero(const void *data, size_t length) {
+ /* Does the buffer consist entirely of NULs?
+ * Copied from https://github.com/systemd/casync/, copied in turn from
+ * https://github.com/rustyrussell/ccan/blob/master/ccan/mem/mem.c#L92,
+ * which is licensed CC-0.
+ */
+
+ const uint8_t *p = data;
+ size_t i;
+
+ /* Check first 16 bytes manually */
+ for (i = 0; i < 16; i++, length--) {
+ if (length == 0)
+ return true;
+ if (p[i])
+ return false;
+ }
+
+ /* Now we know first 16 bytes are NUL, memcmp with self. */
+ return memcmp(data, p + i, length) == 0;
+}
diff --git a/src/basic/memory-util.h b/src/basic/memory-util.h
new file mode 100644
index 0000000000..2d74b14a20
--- /dev/null
+++ b/src/basic/memory-util.h
@@ -0,0 +1,53 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+#pragma once
+
+#include <inttypes.h>
+#include <stdbool.h>
+#include <string.h>
+#include <sys/types.h>
+
+#include "macro.h"
+
+size_t page_size(void) _pure_;
+#define PAGE_ALIGN(l) ALIGN_TO((l), page_size())
+
+/* Normal memcpy requires src to be nonnull. We do nothing if n is 0. */
+static inline void memcpy_safe(void *dst, const void *src, size_t n) {
+ if (n == 0)
+ return;
+ assert(src);
+ memcpy(dst, src, n);
+}
+
+/* Normal memcmp requires s1 and s2 to be nonnull. We do nothing if n is 0. */
+static inline int memcmp_safe(const void *s1, const void *s2, size_t n) {
+ if (n == 0)
+ return 0;
+ assert(s1);
+ assert(s2);
+ return memcmp(s1, s2, n);
+}
+
+/* Compare s1 (length n1) with s2 (length n2) in lexicographic order. */
+static inline int memcmp_nn(const void *s1, size_t n1, const void *s2, size_t n2) {
+ return memcmp_safe(s1, s2, MIN(n1, n2))
+ ?: CMP(n1, n2);
+}
+
+#define memzero(x,l) \
+ ({ \
+ size_t _l_ = (l); \
+ void *_x_ = (x); \
+ _l_ == 0 ? _x_ : memset(_x_, 0, _l_); \
+ })
+
+#define zero(x) (memzero(&(x), sizeof(x)))
+
+bool memeqzero(const void *data, size_t length);
+
+#define eqzero(x) memeqzero(x, sizeof(x))
+
+static inline void *mempset(void *s, int c, size_t n) {
+ memset(s, c, n);
+ return (uint8_t*)s + n;
+}
diff --git a/src/basic/mempool.c b/src/basic/mempool.c
index 159c963377..22df42105b 100644
--- a/src/basic/mempool.c
+++ b/src/basic/mempool.c
@@ -5,6 +5,7 @@
#include "env-util.h"
#include "macro.h"
+#include "memory-util.h"
#include "mempool.h"
#include "process-util.h"
#include "util.h"
diff --git a/src/basic/meson.build b/src/basic/meson.build
index f7556b4198..3d382b3940 100644
--- a/src/basic/meson.build
+++ b/src/basic/meson.build
@@ -91,6 +91,8 @@ basic_sources = files('''
macro.h
memfd-util.c
memfd-util.h
+ memory-util.c
+ memory-util.h
mempool.c
mempool.h
missing.h
diff --git a/src/basic/process-util.c b/src/basic/process-util.c
index 615b6d4044..86d5c3adb5 100644
--- a/src/basic/process-util.c
+++ b/src/basic/process-util.c
@@ -32,6 +32,7 @@
#include "ioprio.h"
#include "log.h"
#include "macro.h"
+#include "memory-util.h"
#include "missing.h"
#include "namespace-util.h"
#include "process-util.h"
@@ -43,7 +44,6 @@
#include "string-util.h"
#include "terminal-util.h"
#include "user-util.h"
-#include "util.h"
int get_process_state(pid_t pid) {
const char *p;
diff --git a/src/basic/sigbus.c b/src/basic/sigbus.c
index d5254eab9d..a065a45a8c 100644
--- a/src/basic/sigbus.c
+++ b/src/basic/sigbus.c
@@ -6,8 +6,8 @@
#include <sys/mman.h>
#include "macro.h"
+#include "memory-util.h"
#include "sigbus.h"
-#include "util.h"
#define SIGBUS_QUEUE_MAX 64
diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c
index a8c9115dc2..3c156fd659 100644
--- a/src/basic/socket-util.c
+++ b/src/basic/socket-util.c
@@ -21,6 +21,7 @@
#include "format-util.h"
#include "log.h"
#include "macro.h"
+#include "memory-util.h"
#include "missing.h"
#include "parse-util.h"
#include "path-util.h"
@@ -31,7 +32,6 @@
#include "strv.h"
#include "user-util.h"
#include "utf8.h"
-#include "util.h"
#if ENABLE_IDN
# define IDN_FLAGS NI_IDN
diff --git a/src/basic/stdio-util.h b/src/basic/stdio-util.h
index dc67b6e761..c3b9448d4f 100644
--- a/src/basic/stdio-util.h
+++ b/src/basic/stdio-util.h
@@ -7,7 +7,7 @@
#include <sys/types.h>
#include "macro.h"
-#include "util.h"
+#include "memory-util.h"
#define snprintf_ok(buf, len, fmt, ...) \
((size_t) snprintf(buf, len, fmt, __VA_ARGS__) < (len))
diff --git a/src/basic/util.c b/src/basic/util.c
index b275570618..fd0277b5df 100644
--- a/src/basic/util.c
+++ b/src/basic/util.c
@@ -51,20 +51,6 @@ int saved_argc = 0;
char **saved_argv = NULL;
static int saved_in_initrd = -1;
-size_t page_size(void) {
- static thread_local size_t pgsz = 0;
- long r;
-
- if (_likely_(pgsz > 0))
- return pgsz;
-
- r = sysconf(_SC_PAGESIZE);
- assert(r > 0);
-
- pgsz = (size_t) r;
- return pgsz;
-}
-
bool plymouth_running(void) {
return access("/run/plymouth/pid", F_OK) >= 0;
}
@@ -165,28 +151,6 @@ void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
return NULL;
}
-bool memeqzero(const void *data, size_t length) {
- /* Does the buffer consist entirely of NULs?
- * Copied from https://github.com/systemd/casync/, copied in turn from
- * https://github.com/rustyrussell/ccan/blob/master/ccan/mem/mem.c#L92,
- * which is licensed CC-0.
- */
-
- const uint8_t *p = data;
- size_t i;
-
- /* Check first 16 bytes manually */
- for (i = 0; i < 16; i++, length--) {
- if (length == 0)
- return true;
- if (p[i])
- return false;
- }
-
- /* Now we know first 16 bytes are NUL, memcmp with self. */
- return memcmp(data, p + i, length) == 0;
-}
-
int on_ac_power(void) {
bool found_offline = false, found_online = false;
_cleanup_closedir_ DIR *d = NULL;
diff --git a/src/basic/util.h b/src/basic/util.h
index dd0f6e5cc8..3c29586749 100644
--- a/src/basic/util.h
+++ b/src/basic/util.h
@@ -27,9 +27,6 @@
#include "macro.h"
#include "time-util.h"
-size_t page_size(void) _pure_;
-#define PAGE_ALIGN(l) ALIGN_TO((l), page_size())
-
static inline const char* yes_no(bool b) {
return b ? "yes" : "no";
}
@@ -130,49 +127,8 @@ static inline void qsort_r_safe(void *base, size_t nmemb, size_t size, __compar_
qsort_r_safe((p), (n), sizeof((p)[0]), (__compar_d_fn_t) _func_, userdata); \
})
-/* Normal memcpy requires src to be nonnull. We do nothing if n is 0. */
-static inline void memcpy_safe(void *dst, const void *src, size_t n) {
- if (n == 0)
- return;
- assert(src);
- memcpy(dst, src, n);
-}
-
-/* Normal memcmp requires s1 and s2 to be nonnull. We do nothing if n is 0. */
-static inline int memcmp_safe(const void *s1, const void *s2, size_t n) {
- if (n == 0)
- return 0;
- assert(s1);
- assert(s2);
- return memcmp(s1, s2, n);
-}
-
-/* Compare s1 (length n1) with s2 (length n2) in lexicographic order. */
-static inline int memcmp_nn(const void *s1, size_t n1, const void *s2, size_t n2) {
- return memcmp_safe(s1, s2, MIN(n1, n2))
- ?: CMP(n1, n2);
-}
-
int on_ac_power(void);
-#define memzero(x,l) \
- ({ \
- size_t _l_ = (l); \
- void *_x_ = (x); \
- _l_ == 0 ? _x_ : memset(_x_, 0, _l_); \
- })
-
-#define zero(x) (memzero(&(x), sizeof(x)))
-
-bool memeqzero(const void *data, size_t length);
-
-#define eqzero(x) memeqzero(x, sizeof(x))
-
-static inline void *mempset(void *s, int c, size_t n) {
- memset(s, c, n);
- return (uint8_t*)s + n;
-}
-
static inline void _reset_errno_(int *saved_errno) {
if (*saved_errno < 0) /* Invalidated by UNPROTECT_ERRNO? */
return;
diff --git a/src/core/bpf-firewall.c b/src/core/bpf-firewall.c
index b9a611fd9e..2ecce300da 100644
--- a/src/core/bpf-firewall.c
+++ b/src/core/bpf-firewall.c
@@ -20,6 +20,7 @@
#include "bpf-program.h"
#include "fd-util.h"
#include "ip-address-access.h"
+#include "memory-util.h"
#include "missing_syscall.h"
#include "unit.h"
diff --git a/src/core/execute.c b/src/core/execute.c
index fb7564b9fe..49478305e2 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -65,6 +65,7 @@
#include "log.h"
#include "macro.h"
#include "manager.h"
+#include "memory-util.h"
#include "missing.h"
#include "mkdir.h"
#include "namespace.h"
@@ -91,7 +92,6 @@
#include "umask-util.h"
#include "unit.h"
#include "user-util.h"
-#include "util.h"
#include "utmp-wtmp.h"
#define IDLE_TIMEOUT_USEC (5*USEC_PER_SEC)
diff --git a/src/core/manager.c b/src/core/manager.c
index f305dc6647..e60ee32b06 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -52,6 +52,7 @@
#include "log.h"
#include "macro.h"
#include "manager.h"
+#include "memory-util.h"
#include "missing.h"
#include "mkdir.h"
#include "parse-util.h"
@@ -77,7 +78,6 @@
#include "umask-util.h"
#include "unit-name.h"
#include "user-util.h"
-#include "util.h"
#include "virt.h"
#include "watchdog.h"
diff --git a/src/coredump/coredump-vacuum.c b/src/coredump/coredump-vacuum.c
index 6ce5dfc71d..73fd420f3d 100644
--- a/src/coredump/coredump-vacuum.c
+++ b/src/coredump/coredump-vacuum.c
@@ -9,10 +9,10 @@
#include "fs-util.h"
#include "hashmap.h"
#include "macro.h"
+#include "memory-util.h"
#include "string-util.h"
#include "time-util.h"
#include "user-util.h"
-#include "util.h"
#define DEFAULT_MAX_USE_LOWER (uint64_t) (1ULL*1024ULL*1024ULL) /* 1 MiB */
#define DEFAULT_MAX_USE_UPPER (uint64_t) (4ULL*1024ULL*1024ULL*1024ULL) /* 4 GiB */
diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c
index ecbb4bffc9..85e265c218 100644
--- a/src/coredump/coredump.c
+++ b/src/coredump/coredump.c
@@ -35,6 +35,7 @@
#include "log.h"
#include "macro.h"
#include "main-func.h"
+#include "memory-util.h"
#include "missing.h"
#include "mkdir.h"
#include "parse-util.h"
@@ -48,7 +49,6 @@
#include "strv.h"
#include "tmpfile-util.h"
#include "user-util.h"
-#include "util.h"
/* The maximum size up to which we process coredumps */
#define PROCESS_SIZE_MAX ((uint64_t) (2LLU*1024LLU*1024LLU*1024LLU))
diff --git a/src/fuzz/fuzz-dns-packet.c b/src/fuzz/fuzz-dns-packet.c
index c150c8184c..9bf95b9c76 100644
--- a/src/fuzz/fuzz-dns-packet.c
+++ b/src/fuzz/fuzz-dns-packet.c
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#include "fuzz.h"
+#include "memory-util.h"
#include "resolved-dns-packet.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
diff --git a/src/initctl/initctl.c b/src/initctl/initctl.c
index 260dc2eb61..651e70c7fa 100644
--- a/src/initctl/initctl.c
+++ b/src/initctl/initctl.c
@@ -18,9 +18,9 @@
#include "initreq.h"
#include "list.h"
#include "log.h"
-#include "special.h"
-#include "util.h"
+#include "memory-util.h"
#include "process-util.h"
+#include "special.h"
#define SERVER_FD_MAX 16
#define TIMEOUT_MSEC ((int) (DEFAULT_EXIT_USEC/USEC_PER_MSEC))
diff --git a/src/journal/catalog.c b/src/journal/catalog.c
index ccee950d1d..b0856f4583 100644
--- a/src/journal/catalog.c
+++ b/src/journal/catalog.c
@@ -17,6 +17,7 @@
#include "fileio.h"
#include "hashmap.h"
#include "log.h"
+#include "memory-util.h"
#include "mkdir.h"
#include "path-util.h"
#include "siphash24.h"
@@ -25,7 +26,6 @@
#include "string-util.h"
#include "strv.h"
#include "tmpfile-util.h"
-#include "util.h"
const char * const catalog_file_dirs[] = {
"/usr/local/lib/systemd/catalog/",
diff --git a/src/journal/fsprg.c b/src/journal/fsprg.c
index 6d062de5f4..d60fc50068 100644
--- a/src/journal/fsprg.c
+++ b/src/journal/fsprg.c
@@ -32,6 +32,7 @@
#include "fsprg.h"
#include "gcrypt-util.h"
+#include "memory-util.h"
#define ISVALID_SECPAR(secpar) (((secpar) % 16 == 0) && ((secpar) >= 16) && ((secpar) <= 16384))
#define VALIDATE_SECPAR(secpar) assert(ISVALID_SECPAR(secpar));
diff --git a/src/journal/journal-authenticate.c b/src/journal/journal-authenticate.c
index 8a9ce8a0d0..a5ee10c3bc 100644
--- a/src/journal/journal-authenticate.c
+++ b/src/journal/journal-authenticate.c
@@ -10,6 +10,7 @@
#include "journal-authenticate.h"
#include "journal-def.h"
#include "journal-file.h"
+#include "memory-util.h"
static uint64_t journal_file_tag_seqnum(JournalFile *f) {
uint64_t r;
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 56827f9f36..6b4f07c85f 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -22,6 +22,7 @@
#include "journal-def.h"
#include "journal-file.h"
#include "lookup3.h"
+#include "memory-util.h"
#include "parse-util.h"
#include "path-util.h"
#include "random-util.h"
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 75b23c7144..9b813a14a0 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -50,6 +50,7 @@
#include "locale-util.h"
#include "log.h"
#include "logs-show.h"
+#include "memory-util.h"
#include "mkdir.h"
#include "pager.h"
#include "parse-util.h"
diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c
index 221188db16..4efe34c664 100644
--- a/src/journal/journald-native.c
+++ b/src/journal/journald-native.c
@@ -19,6 +19,7 @@
#include "journald-syslog.h"
#include "journald-wall.h"
#include "memfd-util.h"
+#include "memory-util.h"
#include "parse-util.h"
#include "path-util.h"
#include "process-util.h"
diff --git a/src/journal/mmap-cache.c b/src/journal/mmap-cache.c
index 0dc453e709..7152564293 100644
--- a/src/journal/mmap-cache.c
+++ b/src/journal/mmap-cache.c
@@ -10,9 +10,9 @@
#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;
diff --git a/src/journal/test-compress-benchmark.c b/src/journal/test-compress-benchmark.c
index 7f13b611e6..1838f5b7d9 100644
--- a/src/journal/test-compress-benchmark.c
+++ b/src/journal/test-compress-benchmark.c
@@ -4,6 +4,7 @@
#include "compress.h"
#include "env-util.h"
#include "macro.h"
+#include "memory-util.h"
#include "parse-util.h"
#include "process-util.h"
#include "random-util.h"
diff --git a/src/journal/test-compress.c b/src/journal/test-compress.c
index 1b050b7052..0920833c12 100644
--- a/src/journal/test-compress.c
+++ b/src/journal/test-compress.c
@@ -9,11 +9,11 @@
#include "fd-util.h"
#include "fs-util.h"
#include "macro.h"
+#include "memory-util.h"
#include "path-util.h"
#include "random-util.h"
#include "tests.h"
#include "tmpfile-util.h"
-#include "util.h"
#if HAVE_XZ
# define XZ_OK 0
diff --git a/src/libsystemd-network/dhcp-option.c b/src/libsystemd-network/dhcp-option.c
index ad3f92546d..a68de4ff98 100644
--- a/src/libsystemd-network/dhcp-option.c
+++ b/src/libsystemd-network/dhcp-option.c
@@ -9,10 +9,10 @@
#include <string.h>
#include "alloc-util.h"
-#include "utf8.h"
-#include "strv.h"
-
#include "dhcp-internal.h"
+#include "memory-util.h"
+#include "strv.h"
+#include "utf8.h"
static int option_append(uint8_t options[], size_t size, size_t *offset,
uint8_t code, size_t optlen, const void *optval) {
diff --git a/src/libsystemd-network/dhcp6-option.c b/src/libsystemd-network/dhcp6-option.c
index a2aac9a793..017402c53b 100644
--- a/src/libsystemd-network/dhcp6-option.c
+++ b/src/libsystemd-network/dhcp6-option.c
@@ -14,10 +14,10 @@
#include "dhcp6-lease-internal.h"
#include "dhcp6-protocol.h"
#include "dns-domain.h"
+#include "memory-util.h"
#include "sparse-endian.h"
#include "strv.h"
#include "unaligned.h"
-#include "util.h"
typedef struct DHCP6StatusOption {
struct DHCP6Option option;
diff --git a/src/libsystemd-network/lldp-neighbor.c b/src/libsystemd-network/lldp-neighbor.c
index f6db62594d..9bae4a3c6e 100644
--- a/src/libsystemd-network/lldp-neighbor.c
+++ b/src/libsystemd-network/lldp-neighbor.c
@@ -7,9 +7,9 @@
#include "in-addr-util.h"
#include "lldp-internal.h"
#include "lldp-neighbor.h"
+#include "memory-util.h"
#include "missing.h"
#include "unaligned.h"
-#include "util.h"
static void lldp_neighbor_id_hash_func(const LLDPNeighborID *id, struct siphash *state) {
siphash24_compress(id->chassis_id, id->chassis_id_size, state);
diff --git a/src/libsystemd-network/ndisc-router.c b/src/libsystemd-network/ndisc-router.c
index 6935311b9a..c0938724e3 100644
--- a/src/libsystemd-network/ndisc-router.c
+++ b/src/libsystemd-network/ndisc-router.c
@@ -10,6 +10,7 @@
#include "alloc-util.h"
#include "dns-domain.h"
#include "hostname-util.h"
+#include "memory-util.h"
#include "missing.h"
#include "ndisc-internal.h"
#include "ndisc-router.h"
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index 7975cfecf5..97e1dd3702 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -24,10 +24,10 @@
#include "event-util.h"
#include "hostname-util.h"
#include "io-util.h"
+#include "memory-util.h"
#include "random-util.h"
#include "string-util.h"
#include "strv.h"
-#include "util.h"
#define MAX_CLIENT_ID_LEN (sizeof(uint32_t) + MAX_DUID_LEN) /* Arbitrary limit */
#define MAX_MAC_ADDR_LEN CONST_MAX(INFINIBAND_ALEN, ETH_ALEN)
diff --git a/src/libsystemd-network/sd-lldp.c b/src/libsystemd-network/sd-lldp.c
index 969fc71051..3460dc09bd 100644
--- a/src/libsystemd-network/sd-lldp.c
+++ b/src/libsystemd-network/sd-lldp.c
@@ -13,6 +13,7 @@
#include "lldp-internal.h"
#include "lldp-neighbor.h"
#include "lldp-network.h"
+#include "memory-util.h"
#include "socket-util.h"
#include "string-table.h"
diff --git a/src/libsystemd-network/sd-ndisc.c b/src/libsystemd-network/sd-ndisc.c
index 32c20b1e4a..5e711713d9 100644
--- a/src/libsystemd-network/sd-ndisc.c
+++ b/src/libsystemd-network/sd-ndisc.c
@@ -13,13 +13,13 @@
#include "fd-util.h"
#include "icmp6-util.h"
#include "in-addr-util.h"
+#include "memory-util.h"
#include "ndisc-internal.h"
#include "ndisc-router.h"
#include "random-util.h"
#include "socket-util.h"
#include "string-table.h"
#include "string-util.h"
-#include "util.h"
#define NDISC_TIMEOUT_NO_RA_USEC (NDISC_ROUTER_SOLICITATION_INTERVAL * NDISC_MAX_ROUTER_SOLICITATIONS)
diff --git a/src/libsystemd-network/sd-radv.c b/src/libsystemd-network/sd-radv.c
index 098e01fb82..08433adb25 100644
--- a/src/libsystemd-network/sd-radv.c
+++ b/src/libsystemd-network/sd-radv.c
@@ -18,12 +18,12 @@
#include "in-addr-util.h"
#include "io-util.h"
#include "macro.h"
+#include "memory-util.h"
#include "radv-internal.h"
#include "random-util.h"
#include "socket-util.h"
#include "string-util.h"
#include "strv.h"
-#include "util.h"
_public_ int sd_radv_new(sd_radv **ret) {
_cleanup_(sd_radv_unrefp) sd_radv *ra = NULL;
diff --git a/src/libsystemd-network/test-dhcp-option.c b/src/libsystemd-network/test-dhcp-option.c
index d84859c053..56bd690cb0 100644
--- a/src/libsystemd-network/test-dhcp-option.c
+++ b/src/libsystemd-network/test-dhcp-option.c
@@ -7,7 +7,7 @@
#include "dhcp-internal.h"
#include "dhcp-protocol.h"
#include "macro.h"
-#include "util.h"
+#include "memory-util.h"
struct option_desc {
uint8_t sname[64];
diff --git a/src/libsystemd-network/test-dhcp6-client.c b/src/libsystemd-network/test-dhcp6-client.c
index fa94b3cb75..00056aa9e2 100644
--- a/src/libsystemd-network/test-dhcp6-client.c
+++ b/src/libsystemd-network/test-dhcp6-client.c
@@ -18,9 +18,10 @@
#include "dhcp6-protocol.h"
#include "fd-util.h"
#include "macro.h"
+#include "memory-util.h"
#include "socket-util.h"
#include "tests.h"
-#include "util.h"
+#include "time-util.h"
#include "virt.h"
static struct ether_addr mac_addr = {
diff --git a/src/libsystemd/sd-bus/bus-introspect.c b/src/libsystemd/sd-bus/bus-introspect.c
index bde97483e8..29a5ef715e 100644
--- a/src/libsystemd/sd-bus/bus-introspect.c
+++ b/src/libsystemd/sd-bus/bus-introspect.c
@@ -9,8 +9,8 @@
#include "bus-signature.h"
#include "fd-util.h"
#include "fileio.h"
+#include "memory-util.h"
#include "string-util.h"
-#include "util.h"
int introspect_begin(struct introspect *i, bool trusted) {
assert(i);
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 34c8a9f8c8..b74cfa6ab8 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -31,7 +31,7 @@
#include "string-util.h"
#include "strv.h"
#include "user-util.h"
-#include "util.h"
+#include "memory-util.h"
void close_and_munmap(int fd, void *address, size_t size) {
if (size > 0)
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index 700c57d362..11c4648f91 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -16,11 +16,11 @@
#include "fd-util.h"
#include "io-util.h"
#include "memfd-util.h"
+#include "memory-util.h"
#include "string-util.h"
#include "strv.h"
#include "time-util.h"
#include "utf8.h"
-#include "util.h"
static int message_append_basic(sd_bus_message *m, char type, const void *p, const void **stored);
diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c
index df9b2631fd..89ac503ab8 100644
--- a/src/libsystemd/sd-bus/bus-socket.c
+++ b/src/libsystemd/sd-bus/bus-socket.c
@@ -18,6 +18,7 @@
#include "hexdecoct.h"
#include "io-util.h"
#include "macro.h"
+#include "memory-util.h"
#include "missing.h"
#include "path-util.h"
#include "process-util.h"
@@ -28,7 +29,6 @@
#include "string-util.h"
#include "user-util.h"
#include "utf8.h"
-#include "util.h"
#define SNDBUF_SIZE (8*1024*1024)
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index ba791db4f2..f7177963c2 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -32,12 +32,12 @@
#include "hexdecoct.h"
#include "hostname-util.h"
#include "macro.h"
+#include "memory-util.h"
#include "missing.h"
#include "parse-util.h"
#include "process-util.h"
#include "string-util.h"
#include "strv.h"
-#include "util.h"
#define log_debug_bus_message(m) \
do { \
diff --git a/src/libsystemd/sd-bus/test-bus-match.c b/src/libsystemd/sd-bus/test-bus-match.c
index 0949d8dee6..47014c403b 100644
--- a/src/libsystemd/sd-bus/test-bus-match.c
+++ b/src/libsystemd/sd-bus/test-bus-match.c
@@ -6,6 +6,7 @@
#include "bus-util.h"
#include "log.h"
#include "macro.h"
+#include "memory-util.h"
#include "tests.h"
static bool mask[32];
diff --git a/src/libsystemd/sd-bus/test-bus-server.c b/src/libsystemd/sd-bus/test-bus-server.c
index 0f1b9645bc..e38bcdcc76 100644
--- a/src/libsystemd/sd-bus/test-bus-server.c
+++ b/src/libsystemd/sd-bus/test-bus-server.c
@@ -9,7 +9,7 @@
#include "bus-util.h"
#include "log.h"
#include "macro.h"
-#include "util.h"
+#include "memory-util.h"
struct context {
int fds[2];
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index 04ba7e2574..eb98e49ca2 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -15,6 +15,7 @@
#include "hashmap.h"
#include "list.h"
#include "macro.h"
+#include "memory-util.h"
#include "missing.h"
#include "prioq.h"
#include "process-util.h"
@@ -23,7 +24,6 @@
#include "string-table.h"
#include "string-util.h"
#include "time-util.h"
-#include "util.h"
#define DEFAULT_ACCURACY_USEC (250 * USEC_PER_MSEC)
diff --git a/src/libsystemd/sd-netlink/netlink-message.c b/src/libsystemd/sd-netlink/netlink-message.c
index bf3ac95400..0dcc53be55 100644
--- a/src/libsystemd/sd-netlink/netlink-message.c
+++ b/src/libsystemd/sd-netlink/netlink-message.c
@@ -13,7 +13,7 @@
#include "netlink-types.h"
#include "netlink-util.h"
#include "socket-util.h"
-#include "util.h"
+#include "memory-util.h"
#define GET_CONTAINER(m, i) ((i) < (m)->n_containers ? (struct rtattr*)((uint8_t*)(m)->hdr + (m)->containers[i].offset) : NULL)
#define PUSH_CONTAINER(m, new) (m)->container_offsets[(m)->n_containers++] = (uint8_t*)(new) - (uint8_t*)(m)->hdr;
diff --git a/src/libsystemd/sd-resolve/sd-resolve.c b/src/libsystemd/sd-resolve/sd-resolve.c
index 36b9c8d019..fdad3bd697 100644
--- a/src/libsystemd/sd-resolve/sd-resolve.c
+++ b/src/libsystemd/sd-resolve/sd-resolve.c
@@ -19,11 +19,11 @@
#include "fd-util.h"
#include "io-util.h"
#include "list.h"
+#include "memory-util.h"
#include "missing.h"
+#include "process-util.h"
#include "resolve-private.h"
#include "socket-util.h"
-#include "util.h"
-#include "process-util.h"
#define WORKERS_MIN 1U
#define WORKERS_MAX 16U
diff --git a/src/libudev/libudev-list.c b/src/libudev/libudev-list.c
index 2737326187..00fd58b9ea 100644
--- a/src/libudev/libudev-list.c
+++ b/src/libudev/libudev-list.c
@@ -7,7 +7,7 @@
#include "alloc-util.h"
#include "libudev-list-internal.h"
-#include "util.h"
+#include "memory-util.h"
/**
* SECTION:libudev-list
diff --git a/src/locale/localectl.c b/src/locale/localectl.c
index 69f5667801..683b127ba1 100644
--- a/src/locale/localectl.c
+++ b/src/locale/localectl.c
@@ -16,13 +16,13 @@
#include "fileio.h"
#include "locale-util.h"
#include "main-func.h"
+#include "memory-util.h"
#include "pager.h"
#include "pretty-print.h"
#include "proc-cmdline.h"
#include "set.h"
#include "spawn-polkit-agent.h"
#include "strv.h"
-#include "util.h"
#include "verbs.h"
#include "virt.h"
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
index 69850724da..b40f527233 100644
--- a/src/login/loginctl.c
+++ b/src/login/loginctl.c
@@ -19,6 +19,7 @@
#include "logs-show.h"
#include "macro.h"
#include "main-func.h"
+#include "memory-util.h"
#include "pager.h"
#include "parse-util.h"
#include "pretty-print.h"
@@ -33,7 +34,6 @@
#include "terminal-util.h"
#include "unit-name.h"
#include "user-util.h"
-#include "util.h"
#include "verbs.h"
static char **arg_property = NULL;
diff --git a/src/network/netdev/wireguard.c b/src/network/netdev/wireguard.c
index eefb543c4d..b1b2ae1bb9 100644
--- a/src/network/netdev/wireguard.c
+++ b/src/network/netdev/wireguard.c
@@ -13,6 +13,7 @@
#include "fd-util.h"
#include "fileio.h"
#include "hexdecoct.h"
+#include "memory-util.h"
#include "netlink-util.h"
#include "networkd-link.h"
#include "networkd-manager.h"
@@ -22,8 +23,8 @@
#include "resolve-private.h"
#include "string-util.h"
#include "strv.h"
-#include "wireguard.h"
#include "wireguard-netlink.h"
+#include "wireguard.h"
static void resolve_endpoints(NetDev *netdev);
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c
index 1a9ba4223c..42d61cc0e5 100644
--- a/src/network/networkd-address.c
+++ b/src/network/networkd-address.c
@@ -5,6 +5,7 @@
#include "alloc-util.h"
#include "conf-parser.h"
#include "firewall-util.h"
+#include "memory-util.h"
#include "missing_network.h"
#include "netlink-util.h"
#include "networkd-address.h"
@@ -15,7 +16,6 @@
#include "string-util.h"
#include "strv.h"
#include "utf8.h"
-#include "util.h"
#define ADDRESSES_PER_LINK_MAX 2048U
#define STATIC_ADDRESSES_PER_NETWORK_MAX 1024U
diff --git a/src/nss-mymachines/nss-mymachines.c b/src/nss-mymachines/nss-mymachines.c
index 486a658958..da003e6aa7 100644
--- a/src/nss-mymachines/nss-mymachines.c
+++ b/src/nss-mymachines/nss-mymachines.c
@@ -12,11 +12,11 @@
#include "hostname-util.h"
#include "in-addr-util.h"
#include "macro.h"
+#include "memory-util.h"
#include "nss-util.h"
#include "signal-util.h"
#include "string-util.h"
#include "user-util.h"
-#include "util.h"
NSS_GETHOSTBYNAME_PROTOTYPES(mymachines);
NSS_GETPW_PROTOTYPES(mymachines);
diff --git a/src/resolve/resolved-bus.c b/src/resolve/resolved-bus.c
index 5b547ba7ee..4fc281e80a 100644
--- a/src/resolve/resolved-bus.c
+++ b/src/resolve/resolved-bus.c
@@ -4,12 +4,13 @@
#include "bus-common-errors.h"
#include "bus-util.h"
#include "dns-domain.h"
+#include "memory-util.h"
#include "missing_capability.h"
#include "resolved-bus.h"
#include "resolved-def.h"
#include "resolved-dns-synthesize.h"
-#include "resolved-dnssd.h"
#include "resolved-dnssd-bus.h"
+#include "resolved-dnssd.h"
#include "resolved-link-bus.h"
#include "user-util.h"
#include "utf8.h"
diff --git a/src/resolve/resolved-dns-dnssec.c b/src/resolve/resolved-dns-dnssec.c
index 3be18de841..ad7b623b69 100644
--- a/src/resolve/resolved-dns-dnssec.c
+++ b/src/resolve/resolved-dns-dnssec.c
@@ -12,6 +12,7 @@
#include "fileio.h"
#include "gcrypt-util.h"
#include "hexdecoct.h"
+#include "memory-util.h"
#include "resolved-dns-dnssec.h"
#include "resolved-dns-packet.h"
#include "string-table.h"
diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
index 278546da84..a4959cd7c0 100644
--- a/src/resolve/resolved-dns-packet.c
+++ b/src/resolve/resolved-dns-packet.c
@@ -6,6 +6,7 @@
#include "alloc-util.h"
#include "dns-domain.h"
+#include "memory-util.h"
#include "resolved-dns-packet.h"
#include "set.h"
#include "string-table.h"
diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c
index a3d61d5b9a..4122362b3c 100644
--- a/src/shared/ask-password-api.c
+++ b/src/shared/ask-password-api.c
@@ -31,6 +31,7 @@
#include "io-util.h"
#include "log.h"
#include "macro.h"
+#include "memory-util.h"
#include "missing.h"
#include "mkdir.h"
#include "process-util.h"
@@ -44,7 +45,6 @@
#include "tmpfile-util.h"
#include "umask-util.h"
#include "utf8.h"
-#include "util.h"
#define KEYRING_TIMEOUT_USEC ((5 * USEC_PER_MINUTE) / 2)
diff --git a/src/shared/bitmap.c b/src/shared/bitmap.c
index a4cd6451b0..a956a42cab 100644
--- a/src/shared/bitmap.c
+++ b/src/shared/bitmap.c
@@ -10,6 +10,7 @@
#include "bitmap.h"
#include "hashmap.h"
#include "macro.h"
+#include "memory-util.h"
struct Bitmap {
uint64_t *bitmaps;
diff --git a/src/shared/bpf-program.c b/src/shared/bpf-program.c
index 2c61e04132..40bc9645be 100644
--- a/src/shared/bpf-program.c
+++ b/src/shared/bpf-program.c
@@ -9,9 +9,9 @@
#include "bpf-program.h"
#include "fd-util.h"
#include "log.h"
+#include "memory-util.h"
#include "missing.h"
#include "path-util.h"
-#include "util.h"
int bpf_program_new(uint32_t prog_type, BPFProgram **ret) {
_cleanup_(bpf_program_unrefp) BPFProgram *p = NULL;
diff --git a/src/shared/format-table.c b/src/shared/format-table.c
index 7d529801a1..589ae9e236 100644
--- a/src/shared/format-table.c
+++ b/src/shared/format-table.c
@@ -8,6 +8,7 @@
#include "fileio.h"
#include "format-table.h"
#include "gunicode.h"
+#include "memory-util.h"
#include "pager.h"
#include "parse-util.h"
#include "pretty-print.h"
@@ -15,7 +16,6 @@
#include "terminal-util.h"
#include "time-util.h"
#include "utf8.h"
-#include "util.h"
#define DEFAULT_WEIGHT 100
diff --git a/src/shared/json.c b/src/shared/json.c
index 2a858d4cc4..55163a733b 100644
--- a/src/shared/json.c
+++ b/src/shared/json.c
@@ -18,6 +18,7 @@
#include "json-internal.h"
#include "json.h"
#include "macro.h"
+#include "memory-util.h"
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
diff --git a/src/shared/utmp-wtmp.c b/src/shared/utmp-wtmp.c
index ef9427fa7b..4b134b6c8a 100644
--- a/src/shared/utmp-wtmp.c
+++ b/src/shared/utmp-wtmp.c
@@ -16,12 +16,12 @@
#include "fd-util.h"
#include "hostname-util.h"
#include "macro.h"
+#include "memory-util.h"
#include "path-util.h"
#include "string-util.h"
#include "terminal-util.h"
#include "time-util.h"
#include "user-util.h"
-#include "util.h"
#include "utmp-wtmp.h"
int utmp_get_runlevel(int *runlevel, int *previous) {
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 38897ecefb..dd62b95669 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -40,9 +40,9 @@
#include "glob-util.h"
#include "hexdecoct.h"
#include "hostname-util.h"
+#include "in-addr-util.h"
#include "initreq.h"
#include "install.h"
-#include "in-addr-util.h"
#include "io-util.h"
#include "journal-util.h"
#include "list.h"
@@ -51,6 +51,7 @@
#include "logs-show.h"
#include "macro.h"
#include "main-func.h"
+#include "memory-util.h"
#include "mkdir.h"
#include "pager.h"
#include "parse-util.h"
@@ -77,7 +78,6 @@
#include "unit-name.h"
#include "user-util.h"
#include "utf8.h"
-#include "util.h"
#include "utmp-wtmp.h"
#include "verbs.h"
#include "virt.h"
diff --git a/src/test/test-alloc-util.c b/src/test/test-alloc-util.c
index 40c32d7114..0f2897a376 100644
--- a/src/test/test-alloc-util.c
+++ b/src/test/test-alloc-util.c
@@ -4,7 +4,7 @@
#include "alloc-util.h"
#include "macro.h"
-#include "util.h"
+#include "memory-util.h"
static void test_alloca(void) {
static const uint8_t zero[997] = { };
diff --git a/src/test/test-fd-util.c b/src/test/test-fd-util.c
index 7a0a2ad7d8..713795814d 100644
--- a/src/test/test-fd-util.c
+++ b/src/test/test-fd-util.c
@@ -7,6 +7,7 @@
#include "fd-util.h"
#include "fileio.h"
#include "macro.h"
+#include "memory-util.h"
#include "path-util.h"
#include "process-util.h"
#include "random-util.h"
@@ -14,7 +15,6 @@
#include "string-util.h"
#include "tests.h"
#include "tmpfile-util.h"
-#include "util.h"
static void test_close_many(void) {
int fds[3];
diff --git a/src/test/test-seccomp.c b/src/test/test-seccomp.c
index fbfeedd536..65f1aae5a7 100644
--- a/src/test/test-seccomp.c
+++ b/src/test/test-seccomp.c
@@ -13,6 +13,7 @@
#include "alloc-util.h"
#include "fd-util.h"
#include "macro.h"
+#include "memory-util.h"
#include "missing.h"
#include "nsflags.h"
#include "process-util.h"
@@ -21,7 +22,6 @@
#include "set.h"
#include "string-util.h"
#include "tests.h"
-#include "util.h"
#include "virt.h"
#if SCMP_SYS(socket) < 0 || defined(__i386__) || defined(__s390x__) || defined(__s390__)
diff --git a/src/test/test-sigbus.c b/src/test/test-sigbus.c
index d2666dd1d8..f753e3836e 100644
--- a/src/test/test-sigbus.c
+++ b/src/test/test-sigbus.c
@@ -1,15 +1,17 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
+#include <fcntl.h>
#include <sys/mman.h>
+#include <unistd.h>
#if HAVE_VALGRIND_VALGRIND_H
# include <valgrind/valgrind.h>
#endif
#include "fd-util.h"
+#include "memory-util.h"
#include "sigbus.h"
#include "tests.h"
-#include "util.h"
int main(int argc, char *argv[]) {
_cleanup_close_ int fd = -1;
diff --git a/src/test/test-siphash24.c b/src/test/test-siphash24.c
index 218200e480..6ae272fa94 100644
--- a/src/test/test-siphash24.c
+++ b/src/test/test-siphash24.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
+#include "memory-util.h"
#include "siphash24.h"
-#include "util.h"
#define ITERATIONS 10000000ULL
diff --git a/src/test/test-sleep.c b/src/test/test-sleep.c
index 2a6d5e765a..618da6e40d 100644
--- a/src/test/test-sleep.c
+++ b/src/test/test-sleep.c
@@ -6,10 +6,10 @@
#include "fd-util.h"
#include "log.h"
+#include "memory-util.h"
#include "sleep-config.h"
#include "strv.h"
#include "tests.h"
-#include "util.h"
static void test_parse_sleep_config(void) {
const char *verb;
diff --git a/src/test/test-unaligned.c b/src/test/test-unaligned.c
index 96d6b22be3..3d6f9a03b4 100644
--- a/src/test/test-unaligned.c
+++ b/src/test/test-unaligned.c
@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
+#include "memory-util.h"
#include "sparse-endian.h"
#include "unaligned.h"
-#include "util.h"
static uint8_t data[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c
index f5578f9fc2..6b01529068 100644
--- a/src/test/test-unit-file.c
+++ b/src/test/test-unit-file.c
@@ -20,6 +20,7 @@
#include "install.h"
#include "load-fragment.h"
#include "macro.h"
+#include "memory-util.h"
#include "rm-rf.h"
#include "specifier.h"
#include "string-util.h"
@@ -28,7 +29,6 @@
#include "tests.h"
#include "tmpfile-util.h"
#include "user-util.h"
-#include "util.h"
static int test_unit_file_get_set(void) {
int r;
diff --git a/src/test/test-util.c b/src/test/test-util.c
index 056708650d..1920cbc84a 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -16,7 +16,7 @@
#include "rm-rf.h"
#include "string-util.h"
#include "tests.h"
-#include "util.h"
+#include "memory-util.h"
static void test_align_power2(void) {
unsigned long i, p2;
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index 324d4a41c7..b3f44bfaab 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -20,6 +20,7 @@
#include "hashmap.h"
#include "list.h"
#include "main-func.h"
+#include "memory-util.h"
#include "missing_capability.h"
#include "path-util.h"
#include "selinux-util.h"
@@ -29,7 +30,6 @@
#include "unit-def.h"
#include "unit-name.h"
#include "user-util.h"
-#include "util.h"
#define NULL_ADJTIME_UTC "0.0 0 0\n0\nUTC\n"
#define NULL_ADJTIME_LOCAL "0.0 0 0\n0\nLOCAL\n"
diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c
index fc165ffc01..d974d4451d 100644
--- a/src/tty-ask-password-agent/tty-ask-password-agent.c
+++ b/src/tty-ask-password-agent/tty-ask-password-agent.c
@@ -31,6 +31,7 @@
#include "io-util.h"
#include "macro.h"
#include "main-func.h"
+#include "memory-util.h"
#include "mkdir.h"
#include "path-util.h"
#include "pretty-print.h"
@@ -40,7 +41,6 @@
#include "string-util.h"
#include "strv.h"
#include "terminal-util.h"
-#include "util.h"
#include "utmp-wtmp.h"
static enum {
diff --git a/src/udev/ata_id/ata_id.c b/src/udev/ata_id/ata_id.c
index 6c2233e430..8ea2e1e327 100644
--- a/src/udev/ata_id/ata_id.c
+++ b/src/udev/ata_id/ata_id.c
@@ -26,8 +26,8 @@
#include "fd-util.h"
#include "libudev-util.h"
#include "log.h"
+#include "memory-util.h"
#include "udev-util.h"
-#include "util.h"
#define COMMAND_TIMEOUT_MSEC (30 * 1000)
diff --git a/src/udev/cdrom_id/cdrom_id.c b/src/udev/cdrom_id/cdrom_id.c
index aed24a3b9a..214fbaa042 100644
--- a/src/udev/cdrom_id/cdrom_id.c
+++ b/src/udev/cdrom_id/cdrom_id.c
@@ -21,9 +21,9 @@
#include <unistd.h>
#include "log.h"
+#include "memory-util.h"
#include "random-util.h"
#include "udev-util.h"
-#include "util.h"
/* device info */
static unsigned cd_cd_rom;
diff --git a/src/udev/net/ethtool-util.c b/src/udev/net/ethtool-util.c
index 55620926dc..c94977e7be 100644
--- a/src/udev/net/ethtool-util.c
+++ b/src/udev/net/ethtool-util.c
@@ -9,11 +9,11 @@
#include "ethtool-util.h"
#include "link-config.h"
#include "log.h"
+#include "memory-util.h"
#include "missing.h"
#include "socket-util.h"
#include "string-table.h"
#include "strxcpyx.h"
-#include "util.h"
static const char* const duplex_table[_DUP_MAX] = {
[DUP_FULL] = "full",
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index f1d36ccac0..438ff473ae 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -14,6 +14,7 @@
#include "fd-util.h"
#include "link-config.h"
#include "log.h"
+#include "memory-util.h"
#include "missing_network.h"
#include "naming-scheme.h"
#include "netlink-util.h"
@@ -26,7 +27,6 @@
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
-#include "util.h"
struct link_config_ctx {
LIST_HEAD(link_config, links);
diff --git a/src/udev/scsi_id/scsi_serial.c b/src/udev/scsi_id/scsi_serial.c
index c67d047475..7ca01858d1 100644
--- a/src/udev/scsi_id/scsi_serial.c
+++ b/src/udev/scsi_id/scsi_serial.c
@@ -21,11 +21,11 @@
#include <time.h>
#include <unistd.h>
+#include "memory-util.h"
#include "random-util.h"
#include "scsi.h"
#include "scsi_id.h"
#include "string-util.h"
-#include "util.h"
/*
* A priority based list of id, naa, and binary/ascii for the identifier