]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic + fundamental: Clean up includes 37595/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 22 May 2025 14:08:26 +0000 (16:08 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 25 May 2025 08:06:07 +0000 (10:06 +0200)
Split out of #37344.

262 files changed:
src/basic/af-list.c
src/basic/af-list.h
src/basic/alloc-util.c
src/basic/alloc-util.h
src/basic/ansi-color.c
src/basic/ansi-color.h
src/basic/architecture.c
src/basic/architecture.h
src/basic/argv-util.c
src/basic/argv-util.h
src/basic/arphrd-util.c
src/basic/arphrd-util.h
src/basic/assert-util.c
src/basic/assert-util.h
src/basic/audit-util.c
src/basic/audit-util.h
src/basic/bitfield.h
src/basic/btrfs.c
src/basic/btrfs.h
src/basic/build-path.c
src/basic/build.c
src/basic/build.h
src/basic/bus-label.c
src/basic/bus-label.h
src/basic/cap-list.c
src/basic/cap-list.h
src/basic/capability-util.c
src/basic/capability-util.h
src/basic/capsule-util.c
src/basic/capsule-util.h
src/basic/cgroup-util.c
src/basic/cgroup-util.h
src/basic/chase.c
src/basic/chase.h
src/basic/chattr-util.c
src/basic/chattr-util.h
src/basic/compress.c
src/basic/compress.h
src/basic/conf-files.c
src/basic/conf-files.h
src/basic/confidential-virt.c
src/basic/confidential-virt.h
src/basic/devnum-util.c
src/basic/devnum-util.h
src/basic/dirent-util.c
src/basic/dirent-util.h
src/basic/dlfcn-util.c
src/basic/dlfcn-util.h
src/basic/dns-def.h
src/basic/efivars.c
src/basic/efivars.h
src/basic/env-file.c
src/basic/env-file.h
src/basic/env-util.c
src/basic/env-util.h
src/basic/errno-list.c
src/basic/errno-list.h
src/basic/errno-util.h
src/basic/escape.c
src/basic/escape.h
src/basic/ether-addr-util.c
src/basic/ether-addr-util.h
src/basic/extract-word.c
src/basic/extract-word.h
src/basic/fd-util.c
src/basic/fd-util.h
src/basic/fileio.c
src/basic/fileio.h
src/basic/filesystems.c
src/basic/filesystems.h
src/basic/format-ifname.c
src/basic/format-util.c
src/basic/format-util.h
src/basic/forward.h
src/basic/fs-util.c
src/basic/fs-util.h
src/basic/gcrypt-util.c
src/basic/gcrypt-util.h
src/basic/glob-util.c
src/basic/glob-util.h
src/basic/glyph-util.h
src/basic/gunicode.c
src/basic/gunicode.h
src/basic/hash-funcs.c
src/basic/hash-funcs.h
src/basic/hashmap.c
src/basic/hashmap.h
src/basic/hexdecoct.c
src/basic/hexdecoct.h
src/basic/hmac.c
src/basic/hmac.h
src/basic/hostname-util.c
src/basic/hostname-util.h
src/basic/in-addr-util.c
src/basic/in-addr-util.h
src/basic/include/net/if.h
src/basic/include/net/if_arp.h
src/basic/include/netinet/in.h
src/basic/include/sys/mount.h
src/basic/initrd-util.c
src/basic/initrd-util.h
src/basic/inotify-util.c
src/basic/inotify-util.h
src/basic/io-util.c
src/basic/io-util.h
src/basic/ioprio-util.c
src/basic/ioprio-util.h
src/basic/iovec-util.h
src/basic/iovec-wrapper.c
src/basic/iovec-wrapper.h
src/basic/iterator.h
src/basic/keyring-util.c
src/basic/keyring-util.h
src/basic/label.c
src/basic/label.h
src/basic/limits-util.c
src/basic/limits-util.h
src/basic/list.h
src/basic/locale-util.c
src/basic/locale-util.h
src/basic/lock-util.c
src/basic/lock-util.h
src/basic/log-context.h
src/basic/log.c
src/basic/log.h
src/basic/login-util.c
src/basic/login-util.h
src/basic/macro.h
src/basic/math-util.h
src/basic/memfd-util.c
src/basic/memfd-util.h
src/basic/memory-util.h
src/basic/mempool.c
src/basic/mempool.h
src/basic/memstream-util.h
src/basic/missing_audit.h
src/basic/missing_bpf.h
src/basic/missing_fcntl.h
src/basic/missing_fs.h
src/basic/missing_keyctl.h
src/basic/missing_magic.h
src/basic/missing_mman.h
src/basic/missing_namespace.h
src/basic/missing_network.h
src/basic/missing_pidfd.h
src/basic/missing_random.h
src/basic/missing_sched.h
src/basic/missing_socket.h
src/basic/missing_syscall.h
src/basic/missing_syscall_def.h
src/basic/missing_wait.h
src/basic/missing_xfs.h
src/basic/mkdir.c
src/basic/mkdir.h
src/basic/mountpoint-util.c
src/basic/mountpoint-util.h
src/basic/namespace-util.c
src/basic/namespace-util.h
src/basic/nulstr-util.c
src/basic/nulstr-util.h
src/basic/ordered-set.c
src/basic/ordered-set.h
src/basic/os-util.c
src/basic/os-util.h
src/basic/parse-util.c
src/basic/parse-util.h
src/basic/path-util.c
src/basic/path-util.h
src/basic/pcapng.h
src/basic/percent-util.c
src/basic/percent-util.h
src/basic/pidfd-util.c
src/basic/pidfd-util.h
src/basic/pidref.c
src/basic/pidref.h
src/basic/prioq.c
src/basic/prioq.h
src/basic/proc-cmdline.c
src/basic/proc-cmdline.h
src/basic/process-util.c
src/basic/process-util.h
src/basic/procfs-util.c
src/basic/procfs-util.h
src/basic/psi-util.c
src/basic/psi-util.h
src/basic/pthread-util.h
src/basic/random-util.c
src/basic/random-util.h
src/basic/ratelimit.c
src/basic/ratelimit.h
src/basic/recurse-dir.c
src/basic/recurse-dir.h
src/basic/replace-var.c
src/basic/replace-var.h
src/basic/rlimit-util.c
src/basic/rlimit-util.h
src/basic/runtime-scope.h
src/basic/set.h
src/basic/sha256.c
src/basic/sha256.h
src/basic/sigbus.c
src/basic/sigbus.h
src/basic/signal-util.c
src/basic/signal-util.h
src/basic/siphash24.c
src/basic/siphash24.h
src/basic/socket-util.c
src/basic/socket-util.h
src/basic/sort-util.c
src/basic/sort-util.h
src/basic/sparse-endian.h
src/basic/stat-util.c
src/basic/stat-util.h
src/basic/static-destruct.c
src/basic/static-destruct.h
src/basic/stdio-util.h
src/basic/strbuf.c
src/basic/strbuf.h
src/basic/string-table.c
src/basic/string-table.h
src/basic/string-util.c
src/basic/string-util.h
src/basic/strv.c
src/basic/strv.h
src/basic/strxcpyx.c
src/basic/strxcpyx.h
src/basic/sync-util.c
src/basic/sync-util.h
src/basic/sysctl-util.c
src/basic/sysctl-util.h
src/basic/syslog-util.c
src/basic/syslog-util.h
src/basic/terminal-util.c
src/basic/terminal-util.h
src/basic/time-util.c
src/basic/time-util.h
src/basic/tmpfile-util.c
src/basic/tmpfile-util.h
src/basic/uid-classification.h
src/basic/uid-range.c
src/basic/uid-range.h
src/basic/umask-util.h
src/basic/unaligned.h
src/basic/unit-def.c
src/basic/unit-def.h
src/basic/unit-name.c
src/basic/unit-name.h
src/basic/user-util.c
src/basic/user-util.h
src/basic/utf8.c
src/basic/utf8.h
src/basic/virt.c
src/basic/virt.h
src/basic/xattr-util.c
src/basic/xattr-util.h
src/fundamental/chid-fundamental.h
src/fundamental/edid-fundamental.c
src/fundamental/edid-fundamental.h
src/fundamental/sha256-fundamental.c
src/fundamental/string-util-fundamental.c
src/fundamental/tpm2-pcr.h
src/fundamental/uki.h

index 421a16d73f3863b0752830992c65fe1384c9aa87..5ab92a96b58420da2e26f329848cc4413d081542 100644 (file)
@@ -1,11 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <string.h>
 #include <sys/socket.h>
 
 #include "af-list.h"
-#include "macro.h"
 #include "string-util.h"
 
 static const struct af_name* lookup_af(register const char *str, register GPERF_LEN_TYPE len);
index 07f505645837dc3a640b33f6c859363e9005666f..425c713408cfadbb100a85f70052c4df8247ca7b 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "macro.h"
+#include "forward.h"
 
 const char* af_to_name(int id) _const_;
 int af_from_name(const char *name) _pure_;
index 1a6b178eb7b7cf11209526ac558efab69462070b..58b70dede4b01b4bec30233dd75e4c73c3421ff9 100644 (file)
@@ -1,11 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include <malloc.h>
-#include <stdint.h>
-#include <string.h>
 
 #include "alloc-util.h"
-#include "macro.h"
 
 void* memdup(const void *p, size_t l) {
         void *ret;
@@ -131,3 +128,17 @@ void* greedy_realloc_append(
 void *expand_to_usable(void *ptr, size_t newsize _unused_) {
         return ptr;
 }
+
+size_t malloc_sizeof_safe(void **xp) {
+        if (_unlikely_(!xp || !*xp))
+                return 0;
+
+        size_t sz = malloc_usable_size(*xp);
+        *xp = expand_to_usable(*xp, sz);
+        /* GCC doesn't see the _returns_nonnull_ when built with ubsan, so yet another hint to make it doubly
+         * clear that expand_to_usable won't return NULL.
+         * See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79265 */
+        if (!*xp)
+                assert_not_reached();
+        return sz;
+}
index ec5b1059a848f61000b8c733a13fcfe4cb3b4131..263815c528eb79802ee832f5a1c37e2c40de9c55 100644 (file)
@@ -1,14 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <alloca.h>
-#include <malloc.h>
-#include <stddef.h>
-#include <string.h>
-
-#include "assert-util.h"
-#include "cleanup-util.h"
-#include "macro.h"
+#include <stdlib.h>
+
+#include "forward.h"
 #include "memory-util.h"
 
 #if HAS_FEATURE_MEMORY_SANITIZER
@@ -191,19 +186,7 @@ void* greedy_realloc_append(void **p, size_t *n_p, const void *from, size_t n_fr
  * See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96503 */
 void *expand_to_usable(void *p, size_t newsize) _alloc_(2) _returns_nonnull_ _noinline_;
 
-static inline size_t malloc_sizeof_safe(void **xp) {
-        if (_unlikely_(!xp || !*xp))
-                return 0;
-
-        size_t sz = malloc_usable_size(*xp);
-        *xp = expand_to_usable(*xp, sz);
-        /* GCC doesn't see the _returns_nonnull_ when built with ubsan, so yet another hint to make it doubly
-         * clear that expand_to_usable won't return NULL.
-         * See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79265 */
-        if (!*xp)
-                assert_not_reached();
-        return sz;
-}
+size_t malloc_sizeof_safe(void **xp);
 
 /* This returns the number of usable bytes in a malloc()ed region as per malloc_usable_size(), which may
  * return a value larger than the size that was actually allocated. Access to that additional memory is
index 18e25f3bb0d6e75fbeee108f7890ad1a40be3719..9dce2f44188f46a93896ae0a801174c5fcff6962 100644 (file)
@@ -1,9 +1,12 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include <stdlib.h>
+
 #include "ansi-color.h"
 #include "log.h"
 #include "process-util.h"
 #include "string-table.h"
+#include "string-util.h"
 #include "strv.h"
 #include "terminal-util.h"
 
index f3e55e8165b2b08d59428feabbedfd7c5abf540e..de86d36150f6557dbc3bb79331efcfa522c8e3d2 100644 (file)
@@ -1,9 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <errno.h>
-
-#include "macro.h"
+#include "forward.h"
 
 /* Limits the use of ANSI colors to a subset. */
 typedef enum ColorMode {
index c7d5b0d8bd329fdaa0565ffe633829abd3bfe71f..a711e8bef48977235790c2b09fb1d8ee6c2173fd 100644 (file)
@@ -3,7 +3,6 @@
 #include <sys/utsname.h>
 
 #include "architecture.h"
-#include "macro.h"
 #include "string-table.h"
 #include "string-util.h"
 
index 4d06e5c3a48289fc631dcb22bee9ca1b7add67fb..3793415e5d8a91a380f52cfd85d6f9bd7bd81fb4 100644 (file)
@@ -1,10 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <endian.h>
-#include <errno.h>
+#include <endian.h>     /* IWYU pragma: keep */
 
-#include "macro.h"
+#include "forward.h"
 
 /* A cleaned up architecture definition. We don't want to get lost in
  * processor features, models, generations or even ABIs. Hence we
index 71be53a1bf7ee9309fdc9834b7c09590e158cd34..ab0fe3280d4c4d401970d18fe4436067961f5a5a 100644 (file)
@@ -1,9 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <sched.h>
+#include <stdlib.h>
 #include <sys/mman.h>
 #include <sys/prctl.h>
-#include <unistd.h>
 
 #include "argv-util.h"
 #include "capability-util.h"
 int saved_argc = 0;
 char **saved_argv = NULL;
 
+void save_argc_argv(int argc, char **argv) {
+        /* Protect against CVE-2021-4034 style attacks */
+        assert_se(argc > 0);
+        assert_se(argv);
+        assert_se(argv[0]);
+
+        saved_argc = argc;
+        saved_argv = argv;
+}
+
 bool invoked_as(char *argv[], const char *token) {
         if (!argv || isempty(argv[0]))
                 return false;
index deaa7c04e63c5cbf1fe80e3abc36b4ebf794e5f3..d79bd6f22240f567d0cfd5aab0397a5931f78bbb 100644 (file)
@@ -1,23 +1,12 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-
-#include "assert-util.h"
-#include "macro.h"
+#include "forward.h"
 
 extern int saved_argc;
 extern char **saved_argv;
 
-static inline void save_argc_argv(int argc, char **argv) {
-        /* Protect against CVE-2021-4034 style attacks */
-        assert_se(argc > 0);
-        assert_se(argv);
-        assert_se(argv[0]);
-
-        saved_argc = argc;
-        saved_argv = argv;
-}
+void save_argc_argv(int argc, char **argv);
 
 bool invoked_as(char *argv[], const char *token);
 bool invoked_by_systemd(void);
index 063aede5e721f4ebc960bf1861c403e85443b1b2..0c5a85edaa577ca45176c816d6de0f6e76f694eb 100644 (file)
@@ -1,14 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <linux/if_arp.h>
 #include <linux/if_infiniband.h>
 #include <netinet/in.h>
 #include <string.h>
 
 #include "arphrd-util.h"
-#include "assert-util.h"
-#include "macro.h"
 
 static const struct arphrd_name* lookup_arphrd(register const char *str, register GPERF_LEN_TYPE len);
 
index 0fd75a0436329fc3b4b34187930a2ea40dd2bfa6..95c6a887c49b593b433945131f4ec1b9cbce1dc3 100644 (file)
@@ -1,8 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <inttypes.h>
-#include <stddef.h>
+#include "forward.h"
 
 const char* arphrd_to_name(int id);
 int arphrd_from_name(const char *name);
index add9e92c5228fc3ea07f0a6539698e0eae8f05a8..a1aa5c82e23e1878f9a50213d8f81a6800070a26 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <limits.h>
 #include <stdio.h>
+#include <stdlib.h>
 
 #include "assert-util.h"
 #include "errno-util.h"
index 7462e1b22257024c59efe945f0524be285285734..f6bb7702ea69a13ba4c5ccefc9d3ac62316c7db1 100644 (file)
@@ -1,8 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "assert-fundamental.h"
-#include "macro.h"
+#include "assert-fundamental.h" /* IWYU pragma: export */
 
 /* Logging for various assertions */
 
index 9a9f2849ed34cebd7b4d10d976c27f90f97b8858..a94378f6121858c3e4298861ef3a466e7908762d 100644 (file)
@@ -4,6 +4,7 @@
 #include "audit-util.h"
 #include "fileio.h"
 #include "parse-util.h"
+#include "pidref.h"
 #include "process-util.h"
 #include "stat-util.h"
 #include "user-util.h"
index 98b1b3631a63d9375f5cd59606d7be1fd6a24b37..ff9ce72e0b761208f866c748cca5ab5fb71f07ba 100644 (file)
@@ -1,10 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-#include <stdint.h>
-
-#include "pidref.h"
+#include "forward.h"
 
 #define AUDIT_SESSION_INVALID UINT32_MAX
 
index c6eaaa484fea3418f9a32136a2fe0dc95da8de08..a06841a64904f7cda36803754e1ffc89b87a5849 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "macro.h"
+#include "forward.h"
 
 /* Bit index (0-based) to mask of specified type. Assertion failure if index is out of range. */
 #define _INDEX_TO_MASK(type, i, uniq)                                   \
index 7d5c35605de45bb885fd23e7930c0c6f0dc2e10e..7981c670e338ff61d0b152f6ac6eb47d56bbf9e7 100644 (file)
@@ -2,12 +2,12 @@
 
 #include <linux/btrfs.h>
 #include <sys/ioctl.h>
+#include <sys/stat.h>
 
 #include "alloc-util.h"
 #include "btrfs.h"
 #include "errno-util.h"
 #include "fd-util.h"
-#include "fs-util.h"
 #include "path-util.h"
 #include "string-util.h"
 
index 38be9d2b3b19bf3d4d329f4ac63435ec3efb9221..0b3ae1082c79bcac46dd783a830217ccbbfea6e9 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <fcntl.h>
+#include "forward.h"
 
 int btrfs_validate_subvolume_name(const char *name);
 
index 0341074cedc2b5ed57c0cc6773a2c2b91fe91727..577ff72bce2585f72aade7995062cf2632181965 100644 (file)
@@ -1,17 +1,16 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include <elf.h>
+#include <fcntl.h>
 #include <link.h>
 #include <stdlib.h>
 #include <sys/auxv.h>
 
+#include "alloc-util.h"
 #include "build-path.h"
-#include "errno-list.h"
-#include "errno-util.h"
-#include "fd-util.h"
-#include "macro.h"
 #include "path-util.h"
 #include "process-util.h"
+#include "string-util.h"
 #include "unistd.h"
 
 static int get_runpath_from_dynamic(const ElfW(Dyn) *d, ElfW(Addr) bias, const char **ret) {
index 946de943f0911e41ddadc36dae474b9da24e91e0..ad9d3b1c4bdca29910f4527da7f2e17cd5a06681 100644 (file)
@@ -7,9 +7,7 @@
 #include "build.h"
 #include "extract-word.h"
 #include "log.h"
-#include "macro.h"
 #include "string-util.h"
-#include "terminal-util.h"
 #include "version.h"
 
 const char* const systemd_features =
index 5b7c83cad9ef5852e7138d3a9962d0989c15dc11..3f1211e708ccb1e5aa280132b4b569e547a27e2f 100644 (file)
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include "forward.h"
+
 extern const char* const systemd_features;
 
 int version(void);
index 6371a9dba0c8c50d7e409608a77223e0cfedd178..b6bf9ca4682896aee4e9191ac94001822a003b39 100644 (file)
@@ -5,7 +5,7 @@
 #include "alloc-util.h"
 #include "bus-label.h"
 #include "hexdecoct.h"
-#include "macro.h"
+#include "string-util.h"
 
 char* bus_label_escape(const char *s) {
         char *r, *t;
@@ -48,6 +48,9 @@ char* bus_label_unescape_n(const char *f, size_t l) {
 
         assert_return(f, NULL);
 
+        if (l == SIZE_MAX)
+                l = strlen(f);
+
         /* Special case for the empty string */
         if (l == 1 && *f == '_')
                 return strdup("");
index 7630eff2955ddbd9b8115506c4d68f932524995b..22dd796984725ed05b95d99cc7bf210fb12a84bb 100644 (file)
@@ -1,14 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stddef.h>
-#include <stdlib.h>
-
-#include "string-util.h"
+#include "forward.h"
 
 char* bus_label_escape(const char *s);
 char* bus_label_unescape_n(const char *f, size_t l);
 
 static inline char* bus_label_unescape(const char *f) {
-        return bus_label_unescape_n(f, strlen_ptr(f));
+        return bus_label_unescape_n(f, SIZE_MAX);
 }
index 9ae679330acbfedbf6da511194873933c5867826..5e368937a2e1076af3ad16753c2058a9bc180704 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-#include <string.h>
+#include <stdio.h>
 
 #include "alloc-util.h"
 #include "bitfield.h"
@@ -9,9 +8,7 @@
 #include "capability-util.h"
 #include "extract-word.h"
 #include "log.h"
-#include "macro.h"
 #include "parse-util.h"
-#include "stdio-util.h"
 #include "string-util.h"
 #include "strv.h"
 
index 95b03c48ddcf74ac4c5f6ebd58c508eb1c43a28f..ea80ca3d5c760750e5b54286cebb84fc0ed28a19 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <inttypes.h>
+#include "forward.h"
 
 /* Space for capability_to_string() in case we write out a numeric capability because we don't know the name
  * for it. "0x3e" is the largest string we might output, in both sensese of the word "largest": two chars for
index 2f0e0ccf92e6710f7552dd22b3289fdb6894fd8c..4e6171e3c1ee912cc329df9a2d2985e723594e65 100644 (file)
@@ -1,12 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <linux/prctl.h>
 #include <stdatomic.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <sys/prctl.h>
-#include <threads.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
@@ -17,7 +14,6 @@
 #include "fileio.h"
 #include "log.h"
 #include "logarithm.h"
-#include "macro.h"
 #include "parse-util.h"
 #include "pidref.h"
 #include "process-util.h"
index a076becdcd82d42da358422ab5fba71951b46613..3c265e4064019168309491ac4d3262f6bd907e84 100644 (file)
@@ -1,13 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-#include <stdint.h>
-#include <sys/capability.h>
-#include <sys/types.h>
+#include <sys/capability.h>     /* IWYU pragma: export */
 
-#include "macro.h"
-#include "pidref.h"
+#include "forward.h"
 
 /* Special marker used when storing a capabilities mask as "unset". This would need to be updated as soon as
  * Linux learns more than 63 caps. */
index 83fcf7afbcc30c710442632da894cbf00376adc2..6cff1aa27fdc36705670a3e79d66a14711884abe 100644 (file)
@@ -1,10 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-
 #include "alloc-util.h"
 #include "capsule-util.h"
 #include "path-util.h"
+#include "string-util.h"
 #include "user-util.h"
 
 int capsule_name_is_valid(const char *name) {
index 437153be9e7cefeba4ceb22a677b14b7ef26eab5..02b00220f1ec8ca676e3280389b54f0e1bd2e0e7 100644 (file)
@@ -1,4 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include "forward.h"
+
 int capsule_name_is_valid(const char *name);
index f0b91254dc7814ebc6d78190afa01ffd695fbbe8..1c7524289245f9b89f609b06795212e7a919a79c 100644 (file)
@@ -1,12 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-#include <limits.h>
 #include <signal.h>
-#include <stddef.h>
 #include <stdlib.h>
-#include <sys/types.h>
-#include <sys/utsname.h>
 #include <sys/xattr.h>
 #include <threads.h>
 #include <unistd.h>
@@ -14,7 +9,6 @@
 #include "alloc-util.h"
 #include "capsule-util.h"
 #include "cgroup-util.h"
-#include "constants.h"
 #include "dirent-util.h"
 #include "errno-util.h"
 #include "extract-word.h"
 #include "fs-util.h"
 #include "log.h"
 #include "login-util.h"
-#include "macro.h"
 #include "missing_fs.h"
 #include "missing_magic.h"
-#include "mkdir.h"
 #include "parse-util.h"
 #include "path-util.h"
+#include "pidref.h"
 #include "process-util.h"
 #include "set.h"
 #include "special.h"
 #include "stat-util.h"
-#include "stdio-util.h"
 #include "string-table.h"
 #include "string-util.h"
 #include "strv.h"
 #include "user-util.h"
 #include "xattr-util.h"
 
+/* The structure to pass to name_to_handle_at() on cgroupfs2 */
+typedef union {
+        struct file_handle file_handle;
+        uint8_t space[offsetof(struct file_handle, f_handle) + sizeof(uint64_t)];
+} cg_file_handle;
+
+#define CG_FILE_HANDLE_INIT                                     \
+        (cg_file_handle) {                                      \
+                .file_handle.handle_bytes = sizeof(uint64_t),   \
+                .file_handle.handle_type = FILEID_KERNFS,       \
+        }
+
+#define CG_FILE_HANDLE_CGROUPID(fh) (*CAST_ALIGN_PTR(uint64_t, (fh).file_handle.f_handle))
+
 int cg_path_open(const char *controller, const char *path) {
         _cleanup_free_ char *fs = NULL;
         int r;
index 05211b065cd624cb3fb994b99130a2e59325ba18..acb3427875eca28fdcb1dc5dd71a812d8c53a9f2 100644 (file)
@@ -1,18 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <sys/statfs.h>
-#include <sys/types.h>
-
-#include "constants.h"
-#include "pidref.h"
-#include "set.h"
+#include "forward.h"
 
 #define SYSTEMD_CGROUP_CONTROLLER_LEGACY "name=systemd"
 #define SYSTEMD_CGROUP_CONTROLLER_HYBRID "name=unified"
@@ -319,17 +308,3 @@ typedef enum ManagedOOMPreference {
 
 const char* managed_oom_preference_to_string(ManagedOOMPreference a) _const_;
 ManagedOOMPreference managed_oom_preference_from_string(const char *s) _pure_;
-
-/* The structure to pass to name_to_handle_at() on cgroupfs2 */
-typedef union {
-        struct file_handle file_handle;
-        uint8_t space[offsetof(struct file_handle, f_handle) + sizeof(uint64_t)];
-} cg_file_handle;
-
-#define CG_FILE_HANDLE_INIT                                     \
-        (cg_file_handle) {                                      \
-                .file_handle.handle_bytes = sizeof(uint64_t),   \
-                .file_handle.handle_type = FILEID_KERNFS,       \
-        }
-
-#define CG_FILE_HANDLE_CGROUPID(fh) (*CAST_ALIGN_PTR(uint64_t, (fh).file_handle.f_handle))
index 88cd840544b046e6d2fe81bc0e6ee7336acf0f73..34423cc3004d17b1b256665656e9bdeebfb5cc6d 100644 (file)
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include <linux/magic.h>
+#include <unistd.h>
 
 #include "alloc-util.h"
 #include "chase.h"
@@ -11,6 +12,7 @@
 #include "glyph-util.h"
 #include "log.h"
 #include "path-util.h"
+#include "stat-util.h"
 #include "string-util.h"
 #include "strv.h"
 #include "user-util.h"
index 2146f54e7aa78ab04d3b9b869a2fe8edc563ad2c..36632c8a325a9de46b11c7ccfe79a66c792f23a1 100644 (file)
@@ -1,10 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <dirent.h>
-#include <stdio.h>
-
-#include "stat-util.h"
+#include "forward.h"
 
 typedef enum ChaseFlags {
         CHASE_PREFIX_ROOT        = 1 << 0,  /* The specified path will be prefixed by the specified root before beginning the iteration */
index 794ac6572fc442591eafcf0e4bbcd26f7ee87515..5786c12a3f8db1a94c67a488aa19bc0a25876aaf 100644 (file)
@@ -1,6 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
@@ -11,7 +10,6 @@
 #include "fd-util.h"
 #include "fs-util.h"
 #include "log.h"
-#include "macro.h"
 #include "string-util.h"
 
 int chattr_full(
index 472054d57e615d7afdd5af2c0ff4472c8965bda1..8d938ef94b14aef8c44be46b76090299f5c35761 100644 (file)
@@ -1,10 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <fcntl.h>
-#include <stdbool.h>
-#include <stddef.h>
-
+#include "forward.h"
 #include "missing_fs.h"
 
 /* The chattr() flags to apply when creating a new file *before* writing to it. In particular, flags such as
index c8096635ef835487f739f11510a79f2ddf23f926..3270a7ed104ea8ffaa9765ce68e8f0cd5906b697 100644 (file)
@@ -1,11 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <inttypes.h>
-#include <malloc.h>
-#include <stdlib.h>
+#include <stdio.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
-#include <sys/types.h>
 #include <unistd.h>
 
 #if HAVE_LZ4
 #include "alloc-util.h"
 #include "bitfield.h"
 #include "compress.h"
-#include "fd-util.h"
+#include "dlfcn-util.h"
 #include "fileio.h"
 #include "io-util.h"
 #include "log.h"
-#include "macro.h"
-#include "sparse-endian.h"
 #include "string-table.h"
 #include "string-util.h"
 #include "unaligned.h"
index dbd6bb385768c2309b91f54745cd3bc28e1ab84d..ce662920eb7c741e6e75a9e81a02ac18b9397d1f 100644 (file)
@@ -1,12 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <errno.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <unistd.h>
-
-#include "dlfcn-util.h"
+#include "forward.h"
 
 typedef enum Compression {
         COMPRESSION_NONE,
index 552b03a0d001301316cc407999287c9aa61ae623..2461235fe8a6b91b8bc0b64ad260278b71ccd7f0 100644 (file)
@@ -1,14 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-#include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 
 #include "alloc-util.h"
 #include "chase.h"
 #include "conf-files.h"
-#include "constants.h"
 #include "dirent-util.h"
 #include "errno-util.h"
 #include "fd-util.h"
 #include "glyph-util.h"
 #include "hashmap.h"
 #include "log.h"
-#include "macro.h"
 #include "nulstr-util.h"
 #include "path-util.h"
 #include "set.h"
 #include "stat-util.h"
 #include "string-util.h"
 #include "strv.h"
-#include "terminal-util.h"
 
 static int files_add(
                 DIR *dir,
index cf89ee62c68ac3badc2126bf225198af7ea8ca4c..fb479cabf9e32ee12020739be2a02d48c1bc6835 100644 (file)
@@ -1,9 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-
-#include "macro.h"
+#include "forward.h"
 
 enum {
         CONF_FILES_EXECUTABLE    = 1 << 0,
index 920a9dd36af107565ab896d4896671d9a6a94245..3e07e3c3a24b7980d3c475fc335d2adc40fa9416 100644 (file)
@@ -3,13 +3,10 @@
 #if defined(__i386__) || defined(__x86_64__)
 #include <cpuid.h>
 #endif
-#include <errno.h>
 #include <fcntl.h>
-#include <stdlib.h>
 #include <threads.h>
 #include <unistd.h>
 
-#include "alloc-util.h"
 #include "confidential-virt.h"
 #include "confidential-virt-fundamental.h"
 #include "errno-util.h"
index bbab12310238c292ad4b476678a395ef2832787d..708b3ab60455da342cab37c77bad8ababdd155ed 100644 (file)
@@ -1,11 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <errno.h>
-#include <stdbool.h>
-
-#include "errno-list.h"
-#include "macro.h"
+#include "forward.h"
 
 typedef enum ConfidentialVirtualization {
         CONFIDENTIAL_VIRTUALIZATION_NONE = 0,
index 7be34ca0ef72638ef1eb8afa7e84ee6ad631d290..99c20662df684f50da87c73b76e09104a877893a 100644 (file)
@@ -9,6 +9,7 @@
 #include "devnum-util.h"
 #include "parse-util.h"
 #include "path-util.h"
+#include "stdio-util.h"
 #include "string-util.h"
 
 int parse_devnum(const char *s, dev_t *ret) {
@@ -135,3 +136,7 @@ int device_path_parse_major_minor(const char *path, mode_t *ret_mode, dev_t *ret
 
         return 0;
 }
+
+char* format_devnum(dev_t d, char buf[static DEVNUM_STR_MAX]) {
+        return ASSERT_PTR(snprintf_ok(buf, DEVNUM_STR_MAX, DEVNUM_FORMAT_STR, DEVNUM_FORMAT_VAL(d)));
+}
index 0e07df5e8cb2ff659500d7ad947518444c58f316..4b4a81f3ca7f276a121db1a1f5d1be223982d2f8 100644 (file)
@@ -1,12 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <inttypes.h>
-#include <stdbool.h>
-#include <sys/types.h>
 #include <sys/sysmacros.h>
 
-#include "stdio-util.h"
+#include "forward.h"
 
 int parse_devnum(const char *s, dev_t *ret);
 
@@ -49,9 +46,7 @@ static inline bool devnum_set_and_equal(dev_t a, dev_t b) {
 #define DEVNUM_FORMAT_STR "%u:%u"
 #define DEVNUM_FORMAT_VAL(d) major(d), minor(d)
 
-static inline char *format_devnum(dev_t d, char buf[static DEVNUM_STR_MAX]) {
-        return ASSERT_PTR(snprintf_ok(buf, DEVNUM_STR_MAX, DEVNUM_FORMAT_STR, DEVNUM_FORMAT_VAL(d)));
-}
+char *format_devnum(dev_t d, char buf[static DEVNUM_STR_MAX]);
 
 #define FORMAT_DEVNUM(d) format_devnum((d), (char[DEVNUM_STR_MAX]) {})
 
index e25097d8aee568291a3e03a82a53984f112f7b1f..5dad9c203226fc585f2daddad436c849ccf6ad8c 100644 (file)
@@ -5,7 +5,6 @@
 
 #include "dirent-util.h"
 #include "path-util.h"
-#include "stat-util.h"
 #include "string-util.h"
 
 int dirent_ensure_type(int dir_fd, struct dirent *de) {
index 4c8d96788b16243c768112abf8191e425626dca8..14fde59c992e463098a94b82ea20c9522c22563c 100644 (file)
@@ -1,12 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <dirent.h>
-#include <errno.h>
-#include <stdbool.h>
+#include <dirent.h>     /* IWYU pragma: export */
 
-#include "assert-util.h"
-#include "macro.h"
+#include "forward.h"
 #include "path-util.h"
 
 bool dirent_is_file(const struct dirent *de) _pure_;
index b629b18d11b4b389297d7de7cc2b4126b523c2ea..6a7fe15a851c35aa87d11e8d62db0a21fa1032f8 100644 (file)
@@ -3,6 +3,14 @@
 #include "dlfcn-util.h"
 #include "log.h"
 
+void* safe_dlclose(void *dl) {
+        if (!dl)
+                return NULL;
+
+        assert_se(dlclose(dl) == 0);
+        return NULL;
+}
+
 static int dlsym_many_or_warnv(void *dl, int log_level, va_list ap) {
         void (**fn)(void);
 
index e92e00b1e8732ce87a846b43ce24fc90357f2c4f..4b054e8cb3ead3b5e5eabe293c509d2ad08bc680 100644 (file)
@@ -1,18 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <dlfcn.h>
+#include <dlfcn.h>      /* IWYU pragma: export */
 
-#include "assert-util.h"
-#include "macro.h"
+#include "forward.h"
 
-static inline void* safe_dlclose(void *dl) {
-        if (!dl)
-                return NULL;
-
-        assert_se(dlclose(dl) == 0);
-        return NULL;
-}
+void* safe_dlclose(void *dl);
 
 static inline void dlclosep(void **dlp) {
         safe_dlclose(*dlp);
index d70220bcc0eb4cf3cc53dcb520ad3c966350bfd1..5c0f031df71ab031103130c55a6f0f11c1831ba0 100644 (file)
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include "forward.h"
+
 /* Length of a single label, with all escaping removed, excluding any trailing dot or NUL byte */
 #define DNS_LABEL_MAX 63
 
index 6fa0da576f8a609e9c04236b152a6a150b79b1a0..0163ad0c166f33741d33c78f552da930e0ac6466 100644 (file)
@@ -1,26 +1,19 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <fcntl.h>
-#include <limits.h>
 #include <stdlib.h>
 #include <sys/stat.h>
+#include <time.h>
 #include <unistd.h>
 
-#include "sd-id128.h"
-
 #include "alloc-util.h"
 #include "chattr-util.h"
 #include "efivars.h"
 #include "fd-util.h"
-#include "fileio.h"
 #include "io-util.h"
 #include "log.h"
-#include "macro.h"
 #include "memory-util.h"
-#include "missing_fs.h"
-#include "stdio-util.h"
-#include "strv.h"
+#include "string-util.h"
 #include "time-util.h"
 #include "utf8.h"
 #include "virt.h"
@@ -389,3 +382,7 @@ SecureBootMode efi_get_secure_boot_mode(void) {
         return (cache = decode_secure_boot_mode(secure, audit > 0, deployed > 0, setup > 0));
 }
 #endif
+
+char *efi_tilt_backslashes(char *s) {
+        return string_replace_char(s, '\\', '/');
+}
index 0bd75f9b4166b98eb6d51d7c010c8e2114c8afca..dd049283f591a8ee5cf8f4f307cf324a904e2f6d 100644 (file)
@@ -1,18 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#if !ENABLE_EFI
-#  include <errno.h>
-#endif
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
+#include "forward.h"
 
 #include "sd-id128.h"
 
-#include "efivars-fundamental.h"
-#include "string-util.h"
-#include "time-util.h"
+#include "efivars-fundamental.h"        /* IWYU pragma: export */
 
 #define EFI_VENDOR_LOADER       SD_ID128_MAKE(4a,67,b0,82,0a,4c,41,cf,b6,c7,44,0b,29,bb,8c,4f)
 #define EFI_VENDOR_LOADER_STR   SD_ID128_MAKE_UUID_STR(4a,67,b0,82,0a,4c,41,cf,b6,c7,44,0b,29,bb,8c,4f)
@@ -88,6 +81,4 @@ static inline SecureBootMode efi_get_secure_boot_mode(void) {
 }
 #endif
 
-static inline char *efi_tilt_backslashes(char *s) {
-        return string_replace_char(s, '\\', '/');
-}
+char *efi_tilt_backslashes(char *s);
index 9ef30a62468d1be7e4d8d9cb600dab29ebfa3458..bc23e94d18f561939ae0ef782641db4bf16ba82c 100644 (file)
@@ -1,5 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include <unistd.h>
+
 #include "alloc-util.h"
 #include "env-file.h"
 #include "env-util.h"
index df3f29500f68ee60dd6daa77134998c4d336dce9..b44651fe1e93edcd50722c5270648f2f930f3ee9 100644 (file)
@@ -1,11 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <fcntl.h>
-#include <stdarg.h>
-#include <stdio.h>
-
-#include "macro.h"
+#include "forward.h"
 
 int parse_env_filev(FILE *f, const char *fname, va_list ap);
 int parse_env_file_fdv(int fd, const char *fname, va_list ap);
index b97eac070ba4a9fbbfb159291eb61c709277b228..112c93c181317536ee8c91df41eb56c45b93a651 100644 (file)
@@ -1,22 +1,17 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-#include <limits.h>
-#include <stdarg.h>
 #include <stdlib.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
 #include "env-util.h"
 #include "errno-util.h"
-#include "escape.h"
 #include "extract-word.h"
+#include "format-util.h"
 #include "log.h"
-#include "macro.h"
 #include "parse-util.h"
 #include "path-util.h"
 #include "process-util.h"
-#include "stdio-util.h"
 #include "string-util.h"
 #include "strv.h"
 #include "syslog-util.h"
         DIGITS LETTERS                          \
         "_"
 
+size_t sc_arg_max(void) {
+        long l = sysconf(_SC_ARG_MAX);
+        assert(l > 0);
+        return (size_t) l;
+}
+
 static bool env_name_is_valid_n(const char *e, size_t n) {
 
         if (n == SIZE_MAX)
index 14f2e718232e805f50794c4b45bf8b17f7522a69..07426d97146e7278f86416d431419794726711dd 100644 (file)
@@ -1,20 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include "assert-util.h"
-#include "macro.h"
-#include "string.h"
-
-static inline size_t sc_arg_max(void) {
-        long l = sysconf(_SC_ARG_MAX);
-        assert(l > 0);
-        return (size_t) l;
-}
+#include "forward.h"
+
+size_t sc_arg_max(void);
 
 bool env_name_is_valid(const char *e);
 bool env_value_is_valid(const char *e);
index 396879c8f2c6db32fb3838d3c4d9222d10c79525..b39e15a7680a15ae828ae84d6845932b049d837d 100644 (file)
@@ -1,18 +1,22 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <string.h>
 
-#include "assert-util.h"
 #include "errno-list.h"
-#include "macro.h"
 
 static const struct errno_name* lookup_errno(register const char *str,
                                              register GPERF_LEN_TYPE len);
 
 #include "errno-from-name.inc"
 
-#if !HAVE_STRERRORNAME_NP
+#if HAVE_STRERRORNAME_NP
+const char* errno_to_name(int id) {
+        if (id == 0) /* To stay in line with our own impl */
+                return NULL;
+
+        return strerrorname_np(ABS(id));
+}
+#else
 #include "errno-to-name.inc"
 
 const char* errno_to_name(int id) {
index e4a59788296cb64adad5653db2d09ed9f5d6f0f2..ce9516068d033b3350d9dab6d2342812fc250f67 100644 (file)
@@ -1,30 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <errno.h>
-#include <stdbool.h>
-#include <string.h>
+#include "forward.h"
 
-#include "macro.h"
-
-/*
- * MAX_ERRNO is defined as 4095 in linux/err.h
- * We use the same value here.
- */
-#define ERRNO_MAX 4095
-
-#if HAVE_STRERRORNAME_NP
-static inline const char* errno_to_name(int id) {
-        if (id == 0) /* To stay in line with our own impl */
-                return NULL;
-
-        return strerrorname_np(ABS(id));
-}
-#else
 const char* errno_to_name(int id);
-#endif
 
-int errno_from_name(const char *name);
+int errno_from_name(const char *name) _const_;
 
 static inline bool errno_is_valid(int n) {
         return n > 0 && n <= ERRNO_MAX;
index 2a5a5abb8a6a3b7f9cb884762771139c98a4a59a..fa53744f6140d57848776184c43d448dc578aae2 100644 (file)
@@ -1,15 +1,12 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <errno.h>
-#include <inttypes.h>
 #include <string.h>
 
-#include "assert-util.h"
-#include "macro.h"
+#include "forward.h"
 
 /* strerror(3) says that glibc uses a maximum length of 1024 bytes. */
-#define ERRNO_BUF_LEN 1024
+#define ERRNO_BUF_LEN           1024
 
 /* Note: the lifetime of the compound literal is the immediately surrounding block,
  * see C11 Â§6.5.2.5, and
@@ -55,6 +52,7 @@ static inline int negative_errno(void) {
          * It will suppress bogus gcc warnings in case it assumes 'errno' might
          * be 0 and thus the caller's error-handling might not be triggered. */
         assert_return(errno > 0, -EINVAL);
+
         return -errno;
 }
 
index e1ded5598117b6d192fdf598af1dff2e86e63311..79123536c034cb856b18a4432a30d5de20d07b28 100644 (file)
@@ -1,13 +1,12 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include "alloc-util.h"
 #include "escape.h"
 #include "hexdecoct.h"
-#include "macro.h"
+#include "string-util.h"
 #include "strv.h"
 #include "utf8.h"
 
@@ -300,6 +299,9 @@ ssize_t cunescape_length_with_prefix(const char *s, size_t length, const char *p
 
         /* Undoes C style string escaping, and optionally prefixes it. */
 
+        if (length == SIZE_MAX)
+                length = strlen(s);
+
         pl = strlen_ptr(prefix);
 
         ans = new(char, pl+length+1);
index 05c27f688e3f1801109e17adc1c1109dc7a84569..c42302c24ee0f26f29f4b9ff56bce44bdb5eea2e 100644 (file)
@@ -1,13 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <inttypes.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <uchar.h>
-
-#include "string-util.h"
+#include "forward.h"
 
 /* What characters are special in the shell? */
 /* must be escaped outside and inside double-quotes */
@@ -53,7 +47,7 @@ static inline ssize_t cunescape_length(const char *s, size_t length, UnescapeFla
         return cunescape_length_with_prefix(s, length, NULL, flags, ret);
 }
 static inline ssize_t cunescape(const char *s, UnescapeFlags flags, char **ret) {
-        return cunescape_length(s, strlen(s), flags, ret);
+        return cunescape_length(s, SIZE_MAX, flags, ret);
 }
 
 typedef enum XEscapeFlags {
index 7e85de92fb98d125e05023c57831d4e39538a644..375c04441573823c17f75bc0fe13ab61f1d50bea 100644 (file)
@@ -1,15 +1,14 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-#include <inttypes.h>
 #include <net/ethernet.h>
 #include <stdio.h>
-#include <sys/types.h>
 
 #include "ether-addr-util.h"
+#include "hash-funcs.h"
 #include "hexdecoct.h"
-#include "log.h"
-#include "macro.h"
+#include "in-addr-util.h"
+#include "memory-util.h"
+#include "siphash24.h"
 #include "string-util.h"
 
 char* hw_addr_to_string_full(
@@ -64,6 +63,11 @@ void hw_addr_hash_func(const struct hw_addr_data *p, struct siphash *state) {
         siphash24_compress_safe(p->bytes, p->length, state);
 }
 
+bool hw_addr_is_null(const struct hw_addr_data *addr) {
+        assert(addr);
+        return addr->length == 0 || memeqzero(addr->bytes, addr->length);
+}
+
 DEFINE_HASH_OPS(hw_addr_hash_ops, struct hw_addr_data, hw_addr_hash_func, hw_addr_compare);
 DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(hw_addr_hash_ops_free, struct hw_addr_data, hw_addr_hash_func, hw_addr_compare, free);
 
@@ -94,6 +98,11 @@ static void ether_addr_hash_func(const struct ether_addr *p, struct siphash *sta
         siphash24_compress_typesafe(*p, state);
 }
 
+bool ether_addr_is_broadcast(const struct ether_addr *addr) {
+        assert(addr);
+        return memeqbyte(0xff, addr->ether_addr_octet, ETH_ALEN);
+}
+
 DEFINE_HASH_OPS(ether_addr_hash_ops, struct ether_addr, ether_addr_hash_func, ether_addr_compare);
 DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(ether_addr_hash_ops_free, struct ether_addr, ether_addr_hash_func, ether_addr_compare, free);
 
index 168c6500dc4d2c64722168799f7c3da788ace680..d2c6df444a4ca406afb5cd98ad435fa2da42aa24 100644 (file)
@@ -2,13 +2,10 @@
 #pragma once
 
 #include <linux/if_infiniband.h>
+#include <netinet/in.h>
 #include <net/ethernet.h>
-#include <stdbool.h>
 
-#include "hash-funcs.h"
-#include "in-addr-util.h"
-#include "macro.h"
-#include "memory-util.h"
+#include "forward.h"
 
 /* This is MAX_ADDR_LEN as defined in linux/netdevice.h, but net/if_arp.h
  * defines a macro of the same name with a much lower size. */
@@ -59,10 +56,7 @@ int hw_addr_compare(const struct hw_addr_data *a, const struct hw_addr_data *b);
 static inline bool hw_addr_equal(const struct hw_addr_data *a, const struct hw_addr_data *b) {
         return hw_addr_compare(a, b) == 0;
 }
-static inline bool hw_addr_is_null(const struct hw_addr_data *addr) {
-        assert(addr);
-        return addr->length == 0 || memeqzero(addr->bytes, addr->length);
-}
+bool hw_addr_is_null(const struct hw_addr_data *addr) _pure_;
 
 extern const struct hash_ops hw_addr_hash_ops;
 extern const struct hash_ops hw_addr_hash_ops_free;
@@ -86,10 +80,7 @@ static inline bool ether_addr_is_null(const struct ether_addr *addr) {
         return ether_addr_equal(addr, &ETHER_ADDR_NULL);
 }
 
-static inline bool ether_addr_is_broadcast(const struct ether_addr *addr) {
-        assert(addr);
-        return memeqbyte(0xff, addr->ether_addr_octet, ETH_ALEN);
-}
+bool ether_addr_is_broadcast(const struct ether_addr *addr) _pure_;
 
 static inline bool ether_addr_is_multicast(const struct ether_addr *addr) {
         assert(addr);
index 012cee6e75a1124c6fc968df7b798fecd2f037c5..99de8740d1320ba1a149007e3bf304da2dcd4232 100644 (file)
@@ -1,20 +1,10 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <syslog.h>
-
 #include "alloc-util.h"
 #include "escape.h"
 #include "extract-word.h"
 #include "log.h"
-#include "macro.h"
 #include "string-util.h"
-#include "strv.h"
 #include "utf8.h"
 
 int extract_first_word(const char **p, char **ret, const char *separators, ExtractFlags flags) {
index da4f6ae674abbbd67543a16b806c3805c96c33f1..2740de9189e4e3e7499ce33084d8ec6b9db28006 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "macro.h"
+#include "forward.h"
 
 typedef enum ExtractFlags {
         EXTRACT_RELAX                    = 1 << 0, /* Allow unbalanced quote and eat up trailing backslash. */
index 55b274a25ee30e1e1a42332de2a743b8f39e99b2..d58f5a987a6d176225a4169e256ebe4d53b70779 100644 (file)
@@ -1,9 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <fcntl.h>
 #include <linux/kcmp.h>
-#include <linux/magic.h>
 #include <sys/ioctl.h>
 #include <sys/resource.h>
 #include <sys/stat.h>
 
 #include "alloc-util.h"
 #include "dirent-util.h"
+#include "errno-util.h"
 #include "fd-util.h"
 #include "fileio.h"
+#include "format-util.h"
 #include "fs-util.h"
-#include "io-util.h"
 #include "log.h"
-#include "macro.h"
 #include "missing_fcntl.h"
 #include "missing_fs.h"
 #include "missing_syscall.h"
@@ -28,6 +26,7 @@
 #include "sort-util.h"
 #include "stat-util.h"
 #include "stdio-util.h"
+#include "string-util.h"
 
 /* The maximum number of iterations in the loop to close descriptors in the fallback case
  * when /proc/self/fd/ is inaccessible. */
@@ -1131,6 +1130,13 @@ int fds_are_same_mount(int fd1, int fd2) {
         return statx_mount_same(&sx1, &sx2);
 }
 
+char* format_proc_fd_path(char buf[static PROC_FD_PATH_MAX], int fd) {
+        assert(buf);
+        assert(fd >= 0);
+        assert_se(snprintf_ok(buf, PROC_FD_PATH_MAX, "/proc/self/fd/%i", fd));
+        return buf;
+}
+
 const char* accmode_to_string(int flags) {
         switch (flags & O_ACCMODE_STRICT) {
         case O_RDONLY:
index 82dd9d31e7ea80910d2d4dbc834e139e66c2f840..6e2b709657b87be66a9f5f0836a36df5c06e9583 100644 (file)
@@ -2,16 +2,10 @@
 #pragma once
 
 #include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdbool.h>
 #include <stdio.h>
-#include <sys/socket.h>
 
-#include "macro.h"
-#include "memory-util.h"
+#include "forward.h"
 #include "missing_fcntl.h"
-#include "stdio-util.h"
 
 /* maximum length of fdname */
 #define FDNAME_MAX 255
@@ -42,6 +36,10 @@ void close_many_and_free(int *fds, size_t n_fds);
 int fclose_nointr(FILE *f);
 FILE* safe_fclose(FILE *f);
 DIR* safe_closedir(DIR *f);
+static inline void* close_fd_ptr(void *p) {
+        safe_close(PTR_TO_FD(p));
+        return NULL;
+}
 
 static inline void closep(int *fd) {
         safe_close(*fd);
@@ -55,11 +53,6 @@ static inline void fclosep(FILE **f) {
         safe_fclose(*f);
 }
 
-static inline void* close_fd_ptr(void *p) {
-        safe_close(PTR_TO_FD(p));
-        return NULL;
-}
-
 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(FILE*, pclose, NULL);
 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(DIR*, closedir, NULL);
 
@@ -144,12 +137,7 @@ int fds_are_same_mount(int fd1, int fd2);
 #define PROC_FD_PATH_MAX \
         (STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int))
 
-static inline char* format_proc_fd_path(char buf[static PROC_FD_PATH_MAX], int fd) {
-        assert(buf);
-        assert(fd >= 0);
-        assert_se(snprintf_ok(buf, PROC_FD_PATH_MAX, "/proc/self/fd/%i", fd));
-        return buf;
-}
+char* format_proc_fd_path(char buf[static PROC_FD_PATH_MAX], int fd);
 
 #define FORMAT_PROC_FD_PATH(fd) \
         format_proc_fd_path((char[PROC_FD_PATH_MAX]) {}, (fd))
index 509514512d9fc8b1e3e23ff7b08ee1a2ddf2ed8c..eaadfaa6accc48b75610b52c8e8b3472a921d98a 100644 (file)
@@ -1,19 +1,13 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <ctype.h>
-#include <errno.h>
 #include <fcntl.h>
-#include <limits.h>
-#include <stdarg.h>
-#include <stdint.h>
 #include <stdio_ext.h>
 #include <stdlib.h>
 #include <sys/stat.h>
-#include <sys/types.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
-#include "chase.h"
+#include "errno-util.h"
 #include "extract-word.h"
 #include "fd-util.h"
 #include "fileio.h"
 #include "hexdecoct.h"
 #include "label.h"
 #include "log.h"
-#include "macro.h"
 #include "mkdir.h"
 #include "nulstr-util.h"
 #include "parse-util.h"
 #include "path-util.h"
 #include "socket-util.h"
+#include "stat-util.h"
 #include "stdio-util.h"
 #include "string-util.h"
 #include "strv.h"
 #include "sync-util.h"
 #include "terminal-util.h"
+#include "time-util.h"
 #include "tmpfile-util.h"
 
 /* The maximum size of the file we'll read in one go in read_full_file() (64M). */
index eff98802928df85e9e373bf9441c52cae779d951..b6513fe3f884842e2c822ab2e474b358d9da3c2c 100644 (file)
@@ -1,16 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <dirent.h>
-#include <fcntl.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include "macro.h"
-#include "time-util.h"
+#include "forward.h"
 
 #define LONG_LINE_MAX (1U*1024U*1024U)
 
index 45f56fdf5aab98199136cce93a569d86bcfd74cc..c8b407fc7e8654692499bccec0e37c8ded1ebf2b 100644 (file)
@@ -1,7 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include "filesystems-gperf.h"
+#include "nulstr-util.h"
 #include "stat-util.h"
+#include "string-util.h"
 
 const char* fs_type_to_string(statfs_f_type_t magic) {
 
index 4e6c6c47fc37ef72c950e97a3aa65bd1fb2d79a7..4d6d7e2641144eb9390e49b2fca4268d6bdc0c7f 100644 (file)
@@ -1,9 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "nulstr-util.h"
+#include "forward.h"
 #include "stat-util.h"
-#include "string-util.h"
 
 #define FILESYSTEM_MAGIC_MAX 10
 
index 8331d202889321450e05ae1b6c6d1885b1f4af40..9d3952f27e698e2cdccf81900dd891a7ec33acd5 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include "format-ifname.h"
-#include "log.h"
 #include "stdio-util.h"
 #include "string-util.h"
 
index 079b32c04db3ff7748b8b75049e5a291c13c5e82..021ece9eeb860cccbd017e2a358653975f9b7829 100644 (file)
@@ -1,9 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include "format-util.h"
-#include "memory-util.h"
-#include "stdio-util.h"
-#include "strxcpyx.h"
 
 char* format_bytes_full(char *buf, size_t l, uint64_t t, FormatBytesFlag flag) {
         typedef struct {
index b528c005ca63beba8b1464b3dadcd0ee6bf115fb..e42f788ce6f26b2893e71c5ca88e15b08f814882 100644 (file)
@@ -1,11 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <inttypes.h>
-#include <stdbool.h>
-
 #include "cgroup-util.h"
-#include "macro.h"
+#include "forward.h"
+#include "stdio-util.h"
 
 assert_cc(sizeof(pid_t) == sizeof(int32_t));
 #define PID_PRI PRIi32
index 307740352866cab6f4f343ef18da5765d4ac22ad..0456772980d0c9af460fb011c68a98454f0bf4c6 100644 (file)
@@ -85,6 +85,7 @@ typedef enum CGroupFlags CGroupFlags;
 typedef enum CGroupMask CGroupMask;
 typedef enum ChaseFlags ChaseFlags;
 typedef enum ExtractFlags ExtractFlags;
+typedef enum Glyph Glyph;
 typedef enum ImageClass ImageClass;
 typedef enum JobMode JobMode;
 typedef enum RuntimeScope RuntimeScope;
index 5b83c78b24df161916e0ffb056a3d5817b5e16f9..6c6b00596779e8202547dc7e3898042a26a86ac2 100644 (file)
@@ -1,9 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <linux/falloc.h>
-#include <linux/magic.h>
-#include <stddef.h>
 #include <stdlib.h>
 #include <sys/file.h>
 #include <unistd.h>
 #include "dirent-util.h"
 #include "errno-util.h"
 #include "fd-util.h"
-#include "fileio.h"
 #include "fs-util.h"
 #include "hostname-util.h"
 #include "label.h"
 #include "lock-util.h"
 #include "log.h"
-#include "macro.h"
 #include "missing_fcntl.h"
-#include "missing_fs.h"
 #include "missing_syscall.h"
 #include "mkdir.h"
-#include "parse-util.h"
 #include "path-util.h"
 #include "process-util.h"
 #include "random-util.h"
 #include "ratelimit.h"
 #include "stat-util.h"
-#include "stdio-util.h"
 #include "string-util.h"
 #include "strv.h"
 #include "time-util.h"
 #include "tmpfile-util.h"
 #include "umask-util.h"
-#include "user-util.h"
 
 int rmdir_parents(const char *path, const char *stop) {
         char *p;
@@ -695,6 +686,16 @@ char *rmdir_and_free(char *p) {
         return mfree(p);
 }
 
+char* unlink_and_free(char *p) {
+        PROTECT_ERRNO;
+
+        if (!p)
+                return NULL;
+
+        (void) unlink(p);
+        return mfree(p);
+}
+
 int access_fd(int fd, int mode) {
         assert(fd >= 0);
 
index 9f2b37a2d6cb40de4af7d3fcf1fb654b823eda15..59dbb1ce0eea4cb8e57b9e41cb462dc6a4131909 100644 (file)
@@ -1,20 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <dirent.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
+#include "forward.h"
 #include "lock-util.h"
-#include "memory-util.h"
-#include "time-util.h"
-
-#define MODE_INVALID ((mode_t) -1)
 
 /* The following macros add 1 when converting things, since 0 is a valid mode, while the pointer
  * NULL is special */
@@ -86,13 +74,7 @@ int unlink_or_warn(const char *filename);
 char *rmdir_and_free(char *p);
 DEFINE_TRIVIAL_CLEANUP_FUNC(char*, rmdir_and_free);
 
-static inline char* unlink_and_free(char *p) {
-        if (!p)
-                return NULL;
-
-        (void) unlink(p);
-        return mfree(p);
-}
+char* unlink_and_free(char *p);
 DEFINE_TRIVIAL_CLEANUP_FUNC(char*, unlink_and_free);
 
 int access_fd(int fd, int mode);
index 70b6413e9b7a2860e8271daca792e13f3eb4dbc6..bd73621c6fe505cc4a6d9d0aca8c550074a082b7 100644 (file)
@@ -2,9 +2,9 @@
 
 #if HAVE_GCRYPT
 
+#include <sys/syslog.h>
+
 #include "gcrypt-util.h"
-#include "hexdecoct.h"
-#include "log.h"
 
 static void *gcrypt_dl = NULL;
 
index 5fc176cb6c6f3640d2b8e96943603813b0239454..83e32babb55b4b93ce3997068df394479eb0c531 100644 (file)
@@ -2,17 +2,12 @@
 
 #pragma once
 
-#include <errno.h>
-#include <stdbool.h>
-#include <stddef.h>
-
-#include "memory-util.h"
+#include "forward.h"
 
 #if HAVE_GCRYPT
-#include <gcrypt.h>
+#include <gcrypt.h> /* IWYU pragma: export */
 
 #include "dlfcn-util.h"
-#include "macro.h"
 
 extern DLSYM_PROTOTYPE(gcry_md_close);
 extern DLSYM_PROTOTYPE(gcry_md_copy);
index 59dda9809caf047a8ebc7bd1be80183624155b09..9eec8b3f092b687ec5b5b729616c80bcf99289c7 100644 (file)
@@ -1,16 +1,13 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
+#include <dirent.h>
 #include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
 
 #include "dirent-util.h"
 #include "errno-util.h"
 #include "glob-util.h"
 #include "log.h"
-#include "macro.h"
-#include "path-util.h"
+#include "string-util.h"
 #include "strv.h"
 
 static void closedir_wrapper(void* v) {
@@ -104,3 +101,8 @@ int glob_non_glob_prefix(const char *path, char **ret) {
         *ret = ans;
         return 0;
 }
+
+bool string_is_glob(const char *p) {
+        /* Check if a string contains any glob patterns. */
+        return !!strpbrk(p, GLOB_CHARS);
+}
index 7ca26cc27f73903e6661e902f704f363347310c1..4fa23f504897adba008098923d80f33d2bf4d83f 100644 (file)
@@ -1,11 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <glob.h>
-#include <stdbool.h>
+#include <glob.h>       /* IWYU pragma: export */
 
-#include "macro.h"
-#include "string-util.h"
+#include "forward.h"
 
 /* Note: this function modifies pglob to set various functions. */
 int safe_glob(const char *path, int flags, glob_t *pglob);
@@ -19,7 +17,4 @@ int glob_non_glob_prefix(const char *path, char **ret);
 
 #define _cleanup_globfree_ _cleanup_(globfree)
 
-_pure_ static inline bool string_is_glob(const char *p) {
-        /* Check if a string contains any glob patterns. */
-        return !!strpbrk(p, GLOB_CHARS);
-}
+bool string_is_glob(const char *p) _pure_;
index 730f26956002ce0b18ae7cde029bb50be04419b3..b1c90d00f6a89ee4950f3653e3096fa934777521 100644 (file)
@@ -1,10 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <errno.h>
-#include <stdbool.h>
-
-#include "macro.h"
+#include "forward.h"
 
 typedef enum Glyph {
         GLYPH_SPACE,
index d7496f3e211c1b0eff52c2a5122fe68cdc49aa4b..5b5e06c0253594665498c3fd04c64c0618ce10e0 100644 (file)
@@ -5,8 +5,9 @@
  *  Copyright Â© 2000, 2005 Red Hat, Inc.
  */
 
+#include <stdlib.h>
+
 #include "gunicode.h"
-#include "macro.h"
 
 #define unichar uint32_t
 
index 6b7183986fd2fc8a08997c60ce5d0aa08c0669ad..9bba03ba30b9a120ec9b7dddea6959a356482654 100644 (file)
@@ -6,9 +6,7 @@
  */
 #pragma once
 
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdlib.h>
+#include "forward.h"
 
 char *utf8_prev_char (const char *p);
 
index 6540fa5dfc3802871c2c07ce3c4ba1f9b76cef92..195256d07d22a537de4ff30189e7e3fe065332eb 100644 (file)
@@ -1,10 +1,12 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include <stdlib.h>
 #include <string.h>
 #include <sys/sysmacros.h>
 
 #include "hash-funcs.h"
 #include "path-util.h"
+#include "siphash24.h"
 #include "strv.h"
 
 void string_hash_func(const char *p, struct siphash *state) {
index d0736807ba45df3792f77a56af9d18e2ea032c8b..7ce29fbe6cdf4bf583c615b061372765f12c20cb 100644 (file)
@@ -1,9 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "alloc-util.h"
-#include "macro.h"
-#include "siphash24.h"
+#include "forward.h"
 
 typedef void (*hash_func_t)(const void *p, struct siphash *state);
 typedef int (*compare_func_t)(const void *a, const void *b);
index 3366d8f60b3c0a3b7fd850a8c18691608fec678a..bd6bdc359b0bca09fd50b8a2b0c91b1e1a043880 100644 (file)
@@ -1,23 +1,18 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <fnmatch.h>
 #include <pthread.h>
-#include <stdint.h>
-#include <stdlib.h>
 #if HAVE_VALGRIND_VALGRIND_H
 #  include <valgrind/valgrind.h>
 #endif
 
 #include "alloc-util.h"
-#include "fileio.h"
+#include "extract-word.h"
 #include "hashmap.h"
 #include "log.h"
 #include "logarithm.h"
-#include "macro.h"
 #include "memory-util.h"
 #include "mempool.h"
-#include "missing_syscall.h"
 #include "process-util.h"
 #include "random-util.h"
 #include "set.h"
index 52d3f45f0a90dfb83b1f72a586d4cda8bc0a3b3c..3e8fc28ee0767a049cbc6c9ea34fa52f654f2d03 100644 (file)
@@ -1,13 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <limits.h>
-#include <stdbool.h>
-#include <stddef.h>
-
+#include "forward.h"
 #include "hash-funcs.h"
 #include "iterator.h"
-#include "macro.h"
 
 /*
  * A hash table implementation. As a minor optimization a NULL hashmap object
@@ -22,7 +18,6 @@
 
 #define HASH_KEY_SIZE 16
 
-typedef void* (*hashmap_destroy_t)(void *p);
 
 /* The base type for all hashmap and set types. Many functions in the implementation take (HashmapBase*)
  * parameters and are run-time polymorphic, though the API is not meant to be polymorphic (do not call
index a08a4697ac3aa2e9ea2415e7eb09d46f18d66146..d0f3450e2c739f9047af8229c70a43e0d45ab4f0 100644 (file)
@@ -1,14 +1,10 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include <ctype.h>
-#include <errno.h>
-#include <limits.h>
-#include <stdint.h>
-#include <stdlib.h>
+#include <stdio.h>
 
 #include "alloc-util.h"
 #include "hexdecoct.h"
-#include "macro.h"
 #include "memory-util.h"
 #include "string-util.h"
 
index b456200e1b402d239e25947293f543d77f430fcc..5841af0b7a6d44d2249fa0db3c43e1e1c5119009 100644 (file)
@@ -1,12 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <sys/types.h>
-
-#include "macro.h"
+#include "forward.h"
 
 char octchar(int x) _const_;
 int unoctchar(char c) _const_;
index a5f66d560566b93c53152649613b282ae69adbcb..d70b874e2cd36200ec403117efe9b280c9373b8d 100644 (file)
@@ -1,6 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <assert.h>
 #include <string.h>
 
 #include "hmac.h"
index e58c1838a3deb67bff08962d2c9387a4312d5a1d..fd474f7649fea131c695f37e444878f57dabd2dd 100644 (file)
@@ -1,9 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdint.h>
-#include <stdlib.h>
-
+#include "forward.h"
 #include "sha256.h"
 
 /* Unoptimized implementation based on FIPS 198. 'res' has to be allocated by
index 5507303055ca0866a94e2c6ebedd54c0129bd4bd..673e1de3d42c4b8218a85e02e6a26fd6e67eecbc 100644 (file)
@@ -1,11 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-#include <limits.h>
-#include <stdio.h>
 #include <stdlib.h>
-#include <sys/utsname.h>
-#include <unistd.h>
 
 #include "alloc-util.h"
 #include "env-file.h"
index 4c5abe760f01c765e4029370e5468818036e1b4d..d85391e59fcd40549fb9a5d8fecbfb70f748e5eb 100644 (file)
@@ -1,10 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-#include <stdio.h>
-
-#include "macro.h"
+#include "forward.h"
 #include "strv.h"
 
 char* get_default_hostname_raw(void);
index 4e39985e27514c2b92f61d1f3120e9d0b629cadb..aded2b93abfc175effa04785de8899caf384d4ea 100644 (file)
@@ -2,23 +2,19 @@
 
 #include <arpa/inet.h>
 #include <endian.h>
-#include <errno.h>
-#include <net/if.h>
-#include <stdint.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 #include "alloc-util.h"
 #include "errno-util.h"
+#include "hash-funcs.h"
 #include "in-addr-util.h"
 #include "logarithm.h"
-#include "macro.h"
 #include "memory-util.h"
 #include "parse-util.h"
 #include "random-util.h"
+#include "siphash24.h"
 #include "stdio-util.h"
 #include "string-util.h"
-#include "strxcpyx.h"
 
 bool in4_addr_is_null(const struct in_addr *a) {
         assert(a);
@@ -493,6 +489,18 @@ int in_addr_to_string(int family, const union in_addr_union *u, char **ret) {
         return 0;
 }
 
+const char* typesafe_inet_ntop(int family, const union in_addr_union *a, char *buf, size_t len) {
+        return inet_ntop(family, a, buf, len);
+}
+
+const char* typesafe_inet_ntop4(const struct in_addr *a, char *buf, size_t len) {
+        return inet_ntop(AF_INET, a, buf, len);
+}
+
+const char* typesafe_inet_ntop6(const struct in6_addr *a, char *buf, size_t len) {
+        return inet_ntop(AF_INET6, a, buf, len);
+}
+
 int in_addr_prefix_to_string(
                 int family,
                 const union in_addr_union *u,
index 2efe9aec01c7032664d3d44d091154cfd2f9518e..a9491806ec56ab58b0aeee28c9e835dc8f106f7c 100644 (file)
@@ -1,13 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <arpa/inet.h>
 #include <netinet/in.h>
-#include <stddef.h>
-#include <sys/socket.h>
 
-#include "hash-funcs.h"
-#include "macro.h"
+#include "forward.h"
 
 union in_addr_union {
         struct in_addr in;
@@ -92,15 +88,9 @@ static inline int in6_addr_to_string(const struct in6_addr *u, char **ret) {
         return in_addr_to_string(AF_INET6, (const union in_addr_union*) u, ret);
 }
 
-static inline const char* typesafe_inet_ntop(int family, const union in_addr_union *a, char *buf, size_t len) {
-        return inet_ntop(family, a, buf, len);
-}
-static inline const char* typesafe_inet_ntop4(const struct in_addr *a, char *buf, size_t len) {
-        return inet_ntop(AF_INET, a, buf, len);
-}
-static inline const char* typesafe_inet_ntop6(const struct in6_addr *a, char *buf, size_t len) {
-        return inet_ntop(AF_INET6, a, buf, len);
-}
+const char* typesafe_inet_ntop(int family, const union in_addr_union *a, char *buf, size_t len);
+const char* typesafe_inet_ntop4(const struct in_addr *a, char *buf, size_t len);
+const char* typesafe_inet_ntop6(const struct in6_addr *a, char *buf, size_t len);
 
 /* Note: the lifetime of the compound literal is the immediately surrounding block,
  * see C11 Â§6.5.2.5, and
@@ -187,8 +177,14 @@ static inline int in_addr_prefix_from_string_auto(const char *p, int *ret_family
 }
 
 static inline size_t FAMILY_ADDRESS_SIZE(int family) {
-        assert(IN_SET(family, AF_INET, AF_INET6));
-        return family == AF_INET6 ? 16 : 4;
+        switch (family) {
+                case AF_INET:
+                        return 4;
+                case AF_INET6:
+                        return 16;
+                default:
+                        assert_not_reached();
+        }
 }
 
 #define FAMILY_ADDRESS_SIZE_SAFE(f)                                     \
index 7d5b61ba061a0e658d98cbf17e4685df538986bb..ba2948ae5c0c926449113f7f3f6bd252a0a6e979 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <linux/if.h>
+#include <linux/if.h>   /* IWYU pragma: export */
 
 #define IF_NAMESIZE       16
 
index 7b384aeb73cffb21927f1c7736554a56e9737985..a414b6faf69c82eef928a7590789955382de5e0d 100644 (file)
@@ -1,4 +1,4 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <linux/if_arp.h>
+#include <linux/if_arp.h> /* IWYU pragma: export */
index 97475ac88218d0047e392798b90b8406f2057306..8e11c86491729725135fbec6a118f367739cf765 100644 (file)
@@ -1,9 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <linux/in.h>
-#include <linux/in6.h>
-#include <linux/ipv6.h>
+#include <linux/in.h>   /* IWYU pragma: export */
+#include <linux/in6.h>  /* IWYU pragma: export */
+#include <linux/ipv6.h> /* IWYU pragma: export */
 #include <stddef.h>
 #include <stdint.h>
 #include <sys/socket.h>
index 16cf080ab8566d8d69b49d5fe67fcb5134564977..c79160aff472a6728b2706fcf739ffca762dc199 100644 (file)
@@ -2,6 +2,7 @@
 #pragma once
 
 #include <features.h>
+#include <linux/mount.h> /* IWYU pragma: export */
 #include <stddef.h>
 #include <stdint.h>
 #include <sys/ioctl.h>
index 2478b0cc29d06a73a026e95e1556b7d334f863ba..c45920b3070ae896573d3a5ee9b0f8645fac3d44 100644 (file)
@@ -6,9 +6,6 @@
 #include "errno-util.h"
 #include "initrd-util.h"
 #include "log.h"
-#include "parse-util.h"
-#include "stat-util.h"
-#include "string-util.h"
 
 static int saved_in_initrd = -1;
 
index 173093c069e621288e65e625c1aaf3a91494672a..29e47828dab4195d6f8ef303db0d4af69511414f 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
+#include "forward.h"
 
 bool in_initrd(void);
 void in_initrd_force(bool value);
index d8cbb0450915b146f7426d65e741fb64d450ba64..209f395e22417f1ca6390b07c43b5f4543ffe77b 100644 (file)
@@ -2,7 +2,8 @@
 
 #include "fd-util.h"
 #include "inotify-util.h"
-#include "stat-util.h"
+#include "log.h"
+#include "memory-util.h"
 
 bool inotify_event_next(
                 union inotify_event_buffer *buffer,
index 665fdacaa6cfe4eae65ea2be338d0d71f123a33a..a509a97f50ebaaf3d765d2e76dbe5e936c9e3642 100644 (file)
@@ -1,12 +1,10 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <inttypes.h>
-#include <limits.h>
-#include <stddef.h>
-#include <sys/inotify.h>
+#include <sys/inotify.h>        /* IWYU pragma: export */
+#include <syslog.h>
 
-#include "log.h"
+#include "forward.h"
 
 #define INOTIFY_EVENT_MAX (offsetof(struct inotify_event, name) + NAME_MAX + 1)
 
index 7d7f34f2035300a376226a8824486d98347d0e26..69c275ae179f2e7923332eda1ecb79a296f01fbd 100644 (file)
@@ -1,14 +1,13 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-#include <limits.h>
+#include <poll.h>
 #include <stdio.h>
+#include <string.h>
+#include <time.h>
 #include <unistd.h>
 
 #include "errno-util.h"
 #include "io-util.h"
-#include "iovec-util.h"
-#include "string-util.h"
 #include "time-util.h"
 
 int flush_fd(int fd) {
index 208e168317d6492bf6a91f3f51b368d00c425311..f560b706b443bedfe33c82988dbc0bf682bdc066 100644 (file)
@@ -1,14 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <poll.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "macro.h"
-#include "time-util.h"
+#include "forward.h"
 
 int flush_fd(int fd);
 
index 49cd0f67e10a37fd638a74e44ae1376614e96dcd..3add1bddd086ff74296543a7960970c2bf618966 100644 (file)
@@ -1,8 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-
-#include "assert-util.h"
 #include "ioprio-util.h"
 #include "parse-util.h"
 #include "string-table.h"
index 376eb85dadc53f1ffbc0302c872578369be20261..0873d8ef616738cb4f4d1df970cfbbb921d39277 100644 (file)
@@ -1,9 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <linux/ioprio.h>
+#include <linux/ioprio.h>       /* IWYU pragma: export */
 
-#include "macro.h"
+#include "forward.h"
 
 static inline int ioprio_prio_class(int value) {
         return IOPRIO_PRIO_CLASS(value);
index d194195e7455a110d453788f0864ee34b5266d52..f1e4be88d43d1be8f68c461707a809180401a89d 100644 (file)
@@ -1,12 +1,10 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-#include <sys/types.h>
-#include <sys/uio.h>
+#include <sys/uio.h>                /* IWYU pragma: export */
 
-#include "iovec-util-fundamental.h"
-#include "macro.h"
+#include "forward.h"
+#include "iovec-util-fundamental.h" /* IWYU pragma: export */
 
 extern const struct iovec iovec_nul_byte; /* Points to a single NUL byte */
 extern const struct iovec iovec_empty;    /* Points to an empty, but valid (i.e. non-NULL) pointer */
index 27b84d2cdb9fbe0947a1c822fb1e66d25e332635..5cc3cc2f93d5b9282b3935eece1530ad297294bd 100644 (file)
@@ -1,8 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-#include <limits.h>
-
 #include "alloc-util.h"
 #include "iovec-util.h"
 #include "iovec-wrapper.h"
index f45dd87b7eff52ae45b3b23f629730ff32341d65..082d7e0ae0025d83384ae5ae802bcb210686a80d 100644 (file)
@@ -1,11 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <sys/types.h>
-#include <sys/uio.h>
-
-#include "macro.h"
-#include "memory-util.h"
+#include "forward.h"
 
 struct iovec_wrapper {
         struct iovec *iovec;
index 87cdd3c6559508ee16c1ad65351454d51feecf03..be9e1a9b6bd1777f87474b41d941ce709500052d 100644 (file)
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include "forward.h"
+
 /* Ideally the Iterator would be an opaque struct, but it is instantiated
  * by hashmap users, so the definition has to be here. Do not use its fields
  * directly. */
index 2a9b3d9aca95cc9515bad75c6ea4156e5000e1b4..6bfc5e38f62bcfbaacdf4844a6b93d2a6033cc23 100644 (file)
@@ -3,7 +3,6 @@
 #include "alloc-util.h"
 #include "keyring-util.h"
 #include "log.h"
-#include "memory-util.h"
 #include "missing_syscall.h"
 
 int keyring_read(key_serial_t serial, void **ret, size_t *ret_size) {
index 6e6e6856ada291de602178607f28df0fc56a10ca..a949f8907e1d69f8c473325b16eae939f480f24a 100644 (file)
@@ -1,8 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <sys/types.h>
-
+#include "forward.h"
 #include "missing_keyctl.h"
 
 /* Like TAKE_PTR() but for key_serial_t, resetting them to -1 */
index b922fd2f191ef3f363a3342f8441072862e29595..cce3e75c7c1be2ce1a70b122d8944632cf1195f1 100644 (file)
@@ -1,11 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-#include <stddef.h>
-
-#include "assert-util.h"
 #include "label.h"
-#include "macro.h"
 
 static const LabelOps *label_ops = NULL;
 
index d001307a4fd5089d44a0c88160ad0a59cb3dba9b..186f93d697b52f489d5072c8b70533e18288fc6d 100644 (file)
@@ -1,8 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-#include <sys/types.h>
+#include "forward.h"
 
 typedef struct LabelOps {
         int (*pre)(int dir_fd, const char *path, mode_t mode);
index 5deaf9dda70aeaebce7723a777fb56bfce250589..ffa89b04461a5f8f65091ca836fc788f8b584417 100644 (file)
@@ -10,7 +10,6 @@
 #include "parse-util.h"
 #include "process-util.h"
 #include "procfs-util.h"
-#include "string-util.h"
 
 uint64_t physical_memory(void) {
         _cleanup_free_ char *root = NULL, *value = NULL;
index d267fcf1d48b0e09f08b00d70c7bd93f545ea378..6049cfa9e9f57c2782dac36db418fd62f0a5c043 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <inttypes.h>
+#include "forward.h"
 
 uint64_t physical_memory(void);
 uint64_t physical_memory_scale(uint64_t v, uint64_t max);
index 090bdc7b6021894ef935afbd5bbbf0d252236e86..ee3405f0548013e513f3d3377c00440762c83a9e 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "macro.h"
+#include "forward.h"
 
 /* The head of the linked list. Use this in the structure that shall
  * contain the head of the linked list */
index 9121ce01f63094d55582060c54765442e66304dd..455b54bc61cc90404d11b73bd72c3b221cac0701 100644 (file)
@@ -1,21 +1,15 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <fcntl.h>
 #include <langinfo.h>
-#include <libintl.h>
-#include <stddef.h>
-#include <stdint.h>
 #include <stdlib.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
 
-#include "constants.h"
 #include "dirent-util.h"
 #include "env-util.h"
 #include "fd-util.h"
 #include "fileio.h"
-#include "hashmap.h"
 #include "locale-util.h"
 #include "log.h"
 #include "path-util.h"
index da84799cf134cb07f394b1fb89ca4f7f7a15f315..1ec6d3074ef18494129ce5a645771b3abeac1d9d 100644 (file)
@@ -1,12 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <errno.h>
-#include <libintl.h>
-#include <locale.h>
-#include <stdbool.h>
+#include <locale.h>     /* IWYU pragma: export */
 
-#include "macro.h"
+#include "forward.h"
 
 typedef enum LocaleVariable {
         /* We don't list LC_ALL here on purpose. People should be
index f87ebb05c4ba15ee66b75a5d6a2a0a53d046d1b5..5921cc8f93136b97fba6f1617df91331897bdd64 100644 (file)
@@ -1,13 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <fcntl.h>
 #include <signal.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <sys/file.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
 
 #include "alloc-util.h"
 #include "errno-util.h"
 #include "fs-util.h"
 #include "lock-util.h"
 #include "log.h"
-#include "macro.h"
-#include "missing_fcntl.h"
 #include "path-util.h"
 #include "process-util.h"
+#include "string-util.h"
+#include "time-util.h"
 
 int make_lock_file_at(int dir_fd, const char *p, int operation, LockFile *ret) {
         _cleanup_close_ int fd = -EBADF, dfd = -EBADF;
index b327b8e5614c0fd3413d5265f4bcc384abb17663..b9643c22a1c4196d49e1f6e73ef2589de4a9c374 100644 (file)
@@ -1,11 +1,10 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <fcntl.h>
 /* Include here so consumers have LOCK_{EX,SH,NB} available. */
-#include <sys/file.h>
+#include <sys/file.h> /* IWYU pragma: export */
 
-#include "time-util.h"
+#include "forward.h"
 
 typedef struct LockFile {
         int dir_fd;
index 2b3a06aab64c4b84b3694426175b57b8385720bf..a49bddd591bb6898b8d16af987b40e09ba59bded 100644 (file)
@@ -1,12 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-#include <stddef.h>
-
+#include "forward.h"
 #include "list.h"
-#include "macro.h"
-#include "memory-util.h"
 
 /*
  * The log context allows attaching extra metadata to log messages written to the journal via log.h. We keep
index 02211460b571f5a9e5674ea0a1a34a9442dabb8e..be036d6e738cb5acc0d2b38870551e923ea39193 100644 (file)
@@ -1,16 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <fcntl.h>
-#include <inttypes.h>
-#include <limits.h>
-#include <stdarg.h>
-#include <stddef.h>
 #include <sys/signalfd.h>
 #include <sys/stat.h>
-#include <sys/time.h>
 #include <sys/uio.h>
-#include <sys/un.h>
 #include <threads.h>
 #include <unistd.h>
 
@@ -28,8 +21,6 @@
 #include "list.h"
 #include "log.h"
 #include "log-context.h"
-#include "macro.h"
-#include "missing_syscall.h"
 #include "parse-util.h"
 #include "proc-cmdline.h"
 #include "process-util.h"
index 07f187a24a98eae8d4a90dd6e9686f8f4507ac3b..4dfac9f4b3d88935ca06a3638efe5d183af81439 100644 (file)
@@ -1,15 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <errno.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stdlib.h>
+#include <stdio.h>
 #include <string.h>
 #include <syslog.h>
 
-#include "assert-util.h"
-#include "macro.h"
+#include "forward.h"
 
 /* Some structures we reference but don't want to pull in headers for */
 struct iovec;
index 044e8b7650ec606a0ba6af52902e21bcb50b6ce1..926e482fb0eacf4973eceb701a520c8e3328233d 100644 (file)
@@ -1,5 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include <unistd.h>
+
 #include "login-util.h"
 #include "string-util.h"
 
@@ -10,3 +12,7 @@ bool session_id_valid(const char *id) {
 
         return id[strspn(id, LETTERS DIGITS)] == '\0';
 }
+
+bool logind_running(void) {
+        return access("/run/systemd/seats/", F_OK) >= 0;
+}
index f9ca34152b8e6001b00fa52386e2b023270b4372..fd07ed2c6e8d038b7cfb7c2bbeae4e10a2d7fb97 100644 (file)
@@ -1,10 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-#include <unistd.h>
-
-#include "macro.h"
+#include "forward.h"
 
 #define SD_LOGIND_ROOT_CHECK_INHIBITORS           (UINT64_C(1) << 0)
 #define SD_LOGIND_REBOOT_VIA_KEXEC                (UINT64_C(1) << 1)
@@ -20,6 +17,4 @@
 
 bool session_id_valid(const char *id) _pure_;
 
-static inline bool logind_running(void) {
-        return access("/run/systemd/seats/", F_OK) >= 0;
-}
+bool logind_running(void);
index 03a05b136807a71a9189868bc148cb38dcca5050..caefa7c57c6faac9a7e9af7d687dd4869f45cd3d 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "macro-fundamental.h"
+#include "macro-fundamental.h" /* IWYU pragma: export */
 
 #if !defined(HAS_FEATURE_MEMORY_SANITIZER)
 #  if defined(__has_feature)
index 24023cd2be35c0c9cdbd8b93d3cde24ed3f8eed3..2cdd655ce8c5a4178dc867e984ebd26a65cdc3a1 100644 (file)
@@ -1,9 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <math.h>
+#include <math.h>       /* IWYU pragma: export */
 
-#include "macro.h"
+#include "forward.h"
 
 /* On some optimization level, iszero(x) is converted to (x == 0.0), and emits warning -Wfloat-equal.
  * The argument must be a floating point, i.e. one of float, double, or long double. */
index f19d39470d7e366c415b2df8d1b3d2a0ad060dbd..d3a1a8457e0b05f649f8cee013653afd0b5f758f 100644 (file)
@@ -1,6 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <stdio.h>
 #include <sys/prctl.h>
 #include <sys/stat.h>
@@ -9,12 +8,9 @@
 #include "alloc-util.h"
 #include "errno-util.h"
 #include "fd-util.h"
-#include "log.h"
-#include "macro.h"
 #include "memfd-util.h"
-#include "missing_fcntl.h"
 #include "missing_mman.h"
-#include "missing_syscall.h"
+#include "missing_sched.h"
 #include "string-util.h"
 #include "utf8.h"
 
index d7220d085dad9e6253fcfbcde54793c7e917c701..efa2f7c616bc18cab263706751f3d809dbd203c8 100644 (file)
@@ -1,12 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <inttypes.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "macro.h"
+#include "forward.h"
 
 int memfd_create_wrapper(const char *name, unsigned mode);
 
index 523486db1ff77d4769b85b5497c47715b74ca4ca..c36a0cc337a3b296628ff0e8e789ef7a5af90353 100644 (file)
@@ -1,16 +1,10 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <inttypes.h>
-#include <limits.h>
-#include <malloc.h>
-#include <stdbool.h>
 #include <string.h>
-#include <sys/types.h>
 
-#include "cleanup-util.h"
-#include "macro.h"
-#include "memory-util-fundamental.h"
+#include "forward.h"
+#include "memory-util-fundamental.h" /* IWYU pragma: export */
 
 size_t page_size(void) _pure_;
 #define PAGE_ALIGN(l)          ALIGN_TO(l, page_size())
index 7bf83403153b18fa76294bbfa32a1463761d719d..3d9189857b155e70215c54772019e753d4223e9a 100644 (file)
@@ -1,11 +1,10 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <stdint.h>
+#include <stdio.h>
 #include <stdlib.h>
 
 #include "format-util.h"
 #include "log.h"
-#include "macro.h"
 #include "memory-util.h"
 #include "mempool.h"
 
index ba588af451ee252c4c6d8f6be7929e95f76ea70f..69fbae18a5fcc55110027fda99eb9ca93bf76bf6 100644 (file)
@@ -1,8 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-#include <stddef.h>
+#include "forward.h"
 
 struct pool;
 
index 1aa5651bcf9c0e6e820dc486ff0f21dc07470765..8c979c7a0ada3499f017389071612ec284e6ec52 100644 (file)
@@ -1,9 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdio.h>
-
-#include "macro.h"
+#include "forward.h"
 
 typedef struct MemStream {
         FILE *f;
index 3aaec1ee248181d6214509eaf204e41deb74a34d..ff95e5e88a5ec9dd470409158462ac88def68668 100644 (file)
@@ -1,10 +1,10 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <linux/audit.h>
+#include <linux/audit.h>        /* IWYU pragma: export */
 
 #if HAVE_AUDIT
-#  include <libaudit.h>
+#  include <libaudit.h>         /* IWYU pragma: export */
 #endif
 
 /* We use _Static_assert() directly here instead of assert_cc()
index c0eb2ca76cda6137c158f8fb9845798ca4ce8e6a..968bcdfb2d7203cc9434909f46c95f41a214c09d 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <linux/bpf.h>
+#include <linux/bpf.h> /* IWYU pragma: export */
 
 /* defined in linux/filter.h */
 /* Unconditional jumps, goto pc + off16 */
index b767186a4a63c761ea6c42f1fb5ece86faf11d81..64f37f5ee86cb3c366c840f3aa82b505e230a82b 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <fcntl.h>
+#include <fcntl.h> /* IWYU pragma: export */
 
 /* This is defined since glibc-2.41. */
 #ifndef F_DUPFD_QUERY
index 1e2f07e55f7955a326c98fc19e316f3ea04b347a..d07042a48abaa9acba2c1a1cd5814092a26ca311 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <linux/fs.h>
+#include <linux/fs.h> /* IWYU pragma: export */
 
 /* Not exposed yet. Defined at fs/ext4/ext4.h */
 #ifndef EXT4_IOC_RESIZE_FS
index 01063fd1935fc12e7a325c6df107387b8e9d1bc0..8a9c82b9b45f65d2bcc1254dd54083adf5bb425e 100644 (file)
@@ -1,10 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <inttypes.h>
-#include <linux/keyctl.h>
+#include <linux/keyctl.h> /* IWYU pragma: export */
 
-#include "macro.h"
+#include "forward.h"
 
 /* From linux/key.h */
 #ifndef KEY_POS_VIEW
index fe54bbc7563edea6ff3eff7318c7f0865336f86a..b5357d4f685735c099f1a0960ae7516b38875b23 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <linux/magic.h>
+#include <linux/magic.h> /* IWYU pragma: export */
 
 /* Not exposed yet (4.20). Defined at ipc/mqueue.c */
 #ifndef MQUEUE_MAGIC
index 29196b1c71559fb26987b34b530554958563a611..b3f79935fec4a2c3211a48ba51a9bf94221bb2d9 100644 (file)
@@ -1,9 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <sys/mman.h>
+#include <sys/mman.h> /* IWYU pragma: export */
 
-#include "macro.h"
+#include "forward.h"
 
 /* since glibc-2.38 */
 #ifndef MFD_NOEXEC_SEAL
index b659a8edc33b74e27b703ea27b9ab55a9d0fad12..e40b751b81d2729edd0173302d8c16c207c47586 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <linux/nsfs.h>
+#include <linux/nsfs.h> /* IWYU pragma: export */
 #include <linux/types.h>
 
 /* Root namespace inode numbers, as per include/linux/proc_ns.h in the kernel source tree, since v3.8:
index 86ea978d4a2900fcb37e352f4c768fe4b41be03e..c5600d9fc67b3cd747b979c53e9463335549a118 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <netinet/in.h>
+#include <netinet/in.h> /* IWYU pragma: export */
 
 /* linux/in.h or netinet/in.h (since glibc-2.32) */
 #ifndef IPPROTO_MPTCP
index 4c81514284e9e9786776b40cefde7a083c53673c..968875e8959676ce41d8cae4dee45c61d03cb3bb 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <linux/types.h>
 #if HAVE_PIDFD_OPEN
-#include <sys/pidfd.h>
+#include <sys/pidfd.h> /* IWYU pragma: export */
 #endif
 
 #ifndef PIDFS_IOCTL_MAGIC
index 690021969e4266b951cf668e7c2414f5046bee5d..61b8c11ed0a0b710313cfc1d907759a91589ca29 100644 (file)
@@ -1,9 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <sys/random.h>
+#include <sys/random.h> /* IWYU pragma: export */
 
-#include "macro.h"
+#include "forward.h"
 
 /* Defined since glibc-2.32. */
 #ifndef GRND_INSECURE
index d8e2b6d3c77b56222af0fa09d8e57f8c2867acc6..d759ed38514b651287db44c8fa66236b76455785 100644 (file)
@@ -2,9 +2,9 @@
 #pragma once
 
 #include <linux/types.h>
-#include <sched.h>
+#include <sched.h>       /* IWYU pragma: export */
 
-#include "macro.h"
+#include "forward.h"
 
 /* 769071ac9f20b6a447410c7eaa55d1a5233ef40c (5.8),
  * defined in sched.h since glibc-2.36. */
index 874e93f37edc62e4363f528867fd5f9d22b527a3..3a81dfff8ad827bea59638424a721564186d856a 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <sys/socket.h>
+#include <sys/socket.h> /* IWYU pragma: export */
 
 /* Supported since kernel v6.5 (5e2ff6704a275be009be8979af17c52361b79b89) */
 #ifndef SO_PASSPIDFD
index 296e39b919d18fab64868ef698b1c52538d4a8cd..b02f0135aeeee6cf2fd35e325e4c830b73b7600a 100644 (file)
@@ -3,19 +3,15 @@
 
 /* Missing glibc definitions to access certain kernel APIs */
 
-#include <errno.h>
-#include <linux/time_types.h>
 #include <signal.h>
 #include <sys/syscall.h>
-#include <sys/types.h>
-#include <sys/wait.h>
 #include <unistd.h>
 
 #ifdef ARCH_MIPS
 #include <asm/sgidefs.h>
 #endif
 
-#include "macro.h"
+#include "forward.h"
 #include "missing_keyctl.h"
 #include "missing_sched.h"
 #include "missing_syscall_def.h"
index c127532249d20e5e57dc503fc2eb11e3e83ad76c..fd8f3e5db5408447e7c724ada607f21dbb186fb3 100644 (file)
@@ -6,7 +6,7 @@
  */
 #pragma once
 
-#include "macro.h"
+#include "forward.h"
 
 /* Note: if this code looks strange, this is because it is derived from the same
  * template as the per-syscall blocks below. */
index 05648779e3f8c31a6ed98e6699f8bcaac93895d9..821df7a9716444b2f8492c3f6bfe7be323ab9973 100644 (file)
@@ -1,9 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <sys/wait.h>
+#include <sys/wait.h> /* IWYU pragma: export */
 
-#include "macro.h"
+#include "forward.h"
 
 /* since glibc-2.36 */
 #ifndef P_PIDFD
index 67c4cefb87b9a0d7946f3406080c873f7fe5a2d9..ead7dbc321f0973f607f72d535521ee19f66c761 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdint.h>
+#include "forward.h"
 
 /* This is currently not exported in the public kernel headers, but the libxfs library code part of xfsprogs
  * defines it as public header */
index fc2d36b33d5621f2c54242139dcd0a74e8b55f40..a3a02b3e4eba90d5531e2e1eb06195c5f91041e1 100644 (file)
@@ -1,8 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-#include <stdbool.h>
-#include <string.h>
+#include <unistd.h>
 
 #include "alloc-util.h"
 #include "btrfs.h"
 #include "format-util.h"
 #include "fs-util.h"
 #include "log.h"
-#include "macro.h"
 #include "mkdir.h"
 #include "path-util.h"
 #include "stat-util.h"
-#include "stdio-util.h"
+#include "string-util.h"
+#include "time-util.h"
 #include "user-util.h"
 
 int mkdirat_safe_internal(
index 471f45b69a0def9a211ef1007b03346d91ccdee9..93af446ebfe85520a6e2996226cd4365b896912e 100644 (file)
@@ -1,10 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <fcntl.h>
-#include <sys/types.h>
-
-#include "time-util.h"
+#include "forward.h"
 
 typedef enum MkdirFlags {
         MKDIR_FOLLOW_SYMLINK  = 1 << 0,
index a66b9169d0aed9a4baec0ea72cc37f0d7bdd8ce2..b7c48709319be7464e19671a5cd6a3c1c8b64fba 100644 (file)
@@ -1,6 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <fcntl.h>
 #include <sys/mount.h>
 
 #include "filesystems.h"
 #include "fs-util.h"
 #include "log.h"
-#include "missing_fcntl.h"
-#include "missing_fs.h"
-#include "missing_syscall.h"
-#include "mkdir.h"
 #include "mountpoint-util.h"
 #include "nulstr-util.h"
 #include "parse-util.h"
 #include "path-util.h"
 #include "stat-util.h"
 #include "stdio-util.h"
+#include "string-util.h"
 #include "strv.h"
-#include "user-util.h"
 
 /* This is the original MAX_HANDLE_SZ definition from the kernel, when the API was introduced. We use that in place of
  * any more currently defined value to future-proof things: if the size is increased in the API headers, and our code
index 9b3f2675aeedf17841a11f6851e5098e9e6a32c3..004d2b2af537379f53337214745aee8b8eb7daa7 100644 (file)
@@ -1,10 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <fcntl.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <sys/types.h>
+#include "forward.h"
 
 /* The limit used for /dev itself. 4MB should be enough since device nodes and symlinks don't
  * consume any space and udev isn't supposed to create regular file either. There's no limit on the
index 2aa286bf3646bb69fb006e612485a2d78e51e343..f7d81cdc7d11c96156148a15969edf8e64ba83b4 100644 (file)
@@ -8,15 +8,14 @@
 #include "fd-util.h"
 #include "fileio.h"
 #include "log.h"
-#include "missing_fs.h"
 #include "missing_magic.h"
 #include "missing_namespace.h"
 #include "missing_sched.h"
-#include "missing_syscall.h"
 #include "mountpoint-util.h"
 #include "namespace-util.h"
 #include "parse-util.h"
 #include "pidfd-util.h"
+#include "pidref.h"
 #include "process-util.h"
 #include "stat-util.h"
 #include "stdio-util.h"
@@ -359,6 +358,14 @@ int pidref_in_same_namespace(PidRef *pid1, PidRef *pid2, NamespaceType type) {
         return fd_inode_same(ns1, ns2);
 }
 
+int in_same_namespace(pid_t pid1, pid_t pid2, NamespaceType type) {
+        assert(pid1 >= 0);
+        assert(pid2 >= 0);
+        return pidref_in_same_namespace(pid1 == 0 ? NULL : &PIDREF_MAKE_FROM_PID(pid1),
+                                        pid2 == 0 ? NULL : &PIDREF_MAKE_FROM_PID(pid2),
+                                        type);
+}
+
 int namespace_get_leader(PidRef *pidref, NamespaceType type, PidRef *ret) {
         int r;
 
index 05ae1a0a95caf88c6c787c3f21fedc48397667e5..e0e857b7a496e75aae11b9691d136da6e096eed2 100644 (file)
@@ -1,9 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <sys/types.h>
-
-#include "pidref.h"
+#include "forward.h"
 
 typedef enum NamespaceType {
         NAMESPACE_CGROUP,
@@ -56,13 +54,7 @@ int is_our_namespace(int fd, NamespaceType type);
 int namespace_is_init(NamespaceType type);
 
 int pidref_in_same_namespace(PidRef *pid1, PidRef *pid2, NamespaceType type);
-static inline int in_same_namespace(pid_t pid1, pid_t pid2, NamespaceType type) {
-        assert(pid1 >= 0);
-        assert(pid2 >= 0);
-        return pidref_in_same_namespace(pid1 == 0 ? NULL : &PIDREF_MAKE_FROM_PID(pid1),
-                                        pid2 == 0 ? NULL : &PIDREF_MAKE_FROM_PID(pid2),
-                                        type);
-}
+int in_same_namespace(pid_t pid1, pid_t pid2, NamespaceType type);
 
 int namespace_get_leader(PidRef *pidref, NamespaceType type, PidRef *ret);
 
index 3a98c5e4448ace41899e4438cc0c4cc3e05735cf..967b585a4d492d3ce6fc8400f2c6bdd8f593fedf 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "alloc-util.h"
 #include "nulstr-util.h"
+#include "set.h"
 #include "string-util.h"
 #include "strv.h"
 
index 6a6c15a2e43ebf664275774c14eeadb81e0bb62b..600667f3c1b3bf8777aa1049e3bd9eb84677dfad 100644 (file)
@@ -1,13 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <errno.h>
-#include <macro.h>
-#include <stdbool.h>
 #include <string.h>
 
-#include "assert-util.h"
-#include "set.h"
+#include "forward.h"
 
 #define NULSTR_FOREACH(i, l)                                    \
         for (typeof(*(l)) *(i) = (l); (i) && *(i); (i) = strchr((i), 0)+1)
index b59a9e5f1b9a046c2bf4218c5c4ee62131464473..9b4ff5ff39c796aa0c3c706c018838262dcf4aea 100644 (file)
@@ -1,5 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
 #include "fileio.h"
 #include "ordered-set.h"
 #include "strv.h"
index 77661ced66a32fe59455df3908b5a3aebf9a5a64..34f585c9bc2c0ae58fcde6e9993030344e906b62 100644 (file)
@@ -1,8 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdio.h>
-
+#include "forward.h"
 #include "hashmap.h"
 
 typedef struct OrderedSet OrderedSet;
index 3187c0bd9f103d1c9fd5bb149a8cd0f4a23040d9..be845e2af7751ed3046e8e6bcedf9c4a944bc350 100644 (file)
@@ -1,24 +1,23 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include <stdlib.h>
+
 #include "alloc-util.h"
 #include "chase.h"
 #include "dirent-util.h"
 #include "env-file.h"
-#include "env-util.h"
 #include "errno-util.h"
 #include "fd-util.h"
-#include "fileio.h"
 #include "fs-util.h"
 #include "glyph-util.h"
 #include "log.h"
-#include "macro.h"
 #include "os-util.h"
-#include "parse-util.h"
 #include "path-util.h"
 #include "stat-util.h"
 #include "string-table.h"
 #include "string-util.h"
 #include "strv.h"
+#include "time-util.h"
 #include "utf8.h"
 #include "xattr-util.h"
 
index 071c9080b7141ae959bdd722a6f73ef7ff0fbb6f..5051a39075c70962b838bd644c2d533ae5cadfd9 100644 (file)
@@ -1,10 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-#include <stdio.h>
-
-#include "time-util.h"
+#include "forward.h"
 
 typedef enum ImageClass {
         IMAGE_MACHINE,
index a10990dbe048b9eaca05643891e354066273b49b..dfe311b043533b8ef950c6b1b35aa10623327aed 100644 (file)
@@ -1,10 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-#include <inttypes.h>
 #include <linux/ipv6.h>
 #include <linux/netfilter/nf_tables.h>
-#include <net/if.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/socket.h>
 #include "extract-word.h"
 #include "locale-util.h"
 #include "log.h"
-#include "macro.h"
 #include "missing_network.h"
 #include "parse-util.h"
 #include "process-util.h"
-#include "stat-util.h"
 #include "string-util.h"
 #include "strv.h"
 
index 0af407b335bb6e3632dd7b02adde3154e347eb70..4c251d2e96d290bf8a0d2da0da8bc703f99f8a40 100644 (file)
@@ -1,13 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <inttypes.h>
-#include <limits.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "macro.h"
+#include "forward.h"
 
 typedef unsigned long loadavg_t;
 
index 2fd568743aedf6eb6a4fcc5d9ed07d27ec000175..dd23d3f6ab09276b639a05d31c15f761d5750287 100644 (file)
@@ -1,8 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <fnmatch.h>
-#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -15,7 +13,6 @@
 #include "fs-util.h"
 #include "glob-util.h"
 #include "log.h"
-#include "macro.h"
 #include "path-util.h"
 #include "stat-util.h"
 #include "string-util.h"
index fabb0eac88c2ba1863cf73b57e3cf5b6371e0229..1cc1fce1e09810e3d996f7a8c042e21d2d1fc5d8 100644 (file)
@@ -1,11 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-#include <stddef.h>
-
-#include "macro.h"
-#include "time-util.h"
+#include "forward.h"
 
 #define PATH_SPLIT_BIN(x) x "sbin:" x "bin"
 #define PATH_SPLIT_BIN_NULSTR(x) x "sbin\0" x "bin\0"
index 28ad0768775fe62a54959348715de4242d1ae241..ff2560c40440afec9d9a5bda5ae06f5f1d76349c 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdint.h>
+#include "forward.h"
 
 /*
  * For details about the file format see RFC:
index b2625d0bb27f08b89308ade877969135d4444d61..c205b10b09c019a25e45016d41eebb1cfd2f0c67 100644 (file)
@@ -1,6 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include "alloc-util.h"
 #include "parse-util.h"
 #include "percent-util.h"
 #include "string-util.h"
index dd70d59dba09f002a557fa35f8e33ec2266f15c7..60b0d4a9ef50aa7eac0d9d58ef9c3e99481a6390 100644 (file)
@@ -1,11 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <errno.h>
-#include <inttypes.h>
-#include <limits.h>
-
-#include "macro.h"
+#include "forward.h"
 
 int parse_percent_unbounded(const char *p);
 int parse_percent(const char *p);
index 54724a40b06a5eceb9596fff2b627bcdbd5759a2..f53a94f2d3e3484e775c5c43f312234aa97ce466 100644 (file)
@@ -7,17 +7,14 @@
 #include "errno-util.h"
 #include "fd-util.h"
 #include "fileio.h"
-#include "log.h"
-#include "macro.h"
-#include "memory-util.h"
 #include "missing_fs.h"
 #include "missing_magic.h"
 #include "mountpoint-util.h"
 #include "parse-util.h"
-#include "path-util.h"
 #include "pidfd-util.h"
 #include "process-util.h"
 #include "stat-util.h"
+#include "stdio-util.h"
 #include "string-util.h"
 
 static int have_pidfs = -1;
index c20de6df6762443dc76af1c8fce156d7599e85e9..774f97018a71a433df5a29b532d7a20efd61e53c 100644 (file)
@@ -1,11 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "missing_pidfd.h"
-#include "missing_syscall.h"
+#include "forward.h"
+#include "missing_pidfd.h"      /* IWYU pragma: export */
+#include "missing_syscall.h"    /* IWYU pragma: export */
 
 int pidfd_get_namespace(int fd, unsigned long ns_type_cmd);
 
index 47ecfaacdef4465b808078c518f2411d3bc63bfc..eeccc537c90c1f9e2b340a54686f1125e4bfa5a7 100644 (file)
@@ -1,15 +1,17 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include "alloc-util.h"
 #include "errno-util.h"
 #include "fd-util.h"
+#include "format-util.h"
+#include "hash-funcs.h"
 #include "log.h"
-#include "missing_syscall.h"
 #include "missing_wait.h"
 #include "parse-util.h"
 #include "pidfd-util.h"
 #include "pidref.h"
 #include "process-util.h"
-#include "signal-util.h"
+#include "siphash24.h"
 
 int pidref_acquire_pidfd_id(PidRef *pidref) {
         int r;
index 6084f9cf89fe97f211c5b865e4b5a55fe914ceef..724871842b92535b43a8afd8ce86035d3658beb8 100644 (file)
@@ -1,11 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <errno.h>
 #include <signal.h>
 
-#include "macro.h"
-#include "memory-util.h"
+#include "forward.h"
 
 /* An embeddable structure carrying a reference to a process. Supposed to be used when tracking processes
  * continuously. This combines a PID, a modern Linux pidfd and the 64bit inode number of the pidfd into one
index ed9b33e59de05efc062c30f03056fd7035d0ced4..157c081eb45c0ee550290ee6a8e9bbd51158c855 100644 (file)
  * The underlying algorithm used in this implementation is a Heap.
  */
 
-#include <errno.h>
-#include <stdlib.h>
-
 #include "alloc-util.h"
-#include "hashmap.h"
 #include "prioq.h"
 
 struct prioq_item {
index 204ba54faeeed03ddb9d1fe6372e062940a9bb87..97b4f40b4ac00473a8f66a434469e981c475ef86 100644 (file)
@@ -1,10 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-
-#include "hashmap.h"
-#include "macro.h"
+#include "forward.h"
 
 typedef struct Prioq Prioq;
 
index 7f8e32f679520f7bff852ece6971f10cfa528da3..fd9cfbae283ee6b92bd2eb9ff269a0ea415b2efc 100644 (file)
@@ -1,15 +1,13 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <stdbool.h>
-#include <stddef.h>
+#include <stdlib.h>
 
 #include "alloc-util.h"
-#include "efivars.h"
 #include "extract-word.h"
 #include "fileio.h"
 #include "getopt-defs.h"
 #include "initrd-util.h"
-#include "macro.h"
+#include "log.h"
 #include "parse-util.h"
 #include "proc-cmdline.h"
 #include "process-util.h"
@@ -415,3 +413,14 @@ int proc_cmdline_get_key_many_internal(ProcCmdlineFlags flags, ...) {
 
         return r;
 }
+
+bool proc_cmdline_value_missing(const char *key, const char *value) {
+        assert(key);
+
+        if (!value) {
+                log_warning("Missing argument for %s= kernel command line switch, ignoring.", key);
+                return true;
+        }
+
+        return false;
+}
index 0e7039ed434773da0697bfd6afb1eb74c240be77..8eb905de3d6894c95e76c87eab2efe5ea7ce0580 100644 (file)
@@ -1,9 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-
-#include "log.h"
+#include "forward.h"
 
 typedef enum ProcCmdlineFlags {
         PROC_CMDLINE_STRIP_RD_PREFIX    = 1 << 0, /* automatically strip "rd." prefix if it is set (and we are in the initrd, since otherwise we'd not consider it anyway) */
@@ -31,11 +29,4 @@ char* proc_cmdline_key_startswith(const char *s, const char *prefix);
 bool proc_cmdline_key_streq(const char *x, const char *y);
 
 /* A little helper call, to be used in proc_cmdline_parse_t callbacks */
-static inline bool proc_cmdline_value_missing(const char *key, const char *value) {
-        if (!value) {
-                log_warning("Missing argument for %s= kernel command line switch, ignoring.", key);
-                return true;
-        }
-
-        return false;
-}
+bool proc_cmdline_value_missing(const char *key, const char *value);
index 945d95d7d66cce49c4a26e8378b2c94244a92924..e05329b4069f275c5889dff2f2c3d9ea339e7dd5 100644 (file)
@@ -1,18 +1,12 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <ctype.h>
-#include <errno.h>
-#include <limits.h>
 #include <linux/oom.h>
 #include <pthread.h>
 #include <spawn.h>
-#include <stdbool.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <sys/mount.h>
 #include <sys/personality.h>
 #include <sys/prctl.h>
-#include <sys/types.h>
 #include <sys/wait.h>
 #include <syslog.h>
 #include <threads.h>
@@ -29,7 +23,6 @@
 #include "cgroup-util.h"
 #include "dirent-util.h"
 #include "env-file.h"
-#include "env-util.h"
 #include "errno-util.h"
 #include "escape.h"
 #include "fd-util.h"
@@ -40,7 +33,6 @@
 #include "iovec-util.h"
 #include "locale-util.h"
 #include "log.h"
-#include "macro.h"
 #include "memory-util.h"
 #include "missing_sched.h"
 #include "missing_syscall.h"
@@ -50,6 +42,7 @@
 #include "parse-util.h"
 #include "path-util.h"
 #include "pidfd-util.h"
+#include "pidref.h"
 #include "process-util.h"
 #include "raw-clone.h"
 #include "rlimit-util.h"
 #include "stdio-util.h"
 #include "string-table.h"
 #include "string-util.h"
-#include "terminal-util.h"
 #include "time-util.h"
 #include "user-util.h"
-#include "utf8.h"
 
 /* The kernel limits userspace processes to TASK_COMM_LEN (16 bytes), but allows higher values for its own
  * workers, e.g. "kworker/u9:3-kcryptd/253:0". Let's pick a fixed smallish limit that will work for the kernel.
@@ -1364,6 +1355,18 @@ int pid_compare_func(const pid_t *a, const pid_t *b) {
         return CMP(*a, *b);
 }
 
+bool nice_is_valid(int n) {
+        return n >= PRIO_MIN && n < PRIO_MAX;
+}
+
+bool sched_policy_is_valid(int i) {
+        return IN_SET(i, SCHED_OTHER, SCHED_BATCH, SCHED_IDLE, SCHED_FIFO, SCHED_RR);
+}
+
+bool sched_priority_is_valid(int i) {
+        return i >= 0 && i <= sched_get_priority_max(SCHED_RR);
+}
+
 /* The cached PID, possible values:
  *
  *     == UNSET [0]  â†’ cache not initialized yet
index 9ae36cf60901e847e458d4a0563cd97b13956b2a..c636b6d14a8dfe93b3b80c6024eb1ff3befa5648 100644 (file)
@@ -1,23 +1,12 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <errno.h>
-#include <sched.h>
 #include <signal.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/resource.h>
-#include <sys/types.h>
-
-#include "alloc-util.h"
-#include "assert-util.h"
+
 #include "fileio.h"
 #include "format-util.h"
-#include "macro.h"
-#include "pidref.h"
-#include "time-util.h"
+#include "forward.h"
+#include "string-util.h"
 
 #define procfs_file_alloca(pid, field)                                  \
         ({                                                              \
@@ -147,17 +136,10 @@ void valgrind_summary_hack(void);
 
 int pid_compare_func(const pid_t *a, const pid_t *b);
 
-static inline bool nice_is_valid(int n) {
-        return n >= PRIO_MIN && n < PRIO_MAX;
-}
+bool nice_is_valid(int n);
 
-static inline bool sched_policy_is_valid(int i) {
-        return IN_SET(i, SCHED_OTHER, SCHED_BATCH, SCHED_IDLE, SCHED_FIFO, SCHED_RR);
-}
-
-static inline bool sched_priority_is_valid(int i) {
-        return i >= 0 && i <= sched_get_priority_max(SCHED_RR);
-}
+bool sched_policy_is_valid(int i) _const_;
+bool sched_priority_is_valid(int i) _const_;
 
 #define PID_AUTOMATIC ((pid_t) INT_MIN) /* special value indicating "acquire pid from connection peer" */
 
index 1b09905515d0373f48961992037e9be007cfaf65..47f460e4f1b533cb76baf090ef00b865c85b3e65 100644 (file)
@@ -1,18 +1,17 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
-#include "constants.h"
+#include "extract-word.h"
 #include "fd-util.h"
 #include "fileio.h"
-#include "log.h"
 #include "parse-util.h"
 #include "process-util.h"
 #include "procfs-util.h"
 #include "stdio-util.h"
 #include "string-util.h"
+#include "time-util.h"
 
 int procfs_get_pid_max(uint64_t *ret) {
         _cleanup_free_ char *value = NULL;
index eb8c7738b166d716913b4073436d7b57b587b14e..a0de848c82de53fa17dee679cfa276d64b00812c 100644 (file)
@@ -1,9 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <inttypes.h>
-
-#include "time-util.h"
+#include "forward.h"
 
 int procfs_get_pid_max(uint64_t *ret);
 int procfs_get_threads_max(uint64_t *ret);
index 1e4de3d8a711d0bd34328f5b508e3885864ea563..df1ccbc1b20fb619e6fe6def58096937b676657d 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <stdio.h>
 #include <threads.h>
-#include <unistd.h>
 
 #include "alloc-util.h"
 #include "errno-util.h"
@@ -11,7 +10,6 @@
 #include "fileio.h"
 #include "parse-util.h"
 #include "psi-util.h"
-#include "stat-util.h"
 #include "string-util.h"
 #include "strv.h"
 
index bf8f4fe51c2b7f8726d13eee74c03674ad80cce6..3029e091a4132d4ff52fb6e37e8aea78476b5006 100644 (file)
@@ -1,10 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-
+#include "forward.h"
 #include "parse-util.h"
-#include "time-util.h"
 
 typedef enum PressureType {
         PRESSURE_TYPE_SOME,
index 4707f5503aa0b099293a521e68cce7ac950234ff..362944efc8e55db63c56745f16b95d2be8e5ea04 100644 (file)
@@ -1,9 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <pthread.h>
+#include <pthread.h> /* IWYU pragma: export */
 
-#include "assert-util.h"
+#include "forward.h"
 
 static inline pthread_mutex_t* pthread_mutex_lock_assert(pthread_mutex_t *mutex) {
         assert_se(pthread_mutex_lock(mutex) == 0);
index c63819e42a2fe77b397cbdb02cf4cb64831fc2ea..486a523bc52c88370979b6c99354efa293f8f633 100644 (file)
@@ -1,28 +1,20 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include <elf.h>
-#include <errno.h>
 #include <fcntl.h>
 #include <linux/random.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdlib.h>
 #include <string.h>
 #include <sys/auxv.h>
 #include <sys/ioctl.h>
-#include <sys/time.h>
 #include <threads.h>
 
 #include "alloc-util.h"
-#include "env-util.h"
-#include "errno-util.h"
 #include "fd-util.h"
 #include "fileio.h"
 #include "io-util.h"
 #include "iovec-util.h"
 #include "log.h"
 #include "missing_random.h"
-#include "missing_syscall.h"
 #include "parse-util.h"
 #include "pidfd-util.h"
 #include "process-util.h"
index 587ca1c28325dc67593a855e3ff14e5745a0c1df..28bdb583c0f6c14a7aa30d0af8df75aa6a5f1849 100644 (file)
@@ -1,12 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <sys/uio.h>
-
-#include "macro.h"
+#include "forward.h"
 
 void random_bytes(void *p, size_t n) _nonnull_if_nonzero_(1, 2); /* Returns random bytes suitable for most uses, but may be insecure sometimes. */
 int crypto_random_bytes(void *p, size_t n) _nonnull_if_nonzero_(1, 2); /* Returns secure random bytes after waiting for the RNG to initialize. */
index 351fcac3bdd27dfa6dfd113f8ac7bb05bf118f28..48ad08f3b670964f6c26b058ce408c47c9633021 100644 (file)
@@ -1,11 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <limits.h>
-#include <sys/time.h>
-
-#include "assert-util.h"
-#include "macro.h"
 #include "ratelimit.h"
+#include "time-util.h"
 
 /* Modelled after Linux' lib/ratelimit.c by Dave Young
  * <hidave.darkstar@gmail.com>, which is licensed GPLv2. */
index 7801ef4270aee7ed43f7d68a02f7bfb6558d146e..321cfbbb44633b173e8effe5edba889b0b47dcb8 100644 (file)
@@ -1,9 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-
-#include "time-util.h"
+#include "forward.h"
 
 typedef struct RateLimit {
         usec_t interval; /* Keep those two fields first so they can be initialized easily: */
index 666d17d3aad7663a268f15906413866b51c3d9ec..36945265473856c1890eafb0d8e94a5942b5982e 100644 (file)
@@ -1,12 +1,14 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include <sys/stat.h>
+
 #include "alloc-util.h"
 #include "dirent-util.h"
 #include "fd-util.h"
-#include "fileio.h"
 #include "fs-util.h"
 #include "log.h"
 #include "mountpoint-util.h"
+#include "path-util.h"
 #include "recurse-dir.h"
 #include "sort-util.h"
 
index 82af043b15dc421178b5001672c007448e321849..5e9548b04668cf5638e4db7664372b334f2c78cd 100644 (file)
@@ -2,11 +2,8 @@
 #pragma once
 
 #include <dirent.h>
-#include <limits.h>
 
-#include "errno-list.h"
-#include "macro.h"
-#include "stat-util.h"
+#include "forward.h"
 
 typedef enum RecurseDirFlags {
         /* Interpreted by readdir_all() */
index 4813ac3d2ba82e793b1a510805181490d3bd55c9..1ff79dd84a6ca9d1473ad9738b436e117f164009 100644 (file)
@@ -1,11 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-#include <stddef.h>
-#include <stdlib.h>
-
 #include "alloc-util.h"
-#include "macro.h"
 #include "replace-var.h"
 #include "string-util.h"
 
index 8b9b2aa5ba15d1cffd6680c6ba1baebc160fed31..abaa57b503defcf68de2484bbbf48f1ad0ff8034 100644 (file)
@@ -1,4 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include "forward.h"
+
 char* replace_var(const char *text, char *(*lookup)(const char *variable, void *userdata), void *userdata);
index d5763b5f9e28a70aad38b804520fe764c1c932f8..803eaa09b267f34a57055a2e8b6ca0a5aa97ad7c 100644 (file)
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-
 #include "alloc-util.h"
 #include "errno-util.h"
 #include "extract-word.h"
@@ -9,7 +7,6 @@
 #include "fileio.h"
 #include "format-util.h"
 #include "log.h"
-#include "macro.h"
 #include "parse-util.h"
 #include "process-util.h"
 #include "rlimit-util.h"
index dd1fef439689db8d349bf1b5c15eeeecbe0c92b5..52ec8bd3203dee8691b34b2185c6512ac6d07820 100644 (file)
@@ -1,10 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <sys/resource.h>
-#include <sys/types.h>
+#include <sys/resource.h>       /* IWYU pragma: export */
 
-#include "macro.h"
+#include "forward.h"
 
 #define _RLIMIT_MAX RLIMIT_NLIMITS
 
index ba900fed1e7589d94652247085e9a3e2014328a7..54c797e742d8a861a94258f58647258e725c9fa7 100644 (file)
@@ -1,9 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <errno.h>
-
-#include "macro.h"
+#include "forward.h"
 
 typedef enum RuntimeScope {
         RUNTIME_SCOPE_SYSTEM,           /* for the system */
index 9dd7bd403dbc22c74884aaa5111a545fd0696b54..e6ce91c752bff0652a2ce8ff8993a398b2c0fdb3 100644 (file)
@@ -1,9 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "extract-word.h"
+#include "forward.h"
 #include "hashmap.h"
-#include "macro.h"
 
 #define set_free_and_replace(a, b)              \
         free_and_replace_full(a, b, set_free)
index c4c2e85cec3c7464d4ac8e8e203697c81b9a8c03..31e535d4d291e71fd317a0b07363cbe21c1ef143 100644 (file)
@@ -1,12 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
 #include "hexdecoct.h"
-#include "macro.h"
 #include "sha256.h"
+#include "string-util.h"
 
 int sha256_fd(int fd, uint64_t max_size, uint8_t ret[static SHA256_DIGEST_SIZE]) {
         struct sha256_ctx ctx;
@@ -50,3 +49,7 @@ int parse_sha256(const char *s, uint8_t ret[static SHA256_DIGEST_SIZE]) {
         memcpy(ret, data, size);
         return 0;
 }
+
+bool sha256_is_valid(const char *s) {
+        return s && in_charset(s, HEXDIGITS) && (strlen(s) == SHA256_DIGEST_SIZE * 2);
+}
index 95bac1bc1dbd8a5dc90a0fb5eb5a5b478abce4a5..3711292958afae7cb7522ca33dddc4106b97d66b 100644 (file)
@@ -2,15 +2,11 @@
 
 #pragma once
 
-#include <stdint.h>
-
-#include "sha256-fundamental.h"
-#include "string-util.h"
+#include "forward.h"
+#include "sha256-fundamental.h" /* IWYU pragma: export */
 
 int sha256_fd(int fd, uint64_t max_size, uint8_t ret[static SHA256_DIGEST_SIZE]);
 
 int parse_sha256(const char *s, uint8_t res[static SHA256_DIGEST_SIZE]);
 
-static inline bool sha256_is_valid(const char *s) {
-        return s && in_charset(s, HEXDIGITS) && (strlen(s) == SHA256_DIGEST_SIZE * 2);
-}
+bool sha256_is_valid(const char *s);
index 9adba5eb72bc135ef3444110109927bc069093ec..a530476d537592b1139335fbb478c0d6506ce307 100644 (file)
@@ -1,15 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <signal.h>
-#include <stddef.h>
 #include <sys/mman.h>
 
-#include "log.h"
-#include "macro.h"
 #include "memory-util.h"
-#include "missing_syscall.h"
-#include "process-util.h"
 #include "sigbus.h"
 #include "signal-util.h"
 
index a40b1a87aa061a82d441f317d6879e698eb3a40c..cf7593072ddde03ba3f33e10ef4adcf576755cab 100644 (file)
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include "forward.h"
+
 void sigbus_install(void);
 void sigbus_reset(void);
 
index f5afe34307605c9066553ebba88a1f6d46d41542..4080d96792fab14221eca4e5e877f50d53108b2c 100644 (file)
@@ -1,11 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-#include <stdarg.h>
 #include <threads.h>
 
 #include "errno-util.h"
-#include "macro.h"
 #include "missing_syscall.h"
 #include "parse-util.h"
 #include "signal-util.h"
index d64d50312435cf62aa4c8fb82673ba393d75d229..5a253583a7665b93e23e7c10fb649e45a03f30ee 100644 (file)
@@ -1,10 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <signal.h>
+#include <signal.h>     /* IWYU pragma: export */
 
-#include "assert-util.h"
-#include "macro.h"
+#include "forward.h"
 
 int reset_all_signal_handlers(void);
 int reset_signal_mask(void);
index b614ecf11a1d06798cb9cc49622fb7f91656a37f..72d6bbe4f0cb7716cceeb9d8b78b929d8c296021 100644 (file)
@@ -21,8 +21,8 @@
 
 #include <stdio.h>
 
-#include "macro.h"
 #include "siphash24.h"
+#include "string-util.h"
 #include "unaligned.h"
 
 static uint64_t rotate_left(uint64_t x, uint8_t b) {
@@ -152,6 +152,10 @@ void siphash24_compress(const void *_in, size_t inlen, struct siphash *state) {
         }
 }
 
+void siphash24_compress_string(const char *in, struct siphash *state) {
+        siphash24_compress_safe(in, strlen_ptr(in), state);
+}
+
 uint64_t siphash24_finalize(struct siphash *state) {
         uint64_t b;
 
@@ -199,3 +203,7 @@ uint64_t siphash24(const void *in, size_t inlen, const uint8_t k[static 16]) {
 
         return siphash24_finalize(&state);
 }
+
+uint64_t siphash24_string(const char *s, const uint8_t k[static 16]) {
+        return siphash24(s, strlen(s) + 1, k);
+}
index 2ef4a0498a847645f6a04013a86dbffce4ef407b..61d83233a58f07fa36963fdd2bb766da8e27eb95 100644 (file)
@@ -2,13 +2,7 @@
 
 #pragma once
 
-#include <inttypes.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "string-util.h"
-#include "time-util.h"
+#include "forward.h"
 
 struct siphash {
         uint64_t v0;
@@ -41,14 +35,10 @@ static inline void siphash24_compress_safe(const void *in, size_t inlen, struct
         siphash24_compress(in, inlen, state);
 }
 
-static inline void siphash24_compress_string(const char *in, struct siphash *state) {
-        siphash24_compress_safe(in, strlen_ptr(in), state);
-}
+void siphash24_compress_string(const char *in, struct siphash *state);
 
 uint64_t siphash24_finalize(struct siphash *state);
 
 uint64_t siphash24(const void *in, size_t inlen, const uint8_t k[static 16]);
 
-static inline uint64_t siphash24_string(const char *s, const uint8_t k[static 16]) {
-        return siphash24(s, strlen(s) + 1, k);
-}
+uint64_t siphash24_string(const char *s, const uint8_t k[static 16]);
index 919884ba472ae34e68990662ab7e8578246f1606..9cce0e129a33a1eeb99aea8d642fafc1bd05c1b8 100644 (file)
@@ -1,8 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <arpa/inet.h>
-#include <errno.h>
-#include <limits.h>
+#include <fcntl.h>
 #include <linux/if.h>
 #include <linux/if_arp.h>
 #include <mqueue.h>
@@ -10,10 +8,7 @@
 #include <netdb.h>
 #include <netinet/ip.h>
 #include <poll.h>
-#include <stddef.h>
-#include <stdint.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <sys/ioctl.h>
 #include <unistd.h>
 
 #include "errno-util.h"
 #include "escape.h"
 #include "fd-util.h"
-#include "fileio.h"
 #include "format-ifname.h"
+#include "format-util.h"
+#include "in-addr-util.h"
 #include "io-util.h"
 #include "log.h"
 #include "memory-util.h"
 #include "parse-util.h"
 #include "path-util.h"
+#include "pidref.h"
 #include "process-util.h"
 #include "random-util.h"
 #include "socket-util.h"
+#include "sparse-endian.h"
 #include "string-table.h"
 #include "string-util.h"
 #include "strv.h"
 #include "sysctl-util.h"
-#include "user-util.h"
-#include "utf8.h"
 
 #if ENABLE_IDN
 #  define IDN_FLAGS NI_IDN
@@ -1688,7 +1684,7 @@ int socket_set_option(int fd, int af, int opt_ipv4, int opt_ipv6, int val) {
 }
 
 int socket_get_mtu(int fd, int af, size_t *ret) {
-        int mtu, r;
+        int mtu = 0, r; /* Avoid maybe-uninitialized false positive */
 
         if (af == AF_UNSPEC) {
                 af = socket_get_family(fd);
index dea93dbde89d34e9bcfb9d86995030cbcb5234a9..a5a1d8775da5d861fdddd0b05a42845d649c30aa 100644 (file)
@@ -1,27 +1,19 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <inttypes.h>
 #include <linux/if_ether.h>
 #include <linux/if_infiniband.h>
 #include <linux/if_packet.h>
 #include <linux/netlink.h>
 #include <linux/vm_sockets.h>
 #include <netinet/in.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <string.h>
 #include <sys/socket.h>
-#include <sys/types.h>
 #include <sys/un.h>
 
-#include "errno-util.h"
-#include "in-addr-util.h"
-#include "macro.h"
+#include "forward.h"
+#include "memory-util.h"
 #include "missing_network.h"
 #include "missing_socket.h"
-#include "pidref.h"
-#include "sparse-endian.h"
 
 union sockaddr_union {
         /* The minimal, abstract version */
@@ -261,7 +253,7 @@ static inline int getsockopt_int(int fd, int level, int optname, int *ret) {
         socklen_t sl = sizeof(v);
 
         if (getsockopt(fd, level, optname, &v, &sl) < 0)
-                return negative_errno();
+                return -errno;
         if (sl != sizeof(v))
                 return -EIO;
 
index 59329dff31cfee6fcb47b36e2604f37386ddf2e9..1adbba8fcf4fb41dbe602736db3ed0959da153d3 100644 (file)
@@ -1,5 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include <stdlib.h>
+
 #include "alloc-util.h"
 #include "sort-util.h"
 
@@ -28,6 +30,40 @@ void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
         return NULL;
 }
 
+void* bsearch_safe(const void *key, const void *base, size_t nmemb, size_t size, comparison_fn_t compar) {
+        /**
+        * Normal bsearch requires base to be nonnull. Here were require
+        * that only if nmemb > 0.
+        */
+
+        if (nmemb <= 0)
+                return NULL;
+
+        assert(base);
+        return bsearch(key, base, nmemb, size, compar);
+}
+
+void qsort_safe(void *base, size_t nmemb, size_t size, comparison_fn_t compar) {
+        /**
+         * Normal qsort requires base to be nonnull. Here were require
+         * that only if nmemb > 0.
+         */
+
+        if (nmemb <= 1)
+                return;
+
+        assert(base);
+        qsort(base, nmemb, size, compar);
+}
+
+void qsort_r_safe(void *base, size_t nmemb, size_t size, comparison_userdata_fn_t compar, void *userdata) {
+        if (nmemb <= 1)
+                return;
+
+        assert(base);
+        qsort_r(base, nmemb, size, compar, userdata);
+}
+
 int cmp_int(const int *a, const int *b) {
         return CMP(*a, *b);
 }
index 2820f2327c3757eaed08b7772e11ab999fe553b3..8b6d2aaddf38f6f758bfe804595c6610090852df 100644 (file)
@@ -1,16 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdlib.h>
-
-#include "assert-util.h"
-#include "macro.h"
-
-/* This is the same as glibc's internal __compar_d_fn_t type. glibc exports a public comparison_fn_t, for the
- * external type __compar_fn_t, but doesn't do anything similar for __compar_d_fn_t. Let's hence do that
- * ourselves, picking a name that is obvious, but likely enough to not clash with glibc's choice of naming if
- * they should ever add one. */
-typedef int (*comparison_userdata_fn_t)(const void *, const void *, void *);
+#include "forward.h"
 
 void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
                  comparison_userdata_fn_t compar, void *arg);
@@ -22,18 +13,7 @@ void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
                 (typeof((b)[0])*) xbsearch_r((const void*) _k, (b), (n), sizeof((b)[0]), (comparison_userdata_fn_t) _func_, userdata); \
         })
 
-/**
- * Normal bsearch requires base to be nonnull. Here were require
- * that only if nmemb > 0.
- */
-static inline void* bsearch_safe(const void *key, const void *base,
-                                 size_t nmemb, size_t size, comparison_fn_t compar) {
-        if (nmemb <= 0)
-                return NULL;
-
-        assert(base);
-        return bsearch(key, base, nmemb, size, compar);
-}
+void* bsearch_safe(const void *key, const void *base, size_t nmemb, size_t size, comparison_fn_t compar);
 
 #define typesafe_bsearch(k, b, n, func)                                 \
         ({                                                              \
@@ -42,33 +22,17 @@ static inline void* bsearch_safe(const void *key, const void *base,
                 (typeof((b)[0])*) bsearch_safe((const void*) _k, (b), (n), sizeof((b)[0]), (comparison_fn_t) _func_); \
         })
 
-/**
- * Normal qsort requires base to be nonnull. Here were require
- * that only if nmemb > 0.
- */
-static inline void _qsort_safe(void *base, size_t nmemb, size_t size, comparison_fn_t compar) {
-        if (nmemb <= 1)
-                return;
-
-        assert(base);
-        qsort(base, nmemb, size, compar);
-}
+void qsort_safe(void *base, size_t nmemb, size_t size, comparison_fn_t compar);
 
 /* A wrapper around the above, but that adds typesafety: the element size is automatically derived from the type and so
  * is the prototype for the comparison function */
 #define typesafe_qsort(p, n, func)                                      \
         ({                                                              \
                 int (*_func_)(const typeof((p)[0])*, const typeof((p)[0])*) = func; \
-                _qsort_safe((p), (n), sizeof((p)[0]), (comparison_fn_t) _func_); \
+                qsort_safe((p), (n), sizeof((p)[0]), (comparison_fn_t) _func_); \
         })
 
-static inline void qsort_r_safe(void *base, size_t nmemb, size_t size, comparison_userdata_fn_t compar, void *userdata) {
-        if (nmemb <= 1)
-                return;
-
-        assert(base);
-        qsort_r(base, nmemb, size, compar, userdata);
-}
+void qsort_r_safe(void *base, size_t nmemb, size_t size, comparison_userdata_fn_t compar, void *userdata);
 
 #define typesafe_qsort_r(p, n, func, userdata)                          \
         ({                                                              \
index c795d3da8f2ff26188e4258322a3805d23f232e3..d66e77afc2e0ddf6e07e28240177d61773c29633 100644 (file)
@@ -24,7 +24,8 @@
 
 #include <byteswap.h>
 #include <endian.h>
-#include <stdint.h>
+
+#include "forward.h"
 
 #ifdef __CHECKER__
 #define __sd_bitwise __attribute__((__bitwise__))
index f3a1db5ed7ead9094fea16e984515da71cc11bc2..237d8e0853740f92197010da3be62da41131a38a 100644 (file)
@@ -1,10 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <fcntl.h>
-#include <sched.h>
 #include <sys/statvfs.h>
-#include <sys/types.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
 #include "dirent-util.h"
 #include "errno-util.h"
 #include "fd-util.h"
-#include "fileio.h"
 #include "filesystems.h"
 #include "fs-util.h"
 #include "hash-funcs.h"
 #include "log.h"
-#include "macro.h"
-#include "missing_fs.h"
 #include "missing_magic.h"
 #include "mountpoint-util.h"
-#include "nulstr-util.h"
-#include "parse-util.h"
+#include "path-util.h"
+#include "siphash24.h"
 #include "stat-util.h"
 #include "string-util.h"
+#include "time-util.h"
 
 static int verify_stat_at(
                 int fd,
@@ -499,6 +494,13 @@ int xstatfsat(int dir_fd, const char *path, struct statfs *ret) {
         return RET_NERRNO(fstatfs(dir_fd, ret));
 }
 
+usec_t statx_timestamp_load(const struct statx_timestamp *ts) {
+        return timespec_load(&(const struct timespec) { .tv_sec = ts->tv_sec, .tv_nsec = ts->tv_nsec });
+}
+nsec_t statx_timestamp_load_nsec(const struct statx_timestamp *ts) {
+        return timespec_load_nsec(&(const struct timespec) { .tv_sec = ts->tv_sec, .tv_nsec = ts->tv_nsec });
+}
+
 void inode_hash_func(const struct stat *q, struct siphash *state) {
         siphash24_compress_typesafe(q->st_dev, state);
         siphash24_compress_typesafe(q->st_ino, state);
index 2c5f7b9e93a8fcab678f7414095a9c00cb8af4ad..1087c264f0a86b7c0b17b7977097c80abb758332 100644 (file)
@@ -1,18 +1,10 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <fcntl.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <sys/stat.h>
-#include <sys/statfs.h>
-#include <sys/types.h>
-#include <sys/vfs.h>
-
-#include "fs-util.h"
-#include "macro.h"
-#include "siphash24.h"
-#include "time-util.h"
+#include <sys/stat.h>           /* IWYU pragma: export */
+#include <sys/statfs.h>         /* IWYU pragma: export */
+
+#include "forward.h"
 
 int stat_verify_regular(const struct stat *st);
 int verify_regular_at(int fd, const char *path, bool follow);
@@ -93,12 +85,8 @@ bool statx_mount_same(const struct statx *a, const struct statx *b);
 
 int xstatfsat(int dir_fd, const char *path, struct statfs *ret);
 
-static inline usec_t statx_timestamp_load(const struct statx_timestamp *ts) {
-        return timespec_load(&(const struct timespec) { .tv_sec = ts->tv_sec, .tv_nsec = ts->tv_nsec });
-}
-static inline nsec_t statx_timestamp_load_nsec(const struct statx_timestamp *ts) {
-        return timespec_load_nsec(&(const struct timespec) { .tv_sec = ts->tv_sec, .tv_nsec = ts->tv_nsec });
-}
+usec_t statx_timestamp_load(const struct statx_timestamp *ts);
+nsec_t statx_timestamp_load_nsec(const struct statx_timestamp *ts);
 
 void inode_hash_func(const struct stat *q, struct siphash *state);
 int inode_compare_func(const struct stat *a, const struct stat *b);
index f8006c86ddc144fe10e64e856145d0e761643fae..c39a1b381649ad9147de284790f02bf1da6e6c1b 100644 (file)
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include "memory-util.h"
 #include "static-destruct.h"
 
 void static_destruct_impl(const StaticDestructor *start, const StaticDestructor *end) {
index aaafbbc478bb8436a28e19f5797f41b2f1a098cb..3502d192e2f9f056f0d3e3a598e0c37feb06cf65 100644 (file)
@@ -2,10 +2,7 @@
 
 #pragma once
 
-#include <errno.h>
-
-#include "macro.h"
-#include "memory-util.h"
+#include "forward.h"
 
 typedef void (*free_func_t)(void *p);
 
index bd5871821c46c77cd9b925f530d7e07bfdbed42f..54640314346c724886eda347f990be588b7d0ff7 100644 (file)
@@ -2,12 +2,9 @@
 #pragma once
 
 #include <printf.h>
-#include <stdarg.h>
 #include <stdio.h>
-#include <sys/types.h>
 
-#include "assert-util.h"
-#include "macro.h"
+#include "forward.h"
 
 _printf_(3, 4)
 static inline char* snprintf_ok(char *buf, size_t len, const char *format, ...) {
index a53d73359489f5d4a41be6a3bc6f64471415d1e7..c2342e67a22bdc4dd430c5d36e8958fc49cbddc6 100644 (file)
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-#include <stdlib.h>
 #include <string.h>
 
 #include "alloc-util.h"
index 143e39f0f0d72ee341399b4feebc632082995d52..68baaffb40c6ffa2188336e637a50de922d469a4 100644 (file)
@@ -1,11 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stddef.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "memory-util.h"
+#include "forward.h"
 
 struct strbuf {
         char *buf;
index 30c912adb66287aef17ba9b8bdff645d55a0b9b4..fa3cc15743dcabe335c6d9b874e423f97987b785 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
+#include <stdio.h>
 
 #include "parse-util.h"
 #include "string-table.h"
index c91bed99a1025b3335eb31afe0a191643389441e..7e0569a489402c2671748722a52509114ca06ce5 100644 (file)
@@ -2,11 +2,7 @@
 
 #pragma once
 
-#include <stddef.h>
-#include <stdio.h>
-#include <sys/types.h>
-
-#include "macro.h"
+#include "forward.h"
 
 const char* string_table_lookup_to_string(const char * const *table, size_t len, ssize_t i) _const_;
 
index de24e60a148d1900b0bf35e8832eb50cd7d2b06f..d2c538cfc4b4c705cf485ad032d09fee36bde732 100644 (file)
@@ -1,21 +1,14 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-#include <stdarg.h>
-#include <stdint.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 #include "alloc-util.h"
 #include "escape.h"
 #include "extract-word.h"
-#include "fd-util.h"
-#include "fileio.h"
 #include "glyph-util.h"
 #include "gunicode.h"
 #include "locale-util.h"
 #include "log.h"
-#include "macro.h"
 #include "memory-util.h"
 #include "memstream-util.h"
 #include "path-util.h"
index b68bf291feae742cd412d0b53c495ccae2ecb9eb..f28d9f12aac43d9bab4f1b6be39ccdae51400f9e 100644 (file)
@@ -1,14 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-#include <stddef.h>
 #include <string.h>
-#include <sys/types.h>
 
 #include "alloc-util.h"
-#include "macro.h"
-#include "string-util-fundamental.h"
+#include "forward.h"
+#include "string-util-fundamental.h" /* IWYU pragma: export */
 
 static inline char* strstr_ptr(const char *haystack, const char *needle) {
         if (!haystack || !needle)
index 67e3d4f4ccf9ec7609ae66d88663c271992d1f1f..37f4bd44f3f4c70fe46086756807dcf1935edc69 100644 (file)
@@ -1,10 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <fnmatch.h>
-#include <stdarg.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 #include "alloc-util.h"
 #include "env-util.h"
@@ -12,9 +9,9 @@
 #include "extract-word.h"
 #include "fileio.h"
 #include "gunicode.h"
+#include "hashmap.h"
 #include "log.h"
 #include "memory-util.h"
-#include "nulstr-util.h"
 #include "sort-util.h"
 #include "string-util.h"
 #include "strv.h"
@@ -1105,6 +1102,10 @@ void string_strv_hashmap_remove(Hashmap *h, const char *key, const char *value)
         strv_free(hashmap_remove2(h, key, (void**) &key_free));
 }
 
+void string_strv_ordered_hashmap_remove(OrderedHashmap *h, const char *key, const char *value) {
+        string_strv_hashmap_remove(PLAIN_HASHMAP(h), key, value);
+}
+
 static int string_strv_hashmap_put_internal(Hashmap *h, const char *key, const char *value) {
         char **l;
         int r;
index 8058df44a05afb044d7cfc57bb1af1f06da5a7eb..55eb020d5694c3a3001e8889cbde33e71c9c654a 100644 (file)
@@ -1,17 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdio.h>
-
-#include "alloc-util.h"
-#include "hashmap.h"
-#include "memory-util.h"
-#include "strv-fundamental.h"
-
-typedef enum ExtractFlags ExtractFlags;
+#include "forward.h"
+#include "strv-fundamental.h"   /* IWYU pragma: export */
 
 char* strv_find(char * const *l, const char *name) _pure_;
 char* strv_find_case(char * const *l, const char *name) _pure_;
@@ -216,9 +207,7 @@ int fputstrv(FILE *f, char * const *l, const char *separator, bool *space);
         free_and_replace_full(a, b, strv_free)
 
 void string_strv_hashmap_remove(Hashmap *h, const char *key, const char *value);
-static inline void string_strv_ordered_hashmap_remove(OrderedHashmap *h, const char *key, const char *value) {
-        string_strv_hashmap_remove(PLAIN_HASHMAP(h), key, value);
-}
+void string_strv_ordered_hashmap_remove(OrderedHashmap *h, const char *key, const char *value);
 int string_strv_hashmap_put(Hashmap **h, const char *key, const char *value);
 int string_strv_ordered_hashmap_put(OrderedHashmap **h, const char *key, const char *value);
 
index 52b95650cf38d0aa138651df5814b1731f725c4c..9126e1dfe26d51b23e8fae67f18908968b5e0f80 100644 (file)
  * occur outside of a loop where this is the preferred behavior.
  */
 
-#include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
 
-#include "string-util.h"
 #include "strxcpyx.h"
 
 size_t strnpcpy_full(char **dest, size_t size, const char *src, size_t len, bool *ret_truncated) {
index 4a648ed033bf5292d83b149d00b4a89a2ce2ca4f..7d045fe8d2219a91a96d009fd9fab0ccfd496884 100644 (file)
@@ -1,10 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-#include <stddef.h>
-
-#include "macro.h"
+#include "forward.h"
 
 size_t strnpcpy_full(char **dest, size_t size, const char *src, size_t len, bool *ret_truncated);
 static inline size_t strnpcpy(char **dest, size_t size, const char *src, size_t len) {
index eb9c9f1a6e8b5b11becce2c2a4f961cb74fc6a22..d9a53175ab4429e328ca99e3ac94bc092bac4560 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <fcntl.h>
 #include <sys/stat.h>
+#include <unistd.h>
 
 #include "alloc-util.h"
 #include "errno-util.h"
index e449440a530b2c34e5a4775410b039dd9b065ae8..c464a656d445dee93ac372a76c497bcdae399b5c 100644 (file)
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include "forward.h"
+
 int fsync_directory_of_file(int fd);
 int fsync_full(int fd);
 
index 5ffb31ec012c260c1effa91ad1a0f1eb3d349926..ae70abe627828be1f435bf9f69c5e4d61b1ab596 100644 (file)
@@ -1,16 +1,12 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-#include <fcntl.h>
 #include <stdio.h>
-#include <unistd.h>
 
 #include "af-list.h"
 #include "alloc-util.h"
-#include "fd-util.h"
 #include "fileio.h"
+#include "hashmap.h"
 #include "log.h"
-#include "macro.h"
 #include "parse-util.h"
 #include "path-util.h"
 #include "socket-util.h"
@@ -143,6 +139,10 @@ int sysctl_write_ip_property(int af, const char *ifname, const char *property, c
         return sysctl_write_full(p, value, shadow);
 }
 
+int sysctl_write_ip_property_boolean(int af, const char *ifname, const char *property, bool value, Hashmap **shadow) {
+        return sysctl_write_ip_property(af, ifname, property, one_zero(value), shadow);
+}
+
 int sysctl_write_ip_neighbor_property(int af, const char *ifname, const char *property, const char *value, Hashmap **shadow) {
         const char *p;
 
@@ -163,6 +163,12 @@ int sysctl_write_ip_neighbor_property(int af, const char *ifname, const char *pr
         return sysctl_write_full(p, value, shadow);
 }
 
+int sysctl_write_ip_neighbor_property_uint32(int af, const char *ifname, const char *property, uint32_t value, Hashmap **shadow) {
+        char buf[DECIMAL_STR_MAX(uint32_t)];
+        xsprintf(buf, "%u", value);
+        return sysctl_write_ip_neighbor_property(af, ifname, property, buf, shadow);
+}
+
 int sysctl_read(const char *property, char **ret) {
         char *p;
         int r;
index f3ae6fe7cf21933b757a9ea92afae0dc320c9ca5..ef08376916c5b9781ab7d1261a02f74aff287218 100644 (file)
@@ -1,13 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-#include <stdint.h>
 
-#include "hashmap.h"
-#include "macro.h"
+#include "forward.h"
 #include "stdio-util.h"
-#include "string-util.h"
 
 char* sysctl_normalize(char *s);
 int sysctl_read(const char *property, char **value);
@@ -21,16 +17,10 @@ int sysctl_read_ip_property(int af, const char *ifname, const char *property, ch
 int sysctl_read_ip_property_int(int af, const char *ifname, const char *property, int *ret);
 int sysctl_read_ip_property_uint32(int af, const char *ifname, const char *property, uint32_t *ret);
 int sysctl_write_ip_property(int af, const char *ifname, const char *property, const char *value, Hashmap **shadow);
-static inline int sysctl_write_ip_property_boolean(int af, const char *ifname, const char *property, bool value, Hashmap **shadow) {
-        return sysctl_write_ip_property(af, ifname, property, one_zero(value), shadow);
-}
+int sysctl_write_ip_property_boolean(int af, const char *ifname, const char *property, bool value, Hashmap **shadow);
 
 int sysctl_write_ip_neighbor_property(int af, const char *ifname, const char *property, const char *value, Hashmap **shadow);
-static inline int sysctl_write_ip_neighbor_property_uint32(int af, const char *ifname, const char *property, uint32_t value, Hashmap **shadow) {
-        char buf[DECIMAL_STR_MAX(uint32_t)];
-        xsprintf(buf, "%u", value);
-        return sysctl_write_ip_neighbor_property(af, ifname, property, buf, shadow);
-}
+int sysctl_write_ip_neighbor_property_uint32(int af, const char *ifname, const char *property, uint32_t value, Hashmap **shadow);
 
 #define DEFINE_SYSCTL_WRITE_IP_PROPERTY(name, type, format)           \
         static inline int sysctl_write_ip_property_##name(int af, const char *ifname, const char *property, type value, Hashmap **shadow) { \
index 18194f70d976cda039b1275892310f7931daa924..fd910ca76d45084d6da934ad65e5150834e47950 100644 (file)
@@ -1,15 +1,14 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <limits.h>
 #include <syslog.h>
 
 #include "sd-id128.h"
 
 #include "glob-util.h"
 #include "hexdecoct.h"
-#include "macro.h"
 #include "path-util.h"
 #include "string-table.h"
+#include "string-util.h"
 #include "syslog-util.h"
 #include "unit-name.h"
 
index d7aa97fb7d8eebcade098d73583d9631a80954f4..dff09db2396c4c12c1d34caae103473cbd7a4c2b 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
+#include "forward.h"
 
 int log_facility_unshifted_to_string_alloc(int i, char **s);
 int log_facility_unshifted_from_string(const char *s);
index 00cdd02eca84c867e54d809d6647342015bdab78..51b3a83d29d9d5a774610d08dc76d5ee8f43ed92 100644 (file)
@@ -1,42 +1,32 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <fcntl.h>
-#include <limits.h>
 #include <linux/kd.h>
 #include <linux/tiocl.h>
 #include <linux/vt.h>
 #include <poll.h>
 #include <signal.h>
-#include <stdarg.h>
-#include <stddef.h>
 #include <stdlib.h>
 #include <sys/inotify.h>
 #include <sys/ioctl.h>
 #include <sys/sysmacros.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/utsname.h>
 #include <termios.h>
+#include <time.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
 #include "ansi-color.h"
 #include "chase.h"
-#include "constants.h"
 #include "devnum-util.h"
-#include "env-util.h"
-#include "errno-list.h"
+#include "errno-util.h"
 #include "extract-word.h"
 #include "fd-util.h"
 #include "fileio.h"
 #include "fs-util.h"
-#include "glyph-util.h"
 #include "hexdecoct.h"
 #include "inotify-util.h"
 #include "io-util.h"
 #include "log.h"
-#include "macro.h"
 #include "missing_magic.h"
 #include "namespace-util.h"
 #include "parse-util.h"
 #include "socket-util.h"
 #include "stat-util.h"
 #include "stdio-util.h"
-#include "string-table.h"
 #include "string-util.h"
 #include "strv.h"
 #include "terminal-util.h"
 #include "time-util.h"
-#include "user-util.h"
 #include "utf8.h"
 
 #define ANSI_RESET_CURSOR                          \
@@ -817,6 +805,11 @@ int terminal_new_session(void) {
         return RET_NERRNO(ioctl(STDIN_FILENO, TIOCSCTTY, 0));
 }
 
+void terminal_detach_session(void) {
+        (void) setsid();
+        (void) release_terminal();
+}
+
 int terminal_vhangup_fd(int fd) {
         assert(fd >= 0);
         return RET_NERRNO(ioctl(fd, TIOCVHANGUP));
index 376d1fe3012ff00f08630d4b45d9fb8765bc3401..17dbdfdfd583c77e1650f725dedc09b97c26a5f2 100644 (file)
@@ -1,17 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <syslog.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "macro.h"
-#include "pidref.h"
-#include "time-util.h"
+#include "forward.h"
 
 /* Erase characters until the end of the line */
 #define ANSI_ERASE_TO_END_OF_LINE "\x1B[K"
@@ -79,10 +69,7 @@ int acquire_terminal(const char *name, AcquireTerminalFlags flags, usec_t timeou
 int release_terminal(void);
 
 int terminal_new_session(void);
-static inline void terminal_detach_session(void) {
-        (void) setsid();
-        (void) release_terminal();
-}
+void terminal_detach_session(void);
 
 int terminal_vhangup_fd(int fd);
 int terminal_vhangup(const char *tty);
index 86c8d71a4a28f7166ecf2f29e9db4dcd01bf1c7a..1a86f7fdee5b4ffc70626217a9fef90938802c05 100644 (file)
@@ -1,13 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <ctype.h>
-#include <errno.h>
-#include <limits.h>
 #include <stdlib.h>
 #include <sys/mman.h>
-#include <sys/time.h>
 #include <sys/timerfd.h>
-#include <sys/types.h>
 #include <threads.h>
 #include <unistd.h>
 
 #include "fs-util.h"
 #include "io-util.h"
 #include "log.h"
-#include "macro.h"
 #include "parse-util.h"
 #include "path-util.h"
 #include "process-util.h"
 #include "stat-util.h"
+#include "stdio-util.h"
 #include "string-table.h"
 #include "string-util.h"
 #include "strv.h"
index 83d7e660ac80c27cf1fa1bf68843859b98237933..90c17c39b1772f83866f91742bdd9b980ab3a895 100644 (file)
@@ -1,24 +1,15 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <errno.h>
-#include <inttypes.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <stdio.h>
 #include <time.h>
 
-typedef uint64_t usec_t;
-typedef uint64_t nsec_t;
+#include "forward.h"
 
 #define PRI_NSEC PRIu64
 #define PRI_USEC PRIu64
 #define NSEC_FMT "%" PRI_NSEC
 #define USEC_FMT "%" PRI_USEC
 
-#include "macro.h"
-
 typedef struct dual_timestamp {
         usec_t realtime;
         usec_t monotonic;
index 0debd249ad02efd3d8eeaf80624262394489e962..6e2069de7cbe06fc0088cc47d94b9666f3c6d33b 100644 (file)
@@ -1,23 +1,16 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <sys/mman.h>
+#include <stdlib.h>
+#include <unistd.h>
 
 #include "alloc-util.h"
 #include "errno-util.h"
 #include "fd-util.h"
 #include "fileio.h"
 #include "fs-util.h"
-#include "hexdecoct.h"
 #include "log.h"
-#include "macro.h"
-#include "memfd-util.h"
-#include "missing_fcntl.h"
-#include "missing_syscall.h"
 #include "path-util.h"
-#include "process-util.h"
 #include "random-util.h"
-#include "stat-util.h"
-#include "stdio-util.h"
 #include "string-util.h"
 #include "sync-util.h"
 #include "tmpfile-util.h"
index 5b94837d35ad21ba22ae0ae737f8b22af8fc085f..b39680f078bff50febcd23deb19925004e4c34e0 100644 (file)
@@ -1,9 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <fcntl.h>
-#include <stdbool.h>
-#include <stdio.h>
+#include "forward.h"
 
 int fopen_temporary_at(int dir_fd, const char *path, FILE **ret_file, char **ret_path);
 static inline int fopen_temporary(const char *path, FILE **ret_file, char **ret_path) {
index c60daf5dcc39b343754b3cb17567f6590585608c..bd87ffc80d7d889dfa43e4669f4331c0d75d1e5c 100644 (file)
@@ -1,10 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-#include <sys/types.h>
-
-#include "macro.h"
+#include "forward.h"
 
 /* The container base should have the last 16 bit set to zero */
 assert_cc((CONTAINER_UID_BASE_MIN & 0xFFFFU) == 0);
index 542f00cadaafd97a90b8a477473252dedfc17479..109bef51cbb907b34db6f98b419ae5914c55dd61 100644 (file)
@@ -1,15 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-#include <stdlib.h>
 #include <string.h>
 
 #include "alloc-util.h"
 #include "errno-util.h"
 #include "fd-util.h"
 #include "format-util.h"
-#include "log.h"
-#include "macro.h"
 #include "namespace-util.h"
 #include "path-util.h"
 #include "process-util.h"
@@ -209,6 +205,30 @@ int uid_map_read_one(FILE *f, uid_t *ret_base, uid_t *ret_shift, uid_t *ret_rang
         return 0;
 }
 
+unsigned uid_range_size(const UIDRange *range) {
+        if (!range)
+                return 0;
+
+        unsigned n = 0;
+
+        FOREACH_ARRAY(e, range->entries, range->n_entries)
+                n += e->nr;
+
+        return n;
+}
+
+bool uid_range_is_empty(const UIDRange *range) {
+
+        if (!range)
+                return true;
+
+        FOREACH_ARRAY(e, range->entries, range->n_entries)
+                if (e->nr > 0)
+                        return false;
+
+        return true;
+}
+
 int uid_range_load_userns(const char *path, UIDRangeUsernsMode mode, UIDRange **ret) {
         _cleanup_(uid_range_freep) UIDRange *range = NULL;
         _cleanup_fclose_ FILE *f = NULL;
index e1965cf9b7d51500b729d8a96f7d1492e50f7602..5f3c0335243bb035e4e23c875a12bc70ecba7673 100644 (file)
@@ -1,11 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <errno.h>
-#include <stdbool.h>
-#include <sys/types.h>
-
-#include "memory-util.h"
+#include "forward.h"
 
 typedef struct UIDRangeEntry {
         uid_t start, nr;
@@ -38,29 +34,8 @@ static inline size_t uid_range_entries(const UIDRange *range) {
         return range ? range->n_entries : 0;
 }
 
-static inline unsigned uid_range_size(const UIDRange *range) {
-        if (!range)
-                return 0;
-
-        unsigned n = 0;
-
-        FOREACH_ARRAY(e, range->entries, range->n_entries)
-                n += e->nr;
-
-        return n;
-}
-
-static inline bool uid_range_is_empty(const UIDRange *range) {
-
-        if (!range)
-                return true;
-
-        FOREACH_ARRAY(e, range->entries, range->n_entries)
-                if (e->nr > 0)
-                        return false;
-
-        return true;
-}
+unsigned uid_range_size(const UIDRange *range) _pure_;
+bool uid_range_is_empty(const UIDRange *range) _pure_;
 
 bool uid_range_equal(const UIDRange *a, const UIDRange *b);
 
index 00417fa3045c8a9b0aec9cf69cc304a7231ffaee..1f9ea2bf2b1ce3cb592fe400a30fc1ebb8891ae9 100644 (file)
@@ -1,11 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
 #include <sys/stat.h>
-#include <sys/types.h>
 
-#include "macro.h"
+#include "forward.h"
 
 static inline void umaskp(mode_t *u) {
         umask(*u);
index 04580cfb636b5b7d1130dc936862170fc38100f2..61ee82b7730bea52d050dec11037b639912853cb 100644 (file)
@@ -2,9 +2,9 @@
 #pragma once
 
 #include <endian.h>
-#include <stdint.h>
 
-#include "unaligned-fundamental.h"
+#include "forward.h"
+#include "unaligned-fundamental.h" /* IWYU pragma: export */
 
 /* BE */
 
index d9ef13b103a5180f6393041a8d67d81f63269717..89c7f937908f76011364ff5de8047bcfea3ff569 100644 (file)
@@ -2,7 +2,9 @@
 
 #include "alloc-util.h"
 #include "bus-label.h"
+#include "glyph-util.h"
 #include "string-table.h"
+#include "string-util.h"
 #include "unit-def.h"
 #include "unit-name.h"
 
index a55b6c3be0bed96a19465d96da0baa159f879c46..a8779769e31df730a3321c3601f1cbb6d9b949ca 100644 (file)
@@ -1,11 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-
-#include "errno-list.h"
-#include "glyph-util.h"
-#include "macro.h"
+#include "forward.h"
 
 /* The enum order is used to order unit jobs in the job queue
  * when other criteria (cpu weight, nice level) are identical.
index f38f6386c129fc488a65990373c4dd049a27a7f8..6a42ece0b3e6eaa0fc2e0ae6beae1e236065e632 100644 (file)
@@ -1,25 +1,18 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
-
 #include "sd-id128.h"
 
 #include "alloc-util.h"
 #include "glob-util.h"
-#include "hash-funcs.h"
 #include "hexdecoct.h"
 #include "log.h"
 #include "memory-util.h"
 #include "path-util.h"
-#include "random-util.h"
 #include "sparse-endian.h"
 #include "special.h"
-#include "stdio-util.h"
+#include "siphash24.h"
 #include "string-util.h"
-#include "strv.h"
+#include "unit-def.h"
 #include "unit-name.h"
 
 /* Characters valid in a unit name. */
index 44354541c4c9f788a375699b3db235ce81bf3888..50fe3ac8e98e259a12aed2098069d06a2316fd17 100644 (file)
@@ -1,10 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-
-#include "macro.h"
-#include "unit-def.h"
+#include "forward.h"
 
 #define UNIT_NAME_MAX 256
 
index 3936192f391189ca945feb097ddcdaf5ca65e9e7..3950a5aa14bffb900d365d2f6813394e6f75ab3b 100644 (file)
@@ -1,9 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <fcntl.h>
-#include <stddef.h>
-#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/file.h>
 #include "format-util.h"
 #include "lock-util.h"
 #include "log.h"
-#include "macro.h"
 #include "mkdir.h"
 #include "parse-util.h"
 #include "path-util.h"
-#include "random-util.h"
 #include "string-util.h"
 #include "strv.h"
 #include "terminal-util.h"
@@ -159,6 +154,10 @@ bool is_nologin_shell(const char *shell) {
                            "/usr/bin/true");
 }
 
+bool shell_is_placeholder(const char *shell) {
+        return isempty(shell) || is_nologin_shell(shell);
+}
+
 const char* default_root_shell_at(int rfd) {
         /* We want to use the preferred shell, i.e. DEFAULT_USER_SHELL, which usually
          * will be /bin/bash. Fall back to /bin/sh if DEFAULT_USER_SHELL is not found,
index 983db1138e22ef9585e51d1972a9012c13b44de3..c2c7d3983d569301556e2ef062f7331dac13545c 100644 (file)
@@ -7,12 +7,8 @@
 #endif
 #include <pwd.h>
 #include <shadow.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <unistd.h>
 
-#include "string-util.h"
+#include "forward.h"
 
 /* Users managed by systemd-homed. See https://systemd.io/UIDS-GIDS for details how this range fits into the rest of the world */
 #define HOME_UID_MIN ((uid_t) 60001)
@@ -43,9 +39,7 @@ const char* default_root_shell(const char *root);
 
 bool is_nologin_shell(const char *shell);
 
-static inline bool shell_is_placeholder(const char *shell) {
-        return isempty(shell) || is_nologin_shell(shell);
-}
+bool shell_is_placeholder(const char *shell) _pure_;
 
 typedef enum UserCredsFlags {
         USER_CREDS_PREFER_NSS           = 1 << 0,  /* if set, only synthesize user records if database lacks them. Normally we bypass the userdb entirely for the records we can synthesize */
index 633d86c6cf7f51b57cf626a8335b6e7ff41e5824..8a0cfc012ec6d7ca0a3a704ab414b84e693616f6 100644 (file)
@@ -7,14 +7,9 @@
  * Copyright (C) 2000 Red Hat, Inc.
  */
 
-#include <errno.h>
-#include <stdbool.h>
-#include <stdlib.h>
-
 #include "alloc-util.h"
 #include "gunicode.h"
 #include "hexdecoct.h"
-#include "macro.h"
 #include "string-util.h"
 #include "utf8.h"
 
index 3b1a468c4f4f789c83617ea3ba55d26ddcd9352c..e5368205bd53c238501400847def6cdaf979edc1 100644 (file)
@@ -1,12 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <uchar.h>
-
-#include "macro.h"
+#include "forward.h"
 
 #define UTF8_REPLACEMENT_CHARACTER "\xef\xbf\xbd"
 #define UTF8_BYTE_ORDER_MARK "\xef\xbb\xbf"
index 5717a1d2b41dcaaef2ef390be09461a7f7bc76c8..f11d5c235acd4d889a88eccc926c2d7dd113f15b 100644 (file)
@@ -3,8 +3,6 @@
 #if defined(__i386__) || defined(__x86_64__)
 #include <cpuid.h>
 #endif
-#include <errno.h>
-#include <stdint.h>
 #include <stdlib.h>
 #include <threads.h>
 #include <unistd.h>
 #include "alloc-util.h"
 #include "dirent-util.h"
 #include "env-util.h"
-#include "errno-util.h"
 #include "extract-word.h"
 #include "fd-util.h"
 #include "fileio.h"
 #include "log.h"
-#include "macro.h"
 #include "namespace-util.h"
 #include "parse-util.h"
+#include "pidref.h"
 #include "process-util.h"
-#include "stat-util.h"
 #include "string-table.h"
 #include "string-util.h"
 #include "strv.h"
index e4fdaca9769d2dae8447650f8223b2a6c8fdbe1f..cac3f4496c62ea2fcb929da2d192250e57de212d 100644 (file)
@@ -1,11 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <errno.h>
-#include <stdbool.h>
-
-#include "errno-list.h"
-#include "macro.h"
+#include "forward.h"
 
 typedef enum Virtualization {
         VIRTUALIZATION_NONE = 0,
index 9256bd4b1a4a218c9c78be2995e46034d305e513..15072add7809dc5680a3449e9f18084085094315 100644 (file)
@@ -1,23 +1,18 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <errno.h>
 #include <fcntl.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <sys/time.h>
 #include <sys/xattr.h>
 #include <threads.h>
 
 #include "alloc-util.h"
 #include "errno-util.h"
 #include "fd-util.h"
-#include "macro.h"
+#include "fs-util.h"
 #include "missing_syscall.h"
 #include "nulstr-util.h"
 #include "parse-util.h"
 #include "sparse-endian.h"
 #include "stat-util.h"
-#include "stdio-util.h"
 #include "string-util.h"
 #include "strv.h"
 #include "time-util.h"
index 773e736cfb9dbcf706e39d4bab6bdbeb3394aaa8..cf68933bfe394a1f7072d4d2abd9a3e13337d4df 100644 (file)
@@ -1,12 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <fcntl.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <sys/types.h>
-
-#include "time-util.h"
+#include "forward.h"
 
 int getxattr_at_malloc(int fd, const char *path, const char *name, int at_flags, char **ret, size_t *ret_size);
 static inline int getxattr_malloc(const char *path, const char *name, char **ret, size_t *ret_size) {
index 5c210e006a31587945acc4218b0488f28a72364a..a0e77dd9b02ceab8542167c6dec4c6c70affd74f 100644 (file)
@@ -9,7 +9,6 @@
 #endif
 
 #include "efi-fundamental.h"
-#include "string-util-fundamental.h"
 
 #define CHID_TYPES_MAX 18
 /* Any chids starting from EXTRA_CHID_BASE are non-standard and are subject to change and renumeration at any time */
index 9657d967044bb68d17b7845efbe052cfd30b3501..bfd314e44452b5fea7dc739e6457e0e3fb4dc68f 100644 (file)
@@ -1,5 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#if !SD_BOOT
+#include <endian.h>
+#endif
+
 #include "edid-fundamental.h"
 #include "efivars-fundamental.h"
 
index 52473784d9031a8d153e0c4466b80b7f93846ec1..2a76c4524de2e157529cb5881c6c1bb1aca93128 100644 (file)
@@ -5,13 +5,12 @@
 #  include "efi-string.h"
 #  include "util.h"
 #else
-#  include <endian.h>
 #  include <stddef.h>
 #  include <stdint.h>
 #  include <uchar.h>
 #endif
 
-#include "string-util-fundamental.h"
+#include "macro-fundamental.h"
 
 /* EDID structure, version 1.4 */
 typedef struct EdidHeader {
index 108c43b45aa03acc44a350f6efb85d60916d15b3..bbf84ee9d60930c4600ca1683a0537f9ca80e07f 100644 (file)
@@ -28,7 +28,6 @@
 #endif
 
 #include "assert-fundamental.h"
-#include "macro-fundamental.h"
 #include "memory-util-fundamental.h"
 #include "sha256-fundamental.h"
 #include "unaligned-fundamental.h"
index c2b58889db204bf37e9d4f061ea39b0fff47109e..0141b42e3972e46551ccb0a065828b1e11258ee0 100644 (file)
@@ -1,9 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#if !SD_BOOT
-#  include <ctype.h>
-#endif
-
 #include "macro-fundamental.h"
 #include "string-util-fundamental.h"
 
index d8728bf88e9d98a956946d3b7e12b443b64050d9..1d39ba59596f390a316347a2f093cedd99da1e2c 100644 (file)
@@ -1,8 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "macro-fundamental.h"
-
 /* The various TPM PCRs we measure into from sd-stub and sd-boot. */
 
 enum {
index 6752b2ae77cc7f979a76391643c1264a0f73b29c..8d67b13b8b5c95e59636882593300e29d5ffc2f7 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include "macro-fundamental.h"
+#include <stdbool.h>
 
 /* List of PE sections that have special meaning for us in unified kernels. This is the canonical order in
  * which we measure the sections into TPM PCR 11. PLEASE DO NOT REORDER! */