From: Daan De Meyer Date: Thu, 22 May 2025 14:08:26 +0000 (+0200) Subject: basic + fundamental: Clean up includes X-Git-Tag: v258-rc1~496^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F37595%2Fhead;p=thirdparty%2Fsystemd.git basic + fundamental: Clean up includes Split out of #37344. --- diff --git a/src/basic/af-list.c b/src/basic/af-list.c index 421a16d73f3..5ab92a96b58 100644 --- a/src/basic/af-list.c +++ b/src/basic/af-list.c @@ -1,11 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include #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); diff --git a/src/basic/af-list.h b/src/basic/af-list.h index 07f50564583..425c713408c 100644 --- a/src/basic/af-list.h +++ b/src/basic/af-list.h @@ -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_; diff --git a/src/basic/alloc-util.c b/src/basic/alloc-util.c index 1a6b178eb7b..58b70dede4b 100644 --- a/src/basic/alloc-util.c +++ b/src/basic/alloc-util.c @@ -1,11 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include -#include -#include #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; +} diff --git a/src/basic/alloc-util.h b/src/basic/alloc-util.h index ec5b1059a84..263815c528e 100644 --- a/src/basic/alloc-util.h +++ b/src/basic/alloc-util.h @@ -1,14 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include - -#include "assert-util.h" -#include "cleanup-util.h" -#include "macro.h" +#include + +#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 diff --git a/src/basic/ansi-color.c b/src/basic/ansi-color.c index 18e25f3bb0d..9dce2f44188 100644 --- a/src/basic/ansi-color.c +++ b/src/basic/ansi-color.c @@ -1,9 +1,12 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include + #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" diff --git a/src/basic/ansi-color.h b/src/basic/ansi-color.h index f3e55e8165b..de86d36150f 100644 --- a/src/basic/ansi-color.h +++ b/src/basic/ansi-color.h @@ -1,9 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - -#include "macro.h" +#include "forward.h" /* Limits the use of ANSI colors to a subset. */ typedef enum ColorMode { diff --git a/src/basic/architecture.c b/src/basic/architecture.c index c7d5b0d8bd3..a711e8bef48 100644 --- a/src/basic/architecture.c +++ b/src/basic/architecture.c @@ -3,7 +3,6 @@ #include #include "architecture.h" -#include "macro.h" #include "string-table.h" #include "string-util.h" diff --git a/src/basic/architecture.h b/src/basic/architecture.h index 4d06e5c3a48..3793415e5d8 100644 --- a/src/basic/architecture.h +++ b/src/basic/architecture.h @@ -1,10 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include +#include /* 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 diff --git a/src/basic/argv-util.c b/src/basic/argv-util.c index 71be53a1bf7..ab0fe3280d4 100644 --- a/src/basic/argv-util.c +++ b/src/basic/argv-util.c @@ -1,9 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include +#include #include #include -#include #include "argv-util.h" #include "capability-util.h" @@ -19,6 +18,16 @@ 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; diff --git a/src/basic/argv-util.h b/src/basic/argv-util.h index deaa7c04e63..d79bd6f2224 100644 --- a/src/basic/argv-util.h +++ b/src/basic/argv-util.h @@ -1,23 +1,12 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - -#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); diff --git a/src/basic/arphrd-util.c b/src/basic/arphrd-util.c index 063aede5e72..0c5a85edaa5 100644 --- a/src/basic/arphrd-util.c +++ b/src/basic/arphrd-util.c @@ -1,14 +1,11 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include #include #include #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); diff --git a/src/basic/arphrd-util.h b/src/basic/arphrd-util.h index 0fd75a04363..95c6a887c49 100644 --- a/src/basic/arphrd-util.h +++ b/src/basic/arphrd-util.h @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include +#include "forward.h" const char* arphrd_to_name(int id); int arphrd_from_name(const char *name); diff --git a/src/basic/assert-util.c b/src/basic/assert-util.c index add9e92c522..a1aa5c82e23 100644 --- a/src/basic/assert-util.c +++ b/src/basic/assert-util.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include +#include #include "assert-util.h" #include "errno-util.h" diff --git a/src/basic/assert-util.h b/src/basic/assert-util.h index 7462e1b2225..f6bb7702ea6 100644 --- a/src/basic/assert-util.h +++ b/src/basic/assert-util.h @@ -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 */ diff --git a/src/basic/audit-util.c b/src/basic/audit-util.c index 9a9f2849ed3..a94378f6121 100644 --- a/src/basic/audit-util.c +++ b/src/basic/audit-util.c @@ -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" diff --git a/src/basic/audit-util.h b/src/basic/audit-util.h index 98b1b3631a6..ff9ce72e0b7 100644 --- a/src/basic/audit-util.h +++ b/src/basic/audit-util.h @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include - -#include "pidref.h" +#include "forward.h" #define AUDIT_SESSION_INVALID UINT32_MAX diff --git a/src/basic/bitfield.h b/src/basic/bitfield.h index c6eaaa484fe..a06841a6490 100644 --- a/src/basic/bitfield.h +++ b/src/basic/bitfield.h @@ -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) \ diff --git a/src/basic/btrfs.c b/src/basic/btrfs.c index 7d5c35605de..7981c670e33 100644 --- a/src/basic/btrfs.c +++ b/src/basic/btrfs.c @@ -2,12 +2,12 @@ #include #include +#include #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" diff --git a/src/basic/btrfs.h b/src/basic/btrfs.h index 38be9d2b3b1..0b3ae1082c7 100644 --- a/src/basic/btrfs.h +++ b/src/basic/btrfs.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include +#include "forward.h" int btrfs_validate_subvolume_name(const char *name); diff --git a/src/basic/build-path.c b/src/basic/build-path.c index 0341074cedc..577ff72bce2 100644 --- a/src/basic/build-path.c +++ b/src/basic/build-path.c @@ -1,17 +1,16 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include +#include #include #include #include +#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) { diff --git a/src/basic/build.c b/src/basic/build.c index 946de943f09..ad9d3b1c4bd 100644 --- a/src/basic/build.c +++ b/src/basic/build.c @@ -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 = diff --git a/src/basic/build.h b/src/basic/build.h index 5b7c83cad9e..3f1211e708c 100644 --- a/src/basic/build.h +++ b/src/basic/build.h @@ -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); diff --git a/src/basic/bus-label.c b/src/basic/bus-label.c index 6371a9dba0c..b6bf9ca4682 100644 --- a/src/basic/bus-label.c +++ b/src/basic/bus-label.c @@ -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(""); diff --git a/src/basic/bus-label.h b/src/basic/bus-label.h index 7630eff2955..22dd7969847 100644 --- a/src/basic/bus-label.h +++ b/src/basic/bus-label.h @@ -1,14 +1,11 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include - -#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); } diff --git a/src/basic/cap-list.c b/src/basic/cap-list.c index 9ae679330ac..5e368937a2e 100644 --- a/src/basic/cap-list.c +++ b/src/basic/cap-list.c @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include +#include #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" diff --git a/src/basic/cap-list.h b/src/basic/cap-list.h index 95b03c48ddc..ea80ca3d5c7 100644 --- a/src/basic/cap-list.h +++ b/src/basic/cap-list.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#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 diff --git a/src/basic/capability-util.c b/src/basic/capability-util.c index 2f0e0ccf92e..4e6171e3c1e 100644 --- a/src/basic/capability-util.c +++ b/src/basic/capability-util.c @@ -1,12 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include #include -#include #include -#include #include #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" diff --git a/src/basic/capability-util.h b/src/basic/capability-util.h index a076becdcd8..3c265e40640 100644 --- a/src/basic/capability-util.h +++ b/src/basic/capability-util.h @@ -1,13 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include +#include /* 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. */ diff --git a/src/basic/capsule-util.c b/src/basic/capsule-util.c index 83fcf7afbcc..6cff1aa27fd 100644 --- a/src/basic/capsule-util.c +++ b/src/basic/capsule-util.c @@ -1,10 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include - #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) { diff --git a/src/basic/capsule-util.h b/src/basic/capsule-util.h index 437153be9e7..02b00220f1e 100644 --- a/src/basic/capsule-util.h +++ b/src/basic/capsule-util.h @@ -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); diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index f0b91254dc7..1c752428924 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -1,12 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include #include -#include #include -#include -#include #include #include #include @@ -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" @@ -24,17 +18,15 @@ #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" @@ -42,6 +34,20 @@ #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; diff --git a/src/basic/cgroup-util.h b/src/basic/cgroup-util.h index 05211b065cd..acb3427875e 100644 --- a/src/basic/cgroup-util.h +++ b/src/basic/cgroup-util.h @@ -1,18 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include - -#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)) diff --git a/src/basic/chase.c b/src/basic/chase.c index 88cd840544b..34423cc3004 100644 --- a/src/basic/chase.c +++ b/src/basic/chase.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include +#include #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" diff --git a/src/basic/chase.h b/src/basic/chase.h index 2146f54e7aa..36632c8a325 100644 --- a/src/basic/chase.h +++ b/src/basic/chase.h @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include - -#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 */ diff --git a/src/basic/chattr-util.c b/src/basic/chattr-util.c index 794ac6572fc..5786c12a3f8 100644 --- a/src/basic/chattr-util.c +++ b/src/basic/chattr-util.c @@ -1,6 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include #include @@ -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( diff --git a/src/basic/chattr-util.h b/src/basic/chattr-util.h index 472054d57e6..8d938ef94b1 100644 --- a/src/basic/chattr-util.h +++ b/src/basic/chattr-util.h @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include - +#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 diff --git a/src/basic/compress.c b/src/basic/compress.c index c8096635ef8..3270a7ed104 100644 --- a/src/basic/compress.c +++ b/src/basic/compress.c @@ -1,11 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include -#include +#include #include #include -#include #include #if HAVE_LZ4 @@ -26,12 +23,10 @@ #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" diff --git a/src/basic/compress.h b/src/basic/compress.h index dbd6bb38576..ce662920eb7 100644 --- a/src/basic/compress.h +++ b/src/basic/compress.h @@ -1,12 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include - -#include "dlfcn-util.h" +#include "forward.h" typedef enum Compression { COMPRESSION_NONE, diff --git a/src/basic/conf-files.c b/src/basic/conf-files.c index 552b03a0d00..2461235fe8a 100644 --- a/src/basic/conf-files.c +++ b/src/basic/conf-files.c @@ -1,14 +1,11 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include #include #include #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" @@ -16,14 +13,12 @@ #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, diff --git a/src/basic/conf-files.h b/src/basic/conf-files.h index cf89ee62c68..fb479cabf9e 100644 --- a/src/basic/conf-files.h +++ b/src/basic/conf-files.h @@ -1,9 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - -#include "macro.h" +#include "forward.h" enum { CONF_FILES_EXECUTABLE = 1 << 0, diff --git a/src/basic/confidential-virt.c b/src/basic/confidential-virt.c index 920a9dd36af..3e07e3c3a24 100644 --- a/src/basic/confidential-virt.c +++ b/src/basic/confidential-virt.c @@ -3,13 +3,10 @@ #if defined(__i386__) || defined(__x86_64__) #include #endif -#include #include -#include #include #include -#include "alloc-util.h" #include "confidential-virt.h" #include "confidential-virt-fundamental.h" #include "errno-util.h" diff --git a/src/basic/confidential-virt.h b/src/basic/confidential-virt.h index bbab1231023..708b3ab6045 100644 --- a/src/basic/confidential-virt.h +++ b/src/basic/confidential-virt.h @@ -1,11 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include - -#include "errno-list.h" -#include "macro.h" +#include "forward.h" typedef enum ConfidentialVirtualization { CONFIDENTIAL_VIRTUALIZATION_NONE = 0, diff --git a/src/basic/devnum-util.c b/src/basic/devnum-util.c index 7be34ca0ef7..99c20662df6 100644 --- a/src/basic/devnum-util.c +++ b/src/basic/devnum-util.c @@ -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))); +} diff --git a/src/basic/devnum-util.h b/src/basic/devnum-util.h index 0e07df5e8cb..4b4a81f3ca7 100644 --- a/src/basic/devnum-util.h +++ b/src/basic/devnum-util.h @@ -1,12 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include #include -#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]) {}) diff --git a/src/basic/dirent-util.c b/src/basic/dirent-util.c index e25097d8aee..5dad9c20322 100644 --- a/src/basic/dirent-util.c +++ b/src/basic/dirent-util.c @@ -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) { diff --git a/src/basic/dirent-util.h b/src/basic/dirent-util.h index 4c8d96788b1..14fde59c992 100644 --- a/src/basic/dirent-util.h +++ b/src/basic/dirent-util.h @@ -1,12 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include +#include /* 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_; diff --git a/src/basic/dlfcn-util.c b/src/basic/dlfcn-util.c index b629b18d11b..6a7fe15a851 100644 --- a/src/basic/dlfcn-util.c +++ b/src/basic/dlfcn-util.c @@ -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); diff --git a/src/basic/dlfcn-util.h b/src/basic/dlfcn-util.h index e92e00b1e87..4b054e8cb3e 100644 --- a/src/basic/dlfcn-util.h +++ b/src/basic/dlfcn-util.h @@ -1,18 +1,11 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include /* 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); diff --git a/src/basic/dns-def.h b/src/basic/dns-def.h index d70220bcc0e..5c0f031df71 100644 --- a/src/basic/dns-def.h +++ b/src/basic/dns-def.h @@ -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 diff --git a/src/basic/efivars.c b/src/basic/efivars.c index 6fa0da576f8..0163ad0c166 100644 --- a/src/basic/efivars.c +++ b/src/basic/efivars.c @@ -1,26 +1,19 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include -#include #include #include +#include #include -#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, '\\', '/'); +} diff --git a/src/basic/efivars.h b/src/basic/efivars.h index 0bd75f9b416..dd049283f59 100644 --- a/src/basic/efivars.h +++ b/src/basic/efivars.h @@ -1,18 +1,11 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#if !ENABLE_EFI -# include -#endif -#include -#include -#include +#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); diff --git a/src/basic/env-file.c b/src/basic/env-file.c index 9ef30a62468..bc23e94d18f 100644 --- a/src/basic/env-file.c +++ b/src/basic/env-file.c @@ -1,5 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include + #include "alloc-util.h" #include "env-file.h" #include "env-util.h" diff --git a/src/basic/env-file.h b/src/basic/env-file.h index df3f29500f6..b44651fe1e9 100644 --- a/src/basic/env-file.h +++ b/src/basic/env-file.h @@ -1,11 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include - -#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); diff --git a/src/basic/env-util.c b/src/basic/env-util.c index b97eac070ba..112c93c1813 100644 --- a/src/basic/env-util.c +++ b/src/basic/env-util.c @@ -1,22 +1,17 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include -#include #include #include #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" @@ -27,6 +22,12 @@ 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) diff --git a/src/basic/env-util.h b/src/basic/env-util.h index 14f2e718232..07426d97146 100644 --- a/src/basic/env-util.h +++ b/src/basic/env-util.h @@ -1,20 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include - -#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); diff --git a/src/basic/errno-list.c b/src/basic/errno-list.c index 396879c8f2c..b39e15a7680 100644 --- a/src/basic/errno-list.c +++ b/src/basic/errno-list.c @@ -1,18 +1,22 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include -#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) { diff --git a/src/basic/errno-list.h b/src/basic/errno-list.h index e4a59788296..ce9516068d0 100644 --- a/src/basic/errno-list.h +++ b/src/basic/errno-list.h @@ -1,30 +1,11 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include +#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; diff --git a/src/basic/errno-util.h b/src/basic/errno-util.h index 2a5a5abb8a6..fa53744f614 100644 --- a/src/basic/errno-util.h +++ b/src/basic/errno-util.h @@ -1,15 +1,12 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include #include -#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; } diff --git a/src/basic/escape.c b/src/basic/escape.c index e1ded559811..79123536c03 100644 --- a/src/basic/escape.c +++ b/src/basic/escape.c @@ -1,13 +1,12 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include #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); diff --git a/src/basic/escape.h b/src/basic/escape.h index 05c27f688e3..c42302c24ee 100644 --- a/src/basic/escape.h +++ b/src/basic/escape.h @@ -1,13 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include -#include - -#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 { diff --git a/src/basic/ether-addr-util.c b/src/basic/ether-addr-util.c index 7e85de92fb9..375c0444157 100644 --- a/src/basic/ether-addr-util.c +++ b/src/basic/ether-addr-util.c @@ -1,15 +1,14 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include #include #include -#include #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); diff --git a/src/basic/ether-addr-util.h b/src/basic/ether-addr-util.h index 168c6500dc4..d2c6df444a4 100644 --- a/src/basic/ether-addr-util.h +++ b/src/basic/ether-addr-util.h @@ -2,13 +2,10 @@ #pragma once #include +#include #include -#include -#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, ÐER_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); diff --git a/src/basic/extract-word.c b/src/basic/extract-word.c index 012cee6e75a..99de8740d13 100644 --- a/src/basic/extract-word.c +++ b/src/basic/extract-word.c @@ -1,20 +1,10 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include -#include -#include -#include -#include -#include - #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) { diff --git a/src/basic/extract-word.h b/src/basic/extract-word.h index da4f6ae674a..2740de9189e 100644 --- a/src/basic/extract-word.h +++ b/src/basic/extract-word.h @@ -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. */ diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c index 55b274a25ee..d58f5a987a6 100644 --- a/src/basic/fd-util.c +++ b/src/basic/fd-util.c @@ -1,9 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include -#include #include #include #include @@ -11,12 +9,12 @@ #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: diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h index 82dd9d31e7e..6e2b709657b 100644 --- a/src/basic/fd-util.h +++ b/src/basic/fd-util.h @@ -2,16 +2,10 @@ #pragma once #include -#include -#include -#include #include -#include -#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)) diff --git a/src/basic/fileio.c b/src/basic/fileio.c index 509514512d9..eaadfaa6acc 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -1,19 +1,13 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include #include -#include -#include -#include #include #include #include -#include #include #include "alloc-util.h" -#include "chase.h" +#include "errno-util.h" #include "extract-word.h" #include "fd-util.h" #include "fileio.h" @@ -21,17 +15,18 @@ #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). */ diff --git a/src/basic/fileio.h b/src/basic/fileio.h index eff98802928..b6513fe3f88 100644 --- a/src/basic/fileio.h +++ b/src/basic/fileio.h @@ -1,16 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include -#include -#include -#include - -#include "macro.h" -#include "time-util.h" +#include "forward.h" #define LONG_LINE_MAX (1U*1024U*1024U) diff --git a/src/basic/filesystems.c b/src/basic/filesystems.c index 45f56fdf5aa..c8b407fc7e8 100644 --- a/src/basic/filesystems.c +++ b/src/basic/filesystems.c @@ -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) { diff --git a/src/basic/filesystems.h b/src/basic/filesystems.h index 4e6c6c47fc3..4d6d7e26411 100644 --- a/src/basic/filesystems.h +++ b/src/basic/filesystems.h @@ -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 diff --git a/src/basic/format-ifname.c b/src/basic/format-ifname.c index 8331d202889..9d3952f27e6 100644 --- a/src/basic/format-ifname.c +++ b/src/basic/format-ifname.c @@ -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" diff --git a/src/basic/format-util.c b/src/basic/format-util.c index 079b32c04db..021ece9eeb8 100644 --- a/src/basic/format-util.c +++ b/src/basic/format-util.c @@ -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 { diff --git a/src/basic/format-util.h b/src/basic/format-util.h index b528c005ca6..e42f788ce6f 100644 --- a/src/basic/format-util.h +++ b/src/basic/format-util.h @@ -1,11 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include - #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 diff --git a/src/basic/forward.h b/src/basic/forward.h index 30774035286..0456772980d 100644 --- a/src/basic/forward.h +++ b/src/basic/forward.h @@ -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; diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index 5b83c78b24d..6c6b0059677 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -1,9 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include -#include -#include #include #include #include @@ -14,30 +11,24 @@ #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); diff --git a/src/basic/fs-util.h b/src/basic/fs-util.h index 9f2b37a2d6c..59dbb1ce0ee 100644 --- a/src/basic/fs-util.h +++ b/src/basic/fs-util.h @@ -1,20 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include - +#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); diff --git a/src/basic/gcrypt-util.c b/src/basic/gcrypt-util.c index 70b6413e9b7..bd73621c6fe 100644 --- a/src/basic/gcrypt-util.c +++ b/src/basic/gcrypt-util.c @@ -2,9 +2,9 @@ #if HAVE_GCRYPT +#include + #include "gcrypt-util.h" -#include "hexdecoct.h" -#include "log.h" static void *gcrypt_dl = NULL; diff --git a/src/basic/gcrypt-util.h b/src/basic/gcrypt-util.h index 5fc176cb6c6..83e32babb55 100644 --- a/src/basic/gcrypt-util.h +++ b/src/basic/gcrypt-util.h @@ -2,17 +2,12 @@ #pragma once -#include -#include -#include - -#include "memory-util.h" +#include "forward.h" #if HAVE_GCRYPT -#include +#include /* IWYU pragma: export */ #include "dlfcn-util.h" -#include "macro.h" extern DLSYM_PROTOTYPE(gcry_md_close); extern DLSYM_PROTOTYPE(gcry_md_copy); diff --git a/src/basic/glob-util.c b/src/basic/glob-util.c index 59dda9809ca..9eec8b3f092 100644 --- a/src/basic/glob-util.c +++ b/src/basic/glob-util.c @@ -1,16 +1,13 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include +#include #include -#include -#include #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); +} diff --git a/src/basic/glob-util.h b/src/basic/glob-util.h index 7ca26cc27f7..4fa23f50489 100644 --- a/src/basic/glob-util.h +++ b/src/basic/glob-util.h @@ -1,11 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include +#include /* 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_; diff --git a/src/basic/glyph-util.h b/src/basic/glyph-util.h index 730f2695600..b1c90d00f6a 100644 --- a/src/basic/glyph-util.h +++ b/src/basic/glyph-util.h @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include - -#include "macro.h" +#include "forward.h" typedef enum Glyph { GLYPH_SPACE, diff --git a/src/basic/gunicode.c b/src/basic/gunicode.c index d7496f3e211..5b5e06c0253 100644 --- a/src/basic/gunicode.c +++ b/src/basic/gunicode.c @@ -5,8 +5,9 @@ * Copyright © 2000, 2005 Red Hat, Inc. */ +#include + #include "gunicode.h" -#include "macro.h" #define unichar uint32_t diff --git a/src/basic/gunicode.h b/src/basic/gunicode.h index 6b7183986fd..9bba03ba30b 100644 --- a/src/basic/gunicode.h +++ b/src/basic/gunicode.h @@ -6,9 +6,7 @@ */ #pragma once -#include -#include -#include +#include "forward.h" char *utf8_prev_char (const char *p); diff --git a/src/basic/hash-funcs.c b/src/basic/hash-funcs.c index 6540fa5dfc3..195256d07d2 100644 --- a/src/basic/hash-funcs.c +++ b/src/basic/hash-funcs.c @@ -1,10 +1,12 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include #include #include #include "hash-funcs.h" #include "path-util.h" +#include "siphash24.h" #include "strv.h" void string_hash_func(const char *p, struct siphash *state) { diff --git a/src/basic/hash-funcs.h b/src/basic/hash-funcs.h index d0736807ba4..7ce29fbe6cd 100644 --- a/src/basic/hash-funcs.h +++ b/src/basic/hash-funcs.h @@ -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); diff --git a/src/basic/hashmap.c b/src/basic/hashmap.c index 3366d8f60b3..bd6bdc359b0 100644 --- a/src/basic/hashmap.c +++ b/src/basic/hashmap.c @@ -1,23 +1,18 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include -#include -#include #if HAVE_VALGRIND_VALGRIND_H # include #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" diff --git a/src/basic/hashmap.h b/src/basic/hashmap.h index 52d3f45f0a9..3e8fc28ee07 100644 --- a/src/basic/hashmap.h +++ b/src/basic/hashmap.h @@ -1,13 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include - +#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 diff --git a/src/basic/hexdecoct.c b/src/basic/hexdecoct.c index a08a4697ac3..d0f3450e2c7 100644 --- a/src/basic/hexdecoct.c +++ b/src/basic/hexdecoct.c @@ -1,14 +1,10 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include -#include -#include -#include -#include +#include #include "alloc-util.h" #include "hexdecoct.h" -#include "macro.h" #include "memory-util.h" #include "string-util.h" diff --git a/src/basic/hexdecoct.h b/src/basic/hexdecoct.h index b456200e1b4..5841af0b7a6 100644 --- a/src/basic/hexdecoct.h +++ b/src/basic/hexdecoct.h @@ -1,12 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include - -#include "macro.h" +#include "forward.h" char octchar(int x) _const_; int unoctchar(char c) _const_; diff --git a/src/basic/hmac.c b/src/basic/hmac.c index a5f66d56056..d70b874e2cd 100644 --- a/src/basic/hmac.c +++ b/src/basic/hmac.c @@ -1,6 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include "hmac.h" diff --git a/src/basic/hmac.h b/src/basic/hmac.h index e58c1838a3d..fd474f7649f 100644 --- a/src/basic/hmac.h +++ b/src/basic/hmac.h @@ -1,9 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include - +#include "forward.h" #include "sha256.h" /* Unoptimized implementation based on FIPS 198. 'res' has to be allocated by diff --git a/src/basic/hostname-util.c b/src/basic/hostname-util.c index 5507303055c..673e1de3d42 100644 --- a/src/basic/hostname-util.c +++ b/src/basic/hostname-util.c @@ -1,11 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include -#include #include -#include -#include #include "alloc-util.h" #include "env-file.h" diff --git a/src/basic/hostname-util.h b/src/basic/hostname-util.h index 4c5abe760f0..d85391e59fc 100644 --- a/src/basic/hostname-util.h +++ b/src/basic/hostname-util.h @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include - -#include "macro.h" +#include "forward.h" #include "strv.h" char* get_default_hostname_raw(void); diff --git a/src/basic/in-addr-util.c b/src/basic/in-addr-util.c index 4e39985e275..aded2b93abf 100644 --- a/src/basic/in-addr-util.c +++ b/src/basic/in-addr-util.c @@ -2,23 +2,19 @@ #include #include -#include -#include -#include #include -#include #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, diff --git a/src/basic/in-addr-util.h b/src/basic/in-addr-util.h index 2efe9aec01c..a9491806ec5 100644 --- a/src/basic/in-addr-util.h +++ b/src/basic/in-addr-util.h @@ -1,13 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include #include -#include -#include -#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) \ diff --git a/src/basic/include/net/if.h b/src/basic/include/net/if.h index 7d5b61ba061..ba2948ae5c0 100644 --- a/src/basic/include/net/if.h +++ b/src/basic/include/net/if.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include /* IWYU pragma: export */ #define IF_NAMESIZE 16 diff --git a/src/basic/include/net/if_arp.h b/src/basic/include/net/if_arp.h index 7b384aeb73c..a414b6faf69 100644 --- a/src/basic/include/net/if_arp.h +++ b/src/basic/include/net/if_arp.h @@ -1,4 +1,4 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include /* IWYU pragma: export */ diff --git a/src/basic/include/netinet/in.h b/src/basic/include/netinet/in.h index 97475ac8821..8e11c864917 100644 --- a/src/basic/include/netinet/in.h +++ b/src/basic/include/netinet/in.h @@ -1,9 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include +#include /* IWYU pragma: export */ +#include /* IWYU pragma: export */ +#include /* IWYU pragma: export */ #include #include #include diff --git a/src/basic/include/sys/mount.h b/src/basic/include/sys/mount.h index 16cf080ab85..c79160aff47 100644 --- a/src/basic/include/sys/mount.h +++ b/src/basic/include/sys/mount.h @@ -2,6 +2,7 @@ #pragma once #include +#include /* IWYU pragma: export */ #include #include #include diff --git a/src/basic/initrd-util.c b/src/basic/initrd-util.c index 2478b0cc29d..c45920b3070 100644 --- a/src/basic/initrd-util.c +++ b/src/basic/initrd-util.c @@ -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; diff --git a/src/basic/initrd-util.h b/src/basic/initrd-util.h index 173093c069e..29e47828dab 100644 --- a/src/basic/initrd-util.h +++ b/src/basic/initrd-util.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include "forward.h" bool in_initrd(void); void in_initrd_force(bool value); diff --git a/src/basic/inotify-util.c b/src/basic/inotify-util.c index d8cbb045091..209f395e224 100644 --- a/src/basic/inotify-util.c +++ b/src/basic/inotify-util.c @@ -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, diff --git a/src/basic/inotify-util.h b/src/basic/inotify-util.h index 665fdacaa6c..a509a97f50e 100644 --- a/src/basic/inotify-util.h +++ b/src/basic/inotify-util.h @@ -1,12 +1,10 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include +#include /* IWYU pragma: export */ +#include -#include "log.h" +#include "forward.h" #define INOTIFY_EVENT_MAX (offsetof(struct inotify_event, name) + NAME_MAX + 1) diff --git a/src/basic/io-util.c b/src/basic/io-util.c index 7d7f34f2035..69c275ae179 100644 --- a/src/basic/io-util.c +++ b/src/basic/io-util.c @@ -1,14 +1,13 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include +#include #include +#include +#include #include #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) { diff --git a/src/basic/io-util.h b/src/basic/io-util.h index 208e168317d..f560b706b44 100644 --- a/src/basic/io-util.h +++ b/src/basic/io-util.h @@ -1,14 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include -#include - -#include "macro.h" -#include "time-util.h" +#include "forward.h" int flush_fd(int fd); diff --git a/src/basic/ioprio-util.c b/src/basic/ioprio-util.c index 49cd0f67e10..3add1bddd08 100644 --- a/src/basic/ioprio-util.c +++ b/src/basic/ioprio-util.c @@ -1,8 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include - -#include "assert-util.h" #include "ioprio-util.h" #include "parse-util.h" #include "string-table.h" diff --git a/src/basic/ioprio-util.h b/src/basic/ioprio-util.h index 376eb85dadc..0873d8ef616 100644 --- a/src/basic/ioprio-util.h +++ b/src/basic/ioprio-util.h @@ -1,9 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include /* IWYU pragma: export */ -#include "macro.h" +#include "forward.h" static inline int ioprio_prio_class(int value) { return IOPRIO_PRIO_CLASS(value); diff --git a/src/basic/iovec-util.h b/src/basic/iovec-util.h index d194195e745..f1e4be88d43 100644 --- a/src/basic/iovec-util.h +++ b/src/basic/iovec-util.h @@ -1,12 +1,10 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include +#include /* 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 */ diff --git a/src/basic/iovec-wrapper.c b/src/basic/iovec-wrapper.c index 27b84d2cdb9..5cc3cc2f93d 100644 --- a/src/basic/iovec-wrapper.c +++ b/src/basic/iovec-wrapper.c @@ -1,8 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include - #include "alloc-util.h" #include "iovec-util.h" #include "iovec-wrapper.h" diff --git a/src/basic/iovec-wrapper.h b/src/basic/iovec-wrapper.h index f45dd87b7ef..082d7e0ae00 100644 --- a/src/basic/iovec-wrapper.h +++ b/src/basic/iovec-wrapper.h @@ -1,11 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include - -#include "macro.h" -#include "memory-util.h" +#include "forward.h" struct iovec_wrapper { struct iovec *iovec; diff --git a/src/basic/iterator.h b/src/basic/iterator.h index 87cdd3c6559..be9e1a9b6bd 100644 --- a/src/basic/iterator.h +++ b/src/basic/iterator.h @@ -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. */ diff --git a/src/basic/keyring-util.c b/src/basic/keyring-util.c index 2a9b3d9aca9..6bfc5e38f62 100644 --- a/src/basic/keyring-util.c +++ b/src/basic/keyring-util.c @@ -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) { diff --git a/src/basic/keyring-util.h b/src/basic/keyring-util.h index 6e6e6856ada..a949f8907e1 100644 --- a/src/basic/keyring-util.h +++ b/src/basic/keyring-util.h @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - +#include "forward.h" #include "missing_keyctl.h" /* Like TAKE_PTR() but for key_serial_t, resetting them to -1 */ diff --git a/src/basic/label.c b/src/basic/label.c index b922fd2f191..cce3e75c7c1 100644 --- a/src/basic/label.c +++ b/src/basic/label.c @@ -1,11 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include - -#include "assert-util.h" #include "label.h" -#include "macro.h" static const LabelOps *label_ops = NULL; diff --git a/src/basic/label.h b/src/basic/label.h index d001307a4fd..186f93d697b 100644 --- a/src/basic/label.h +++ b/src/basic/label.h @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include +#include "forward.h" typedef struct LabelOps { int (*pre)(int dir_fd, const char *path, mode_t mode); diff --git a/src/basic/limits-util.c b/src/basic/limits-util.c index 5deaf9dda70..ffa89b04461 100644 --- a/src/basic/limits-util.c +++ b/src/basic/limits-util.c @@ -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; diff --git a/src/basic/limits-util.h b/src/basic/limits-util.h index d267fcf1d48..6049cfa9e9f 100644 --- a/src/basic/limits-util.h +++ b/src/basic/limits-util.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include "forward.h" uint64_t physical_memory(void); uint64_t physical_memory_scale(uint64_t v, uint64_t max); diff --git a/src/basic/list.h b/src/basic/list.h index 090bdc7b602..ee3405f0548 100644 --- a/src/basic/list.h +++ b/src/basic/list.h @@ -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 */ diff --git a/src/basic/locale-util.c b/src/basic/locale-util.c index 9121ce01f63..455b54bc61c 100644 --- a/src/basic/locale-util.c +++ b/src/basic/locale-util.c @@ -1,21 +1,15 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include -#include -#include -#include #include #include #include -#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" diff --git a/src/basic/locale-util.h b/src/basic/locale-util.h index da84799cf13..1ec6d3074ef 100644 --- a/src/basic/locale-util.h +++ b/src/basic/locale-util.h @@ -1,12 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include +#include /* IWYU pragma: export */ -#include "macro.h" +#include "forward.h" typedef enum LocaleVariable { /* We don't list LC_ALL here on purpose. People should be diff --git a/src/basic/lock-util.c b/src/basic/lock-util.c index f87ebb05c4b..5921cc8f931 100644 --- a/src/basic/lock-util.c +++ b/src/basic/lock-util.c @@ -1,13 +1,11 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include #include +#include #include #include -#include -#include #include "alloc-util.h" #include "errno-util.h" @@ -15,10 +13,10 @@ #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; diff --git a/src/basic/lock-util.h b/src/basic/lock-util.h index b327b8e5614..b9643c22a1c 100644 --- a/src/basic/lock-util.h +++ b/src/basic/lock-util.h @@ -1,11 +1,10 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include /* Include here so consumers have LOCK_{EX,SH,NB} available. */ -#include +#include /* IWYU pragma: export */ -#include "time-util.h" +#include "forward.h" typedef struct LockFile { int dir_fd; diff --git a/src/basic/log-context.h b/src/basic/log-context.h index 2b3a06aab64..a49bddd591b 100644 --- a/src/basic/log-context.h +++ b/src/basic/log-context.h @@ -1,12 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include - +#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 diff --git a/src/basic/log.c b/src/basic/log.c index 02211460b57..be036d6e738 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -1,16 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include -#include -#include -#include -#include #include #include -#include #include -#include #include #include @@ -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" diff --git a/src/basic/log.h b/src/basic/log.h index 07f187a24a9..4dfac9f4b3d 100644 --- a/src/basic/log.h +++ b/src/basic/log.h @@ -1,15 +1,11 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include +#include #include #include -#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; diff --git a/src/basic/login-util.c b/src/basic/login-util.c index 044e8b7650e..926e482fb0e 100644 --- a/src/basic/login-util.c +++ b/src/basic/login-util.c @@ -1,5 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include + #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; +} diff --git a/src/basic/login-util.h b/src/basic/login-util.h index f9ca34152b8..fd07ed2c6e8 100644 --- a/src/basic/login-util.h +++ b/src/basic/login-util.h @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include - -#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); diff --git a/src/basic/macro.h b/src/basic/macro.h index 03a05b13680..caefa7c57c6 100644 --- a/src/basic/macro.h +++ b/src/basic/macro.h @@ -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) diff --git a/src/basic/math-util.h b/src/basic/math-util.h index 24023cd2be3..2cdd655ce8c 100644 --- a/src/basic/math-util.h +++ b/src/basic/math-util.h @@ -1,9 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include /* 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. */ diff --git a/src/basic/memfd-util.c b/src/basic/memfd-util.c index f19d39470d7..d3a1a8457e0 100644 --- a/src/basic/memfd-util.c +++ b/src/basic/memfd-util.c @@ -1,6 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include #include @@ -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" diff --git a/src/basic/memfd-util.h b/src/basic/memfd-util.h index d7220d085da..efa2f7c616b 100644 --- a/src/basic/memfd-util.h +++ b/src/basic/memfd-util.h @@ -1,12 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include - -#include "macro.h" +#include "forward.h" int memfd_create_wrapper(const char *name, unsigned mode); diff --git a/src/basic/memory-util.h b/src/basic/memory-util.h index 523486db1ff..c36a0cc337a 100644 --- a/src/basic/memory-util.h +++ b/src/basic/memory-util.h @@ -1,16 +1,10 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include #include -#include -#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()) diff --git a/src/basic/mempool.c b/src/basic/mempool.c index 7bf83403153..3d9189857b1 100644 --- a/src/basic/mempool.c +++ b/src/basic/mempool.c @@ -1,11 +1,10 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include +#include #include #include "format-util.h" #include "log.h" -#include "macro.h" #include "memory-util.h" #include "mempool.h" diff --git a/src/basic/mempool.h b/src/basic/mempool.h index ba588af451e..69fbae18a5f 100644 --- a/src/basic/mempool.h +++ b/src/basic/mempool.h @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include +#include "forward.h" struct pool; diff --git a/src/basic/memstream-util.h b/src/basic/memstream-util.h index 1aa5651bcf9..8c979c7a0ad 100644 --- a/src/basic/memstream-util.h +++ b/src/basic/memstream-util.h @@ -1,9 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - -#include "macro.h" +#include "forward.h" typedef struct MemStream { FILE *f; diff --git a/src/basic/missing_audit.h b/src/basic/missing_audit.h index 3aaec1ee248..ff95e5e88a5 100644 --- a/src/basic/missing_audit.h +++ b/src/basic/missing_audit.h @@ -1,10 +1,10 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include /* IWYU pragma: export */ #if HAVE_AUDIT -# include +# include /* IWYU pragma: export */ #endif /* We use _Static_assert() directly here instead of assert_cc() diff --git a/src/basic/missing_bpf.h b/src/basic/missing_bpf.h index c0eb2ca76cd..968bcdfb2d7 100644 --- a/src/basic/missing_bpf.h +++ b/src/basic/missing_bpf.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include /* IWYU pragma: export */ /* defined in linux/filter.h */ /* Unconditional jumps, goto pc + off16 */ diff --git a/src/basic/missing_fcntl.h b/src/basic/missing_fcntl.h index b767186a4a6..64f37f5ee86 100644 --- a/src/basic/missing_fcntl.h +++ b/src/basic/missing_fcntl.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include /* IWYU pragma: export */ /* This is defined since glibc-2.41. */ #ifndef F_DUPFD_QUERY diff --git a/src/basic/missing_fs.h b/src/basic/missing_fs.h index 1e2f07e55f7..d07042a48ab 100644 --- a/src/basic/missing_fs.h +++ b/src/basic/missing_fs.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include /* IWYU pragma: export */ /* Not exposed yet. Defined at fs/ext4/ext4.h */ #ifndef EXT4_IOC_RESIZE_FS diff --git a/src/basic/missing_keyctl.h b/src/basic/missing_keyctl.h index 01063fd1935..8a9c82b9b45 100644 --- a/src/basic/missing_keyctl.h +++ b/src/basic/missing_keyctl.h @@ -1,10 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include +#include /* IWYU pragma: export */ -#include "macro.h" +#include "forward.h" /* From linux/key.h */ #ifndef KEY_POS_VIEW diff --git a/src/basic/missing_magic.h b/src/basic/missing_magic.h index fe54bbc7563..b5357d4f685 100644 --- a/src/basic/missing_magic.h +++ b/src/basic/missing_magic.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include /* IWYU pragma: export */ /* Not exposed yet (4.20). Defined at ipc/mqueue.c */ #ifndef MQUEUE_MAGIC diff --git a/src/basic/missing_mman.h b/src/basic/missing_mman.h index 29196b1c715..b3f79935fec 100644 --- a/src/basic/missing_mman.h +++ b/src/basic/missing_mman.h @@ -1,9 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include /* IWYU pragma: export */ -#include "macro.h" +#include "forward.h" /* since glibc-2.38 */ #ifndef MFD_NOEXEC_SEAL diff --git a/src/basic/missing_namespace.h b/src/basic/missing_namespace.h index b659a8edc33..e40b751b81d 100644 --- a/src/basic/missing_namespace.h +++ b/src/basic/missing_namespace.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include /* IWYU pragma: export */ #include /* Root namespace inode numbers, as per include/linux/proc_ns.h in the kernel source tree, since v3.8: diff --git a/src/basic/missing_network.h b/src/basic/missing_network.h index 86ea978d4a2..c5600d9fc67 100644 --- a/src/basic/missing_network.h +++ b/src/basic/missing_network.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include /* IWYU pragma: export */ /* linux/in.h or netinet/in.h (since glibc-2.32) */ #ifndef IPPROTO_MPTCP diff --git a/src/basic/missing_pidfd.h b/src/basic/missing_pidfd.h index 4c81514284e..968875e8959 100644 --- a/src/basic/missing_pidfd.h +++ b/src/basic/missing_pidfd.h @@ -3,7 +3,7 @@ #include #if HAVE_PIDFD_OPEN -#include +#include /* IWYU pragma: export */ #endif #ifndef PIDFS_IOCTL_MAGIC diff --git a/src/basic/missing_random.h b/src/basic/missing_random.h index 690021969e4..61b8c11ed0a 100644 --- a/src/basic/missing_random.h +++ b/src/basic/missing_random.h @@ -1,9 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include /* IWYU pragma: export */ -#include "macro.h" +#include "forward.h" /* Defined since glibc-2.32. */ #ifndef GRND_INSECURE diff --git a/src/basic/missing_sched.h b/src/basic/missing_sched.h index d8e2b6d3c77..d759ed38514 100644 --- a/src/basic/missing_sched.h +++ b/src/basic/missing_sched.h @@ -2,9 +2,9 @@ #pragma once #include -#include +#include /* IWYU pragma: export */ -#include "macro.h" +#include "forward.h" /* 769071ac9f20b6a447410c7eaa55d1a5233ef40c (5.8), * defined in sched.h since glibc-2.36. */ diff --git a/src/basic/missing_socket.h b/src/basic/missing_socket.h index 874e93f37ed..3a81dfff8ad 100644 --- a/src/basic/missing_socket.h +++ b/src/basic/missing_socket.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include /* IWYU pragma: export */ /* Supported since kernel v6.5 (5e2ff6704a275be009be8979af17c52361b79b89) */ #ifndef SO_PASSPIDFD diff --git a/src/basic/missing_syscall.h b/src/basic/missing_syscall.h index 296e39b919d..b02f0135aee 100644 --- a/src/basic/missing_syscall.h +++ b/src/basic/missing_syscall.h @@ -3,19 +3,15 @@ /* Missing glibc definitions to access certain kernel APIs */ -#include -#include #include #include -#include -#include #include #ifdef ARCH_MIPS #include #endif -#include "macro.h" +#include "forward.h" #include "missing_keyctl.h" #include "missing_sched.h" #include "missing_syscall_def.h" diff --git a/src/basic/missing_syscall_def.h b/src/basic/missing_syscall_def.h index c127532249d..fd8f3e5db54 100644 --- a/src/basic/missing_syscall_def.h +++ b/src/basic/missing_syscall_def.h @@ -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. */ diff --git a/src/basic/missing_wait.h b/src/basic/missing_wait.h index 05648779e3f..821df7a9716 100644 --- a/src/basic/missing_wait.h +++ b/src/basic/missing_wait.h @@ -1,9 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include /* IWYU pragma: export */ -#include "macro.h" +#include "forward.h" /* since glibc-2.36 */ #ifndef P_PIDFD diff --git a/src/basic/missing_xfs.h b/src/basic/missing_xfs.h index 67c4cefb87b..ead7dbc321f 100644 --- a/src/basic/missing_xfs.h +++ b/src/basic/missing_xfs.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#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 */ diff --git a/src/basic/mkdir.c b/src/basic/mkdir.c index fc2d36b33d5..a3a02b3e4eb 100644 --- a/src/basic/mkdir.c +++ b/src/basic/mkdir.c @@ -1,8 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include -#include +#include #include "alloc-util.h" #include "btrfs.h" @@ -12,11 +10,11 @@ #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( diff --git a/src/basic/mkdir.h b/src/basic/mkdir.h index 471f45b69a0..93af446ebfe 100644 --- a/src/basic/mkdir.h +++ b/src/basic/mkdir.h @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include - -#include "time-util.h" +#include "forward.h" typedef enum MkdirFlags { MKDIR_FOLLOW_SYMLINK = 1 << 0, diff --git a/src/basic/mountpoint-util.c b/src/basic/mountpoint-util.c index a66b9169d0a..b7c48709319 100644 --- a/src/basic/mountpoint-util.c +++ b/src/basic/mountpoint-util.c @@ -1,6 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include @@ -12,18 +11,14 @@ #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 diff --git a/src/basic/mountpoint-util.h b/src/basic/mountpoint-util.h index 9b3f2675aee..004d2b2af53 100644 --- a/src/basic/mountpoint-util.h +++ b/src/basic/mountpoint-util.h @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include +#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 diff --git a/src/basic/namespace-util.c b/src/basic/namespace-util.c index 2aa286bf364..f7d81cdc7d1 100644 --- a/src/basic/namespace-util.c +++ b/src/basic/namespace-util.c @@ -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; diff --git a/src/basic/namespace-util.h b/src/basic/namespace-util.h index 05ae1a0a95c..e0e857b7a49 100644 --- a/src/basic/namespace-util.h +++ b/src/basic/namespace-util.h @@ -1,9 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - -#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); diff --git a/src/basic/nulstr-util.c b/src/basic/nulstr-util.c index 3a98c5e4448..967b585a4d4 100644 --- a/src/basic/nulstr-util.c +++ b/src/basic/nulstr-util.c @@ -2,6 +2,7 @@ #include "alloc-util.h" #include "nulstr-util.h" +#include "set.h" #include "string-util.h" #include "strv.h" diff --git a/src/basic/nulstr-util.h b/src/basic/nulstr-util.h index 6a6c15a2e43..600667f3c1b 100644 --- a/src/basic/nulstr-util.h +++ b/src/basic/nulstr-util.h @@ -1,13 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include #include -#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) diff --git a/src/basic/ordered-set.c b/src/basic/ordered-set.c index b59a9e5f1b9..9b4ff5ff39c 100644 --- a/src/basic/ordered-set.c +++ b/src/basic/ordered-set.c @@ -1,5 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include +#include +#include + #include "fileio.h" #include "ordered-set.h" #include "strv.h" diff --git a/src/basic/ordered-set.h b/src/basic/ordered-set.h index 77661ced66a..34f585c9bc2 100644 --- a/src/basic/ordered-set.h +++ b/src/basic/ordered-set.h @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - +#include "forward.h" #include "hashmap.h" typedef struct OrderedSet OrderedSet; diff --git a/src/basic/os-util.c b/src/basic/os-util.c index 3187c0bd9f1..be845e2af77 100644 --- a/src/basic/os-util.c +++ b/src/basic/os-util.c @@ -1,24 +1,23 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include + #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" diff --git a/src/basic/os-util.h b/src/basic/os-util.h index 071c9080b71..5051a39075c 100644 --- a/src/basic/os-util.h +++ b/src/basic/os-util.h @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include - -#include "time-util.h" +#include "forward.h" typedef enum ImageClass { IMAGE_MACHINE, diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c index a10990dbe04..dfe311b0435 100644 --- a/src/basic/parse-util.c +++ b/src/basic/parse-util.c @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include #include #include -#include #include #include #include @@ -14,11 +11,9 @@ #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" diff --git a/src/basic/parse-util.h b/src/basic/parse-util.h index 0af407b335b..4c251d2e96d 100644 --- a/src/basic/parse-util.h +++ b/src/basic/parse-util.h @@ -1,13 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include -#include - -#include "macro.h" +#include "forward.h" typedef unsigned long loadavg_t; diff --git a/src/basic/path-util.c b/src/basic/path-util.c index 2fd568743ae..dd23d3f6ab0 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -1,8 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include -#include #include #include #include @@ -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" diff --git a/src/basic/path-util.h b/src/basic/path-util.h index fabb0eac88c..1cc1fce1e09 100644 --- a/src/basic/path-util.h +++ b/src/basic/path-util.h @@ -1,11 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include - -#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" diff --git a/src/basic/pcapng.h b/src/basic/pcapng.h index 28ad0768775..ff2560c4044 100644 --- a/src/basic/pcapng.h +++ b/src/basic/pcapng.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include "forward.h" /* * For details about the file format see RFC: diff --git a/src/basic/percent-util.c b/src/basic/percent-util.c index b2625d0bb27..c205b10b09c 100644 --- a/src/basic/percent-util.c +++ b/src/basic/percent-util.c @@ -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" diff --git a/src/basic/percent-util.h b/src/basic/percent-util.h index dd70d59dba0..60b0d4a9ef5 100644 --- a/src/basic/percent-util.h +++ b/src/basic/percent-util.h @@ -1,11 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include - -#include "macro.h" +#include "forward.h" int parse_percent_unbounded(const char *p); int parse_percent(const char *p); diff --git a/src/basic/pidfd-util.c b/src/basic/pidfd-util.c index 54724a40b06..f53a94f2d3e 100644 --- a/src/basic/pidfd-util.c +++ b/src/basic/pidfd-util.c @@ -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; diff --git a/src/basic/pidfd-util.h b/src/basic/pidfd-util.h index c20de6df676..774f97018a7 100644 --- a/src/basic/pidfd-util.h +++ b/src/basic/pidfd-util.h @@ -1,11 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include - -#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); diff --git a/src/basic/pidref.c b/src/basic/pidref.c index 47ecfaacdef..eeccc537c90 100644 --- a/src/basic/pidref.c +++ b/src/basic/pidref.c @@ -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; diff --git a/src/basic/pidref.h b/src/basic/pidref.h index 6084f9cf89f..724871842b9 100644 --- a/src/basic/pidref.h +++ b/src/basic/pidref.h @@ -1,11 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include #include -#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 diff --git a/src/basic/prioq.c b/src/basic/prioq.c index ed9b33e59de..157c081eb45 100644 --- a/src/basic/prioq.c +++ b/src/basic/prioq.c @@ -10,11 +10,7 @@ * The underlying algorithm used in this implementation is a Heap. */ -#include -#include - #include "alloc-util.h" -#include "hashmap.h" #include "prioq.h" struct prioq_item { diff --git a/src/basic/prioq.h b/src/basic/prioq.h index 204ba54faee..97b4f40b4ac 100644 --- a/src/basic/prioq.h +++ b/src/basic/prioq.h @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - -#include "hashmap.h" -#include "macro.h" +#include "forward.h" typedef struct Prioq Prioq; diff --git a/src/basic/proc-cmdline.c b/src/basic/proc-cmdline.c index 7f8e32f6795..fd9cfbae283 100644 --- a/src/basic/proc-cmdline.c +++ b/src/basic/proc-cmdline.c @@ -1,15 +1,13 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include +#include #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; +} diff --git a/src/basic/proc-cmdline.h b/src/basic/proc-cmdline.h index 0e7039ed434..8eb905de3d6 100644 --- a/src/basic/proc-cmdline.h +++ b/src/basic/proc-cmdline.h @@ -1,9 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - -#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); diff --git a/src/basic/process-util.c b/src/basic/process-util.c index 945d95d7d66..e05329b4069 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -1,18 +1,12 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include -#include #include #include #include -#include #include -#include #include #include #include -#include #include #include #include @@ -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" @@ -59,10 +52,8 @@ #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 diff --git a/src/basic/process-util.h b/src/basic/process-util.h index 9ae36cf6090..c636b6d14a8 100644 --- a/src/basic/process-util.h +++ b/src/basic/process-util.h @@ -1,23 +1,12 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include #include -#include -#include -#include -#include -#include -#include - -#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" */ diff --git a/src/basic/procfs-util.c b/src/basic/procfs-util.c index 1b09905515d..47f460e4f1b 100644 --- a/src/basic/procfs-util.c +++ b/src/basic/procfs-util.c @@ -1,18 +1,17 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #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; diff --git a/src/basic/procfs-util.h b/src/basic/procfs-util.h index eb8c7738b16..a0de848c82d 100644 --- a/src/basic/procfs-util.h +++ b/src/basic/procfs-util.h @@ -1,9 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - -#include "time-util.h" +#include "forward.h" int procfs_get_pid_max(uint64_t *ret); int procfs_get_threads_max(uint64_t *ret); diff --git a/src/basic/psi-util.c b/src/basic/psi-util.c index 1e4de3d8a71..df1ccbc1b20 100644 --- a/src/basic/psi-util.c +++ b/src/basic/psi-util.c @@ -2,7 +2,6 @@ #include #include -#include #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" diff --git a/src/basic/psi-util.h b/src/basic/psi-util.h index bf8f4fe51c2..3029e091a41 100644 --- a/src/basic/psi-util.h +++ b/src/basic/psi-util.h @@ -1,10 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - +#include "forward.h" #include "parse-util.h" -#include "time-util.h" typedef enum PressureType { PRESSURE_TYPE_SOME, diff --git a/src/basic/pthread-util.h b/src/basic/pthread-util.h index 4707f5503aa..362944efc8e 100644 --- a/src/basic/pthread-util.h +++ b/src/basic/pthread-util.h @@ -1,9 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include /* 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); diff --git a/src/basic/random-util.c b/src/basic/random-util.c index c63819e42a2..486a523bc52 100644 --- a/src/basic/random-util.c +++ b/src/basic/random-util.c @@ -1,28 +1,20 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include -#include #include #include -#include -#include -#include #include #include #include -#include #include #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" diff --git a/src/basic/random-util.h b/src/basic/random-util.h index 587ca1c2832..28bdb583c0f 100644 --- a/src/basic/random-util.h +++ b/src/basic/random-util.h @@ -1,12 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include - -#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. */ diff --git a/src/basic/ratelimit.c b/src/basic/ratelimit.c index 351fcac3bdd..48ad08f3b67 100644 --- a/src/basic/ratelimit.c +++ b/src/basic/ratelimit.c @@ -1,11 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include - -#include "assert-util.h" -#include "macro.h" #include "ratelimit.h" +#include "time-util.h" /* Modelled after Linux' lib/ratelimit.c by Dave Young * , which is licensed GPLv2. */ diff --git a/src/basic/ratelimit.h b/src/basic/ratelimit.h index 7801ef4270a..321cfbbb446 100644 --- a/src/basic/ratelimit.h +++ b/src/basic/ratelimit.h @@ -1,9 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - -#include "time-util.h" +#include "forward.h" typedef struct RateLimit { usec_t interval; /* Keep those two fields first so they can be initialized easily: */ diff --git a/src/basic/recurse-dir.c b/src/basic/recurse-dir.c index 666d17d3aad..36945265473 100644 --- a/src/basic/recurse-dir.c +++ b/src/basic/recurse-dir.c @@ -1,12 +1,14 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include + #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" diff --git a/src/basic/recurse-dir.h b/src/basic/recurse-dir.h index 82af043b15d..5e9548b0466 100644 --- a/src/basic/recurse-dir.h +++ b/src/basic/recurse-dir.h @@ -2,11 +2,8 @@ #pragma once #include -#include -#include "errno-list.h" -#include "macro.h" -#include "stat-util.h" +#include "forward.h" typedef enum RecurseDirFlags { /* Interpreted by readdir_all() */ diff --git a/src/basic/replace-var.c b/src/basic/replace-var.c index 4813ac3d2ba..1ff79dd84a6 100644 --- a/src/basic/replace-var.c +++ b/src/basic/replace-var.c @@ -1,11 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include -#include - #include "alloc-util.h" -#include "macro.h" #include "replace-var.h" #include "string-util.h" diff --git a/src/basic/replace-var.h b/src/basic/replace-var.h index 8b9b2aa5ba1..abaa57b503d 100644 --- a/src/basic/replace-var.h +++ b/src/basic/replace-var.h @@ -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); diff --git a/src/basic/rlimit-util.c b/src/basic/rlimit-util.c index d5763b5f9e2..803eaa09b26 100644 --- a/src/basic/rlimit-util.c +++ b/src/basic/rlimit-util.c @@ -1,7 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include - #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" diff --git a/src/basic/rlimit-util.h b/src/basic/rlimit-util.h index dd1fef43968..52ec8bd3203 100644 --- a/src/basic/rlimit-util.h +++ b/src/basic/rlimit-util.h @@ -1,10 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include +#include /* IWYU pragma: export */ -#include "macro.h" +#include "forward.h" #define _RLIMIT_MAX RLIMIT_NLIMITS diff --git a/src/basic/runtime-scope.h b/src/basic/runtime-scope.h index ba900fed1e7..54c797e742d 100644 --- a/src/basic/runtime-scope.h +++ b/src/basic/runtime-scope.h @@ -1,9 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - -#include "macro.h" +#include "forward.h" typedef enum RuntimeScope { RUNTIME_SCOPE_SYSTEM, /* for the system */ diff --git a/src/basic/set.h b/src/basic/set.h index 9dd7bd403db..e6ce91c752b 100644 --- a/src/basic/set.h +++ b/src/basic/set.h @@ -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) diff --git a/src/basic/sha256.c b/src/basic/sha256.c index c4c2e85cec3..31e535d4d29 100644 --- a/src/basic/sha256.c +++ b/src/basic/sha256.c @@ -1,12 +1,11 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #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); +} diff --git a/src/basic/sha256.h b/src/basic/sha256.h index 95bac1bc1db..3711292958a 100644 --- a/src/basic/sha256.h +++ b/src/basic/sha256.h @@ -2,15 +2,11 @@ #pragma once -#include - -#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); diff --git a/src/basic/sigbus.c b/src/basic/sigbus.c index 9adba5eb72b..a530476d537 100644 --- a/src/basic/sigbus.c +++ b/src/basic/sigbus.c @@ -1,15 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include -#include #include -#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" diff --git a/src/basic/sigbus.h b/src/basic/sigbus.h index a40b1a87aa0..cf7593072dd 100644 --- a/src/basic/sigbus.h +++ b/src/basic/sigbus.h @@ -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); diff --git a/src/basic/signal-util.c b/src/basic/signal-util.c index f5afe343076..4080d96792f 100644 --- a/src/basic/signal-util.c +++ b/src/basic/signal-util.c @@ -1,11 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include #include #include "errno-util.h" -#include "macro.h" #include "missing_syscall.h" #include "parse-util.h" #include "signal-util.h" diff --git a/src/basic/signal-util.h b/src/basic/signal-util.h index d64d5031243..5a253583a76 100644 --- a/src/basic/signal-util.h +++ b/src/basic/signal-util.h @@ -1,10 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include /* IWYU pragma: export */ -#include "assert-util.h" -#include "macro.h" +#include "forward.h" int reset_all_signal_handlers(void); int reset_signal_mask(void); diff --git a/src/basic/siphash24.c b/src/basic/siphash24.c index b614ecf11a1..72d6bbe4f0c 100644 --- a/src/basic/siphash24.c +++ b/src/basic/siphash24.c @@ -21,8 +21,8 @@ #include -#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); +} diff --git a/src/basic/siphash24.h b/src/basic/siphash24.h index 2ef4a0498a8..61d83233a58 100644 --- a/src/basic/siphash24.h +++ b/src/basic/siphash24.h @@ -2,13 +2,7 @@ #pragma once -#include -#include -#include -#include - -#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]); diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c index 919884ba472..9cce0e129a3 100644 --- a/src/basic/socket-util.c +++ b/src/basic/socket-util.c @@ -1,8 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include -#include +#include #include #include #include @@ -10,10 +8,7 @@ #include #include #include -#include -#include #include -#include #include #include @@ -21,22 +16,23 @@ #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); diff --git a/src/basic/socket-util.h b/src/basic/socket-util.h index dea93dbde89..a5a1d8775da 100644 --- a/src/basic/socket-util.h +++ b/src/basic/socket-util.h @@ -1,27 +1,19 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include #include #include #include #include #include #include -#include -#include -#include #include -#include #include -#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; diff --git a/src/basic/sort-util.c b/src/basic/sort-util.c index 59329dff31c..1adbba8fcf4 100644 --- a/src/basic/sort-util.c +++ b/src/basic/sort-util.c @@ -1,5 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include + #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); } diff --git a/src/basic/sort-util.h b/src/basic/sort-util.h index 2820f2327c3..8b6d2aaddf3 100644 --- a/src/basic/sort-util.h +++ b/src/basic/sort-util.h @@ -1,16 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - -#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) \ ({ \ diff --git a/src/basic/sparse-endian.h b/src/basic/sparse-endian.h index c795d3da8f2..d66e77afc2e 100644 --- a/src/basic/sparse-endian.h +++ b/src/basic/sparse-endian.h @@ -24,7 +24,8 @@ #include #include -#include + +#include "forward.h" #ifdef __CHECKER__ #define __sd_bitwise __attribute__((__bitwise__)) diff --git a/src/basic/stat-util.c b/src/basic/stat-util.c index f3a1db5ed7e..237d8e08537 100644 --- a/src/basic/stat-util.c +++ b/src/basic/stat-util.c @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include -#include #include -#include #include #include "alloc-util.h" @@ -12,19 +9,17 @@ #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); diff --git a/src/basic/stat-util.h b/src/basic/stat-util.h index 2c5f7b9e93a..1087c264f0a 100644 --- a/src/basic/stat-util.h +++ b/src/basic/stat-util.h @@ -1,18 +1,10 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include -#include -#include -#include - -#include "fs-util.h" -#include "macro.h" -#include "siphash24.h" -#include "time-util.h" +#include /* IWYU pragma: export */ +#include /* 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); diff --git a/src/basic/static-destruct.c b/src/basic/static-destruct.c index f8006c86ddc..c39a1b38164 100644 --- a/src/basic/static-destruct.c +++ b/src/basic/static-destruct.c @@ -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) { diff --git a/src/basic/static-destruct.h b/src/basic/static-destruct.h index aaafbbc478b..3502d192e2f 100644 --- a/src/basic/static-destruct.h +++ b/src/basic/static-destruct.h @@ -2,10 +2,7 @@ #pragma once -#include - -#include "macro.h" -#include "memory-util.h" +#include "forward.h" typedef void (*free_func_t)(void *p); diff --git a/src/basic/stdio-util.h b/src/basic/stdio-util.h index bd5871821c4..54640314346 100644 --- a/src/basic/stdio-util.h +++ b/src/basic/stdio-util.h @@ -2,12 +2,9 @@ #pragma once #include -#include #include -#include -#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, ...) { diff --git a/src/basic/strbuf.c b/src/basic/strbuf.c index a53d7335948..c2342e67a22 100644 --- a/src/basic/strbuf.c +++ b/src/basic/strbuf.c @@ -1,7 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include #include #include "alloc-util.h" diff --git a/src/basic/strbuf.h b/src/basic/strbuf.h index 143e39f0f0d..68baaffb40c 100644 --- a/src/basic/strbuf.h +++ b/src/basic/strbuf.h @@ -1,11 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include - -#include "memory-util.h" +#include "forward.h" struct strbuf { char *buf; diff --git a/src/basic/string-table.c b/src/basic/string-table.c index 30c912adb66..fa3cc15743d 100644 --- a/src/basic/string-table.c +++ b/src/basic/string-table.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include +#include #include "parse-util.h" #include "string-table.h" diff --git a/src/basic/string-table.h b/src/basic/string-table.h index c91bed99a10..7e0569a4894 100644 --- a/src/basic/string-table.h +++ b/src/basic/string-table.h @@ -2,11 +2,7 @@ #pragma once -#include -#include -#include - -#include "macro.h" +#include "forward.h" const char* string_table_lookup_to_string(const char * const *table, size_t len, ssize_t i) _const_; diff --git a/src/basic/string-util.c b/src/basic/string-util.c index de24e60a148..d2c538cfc4b 100644 --- a/src/basic/string-util.c +++ b/src/basic/string-util.c @@ -1,21 +1,14 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include -#include #include -#include #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" diff --git a/src/basic/string-util.h b/src/basic/string-util.h index b68bf291fea..f28d9f12aac 100644 --- a/src/basic/string-util.h +++ b/src/basic/string-util.h @@ -1,14 +1,11 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include #include -#include #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) diff --git a/src/basic/strv.c b/src/basic/strv.c index 67e3d4f4ccf..37f4bd44f3f 100644 --- a/src/basic/strv.c +++ b/src/basic/strv.c @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include -#include #include -#include #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; diff --git a/src/basic/strv.h b/src/basic/strv.h index 8058df44a05..55eb020d569 100644 --- a/src/basic/strv.h +++ b/src/basic/strv.h @@ -1,17 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include - -#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); diff --git a/src/basic/strxcpyx.c b/src/basic/strxcpyx.c index 52b95650cf3..9126e1dfe26 100644 --- a/src/basic/strxcpyx.c +++ b/src/basic/strxcpyx.c @@ -11,11 +11,9 @@ * occur outside of a loop where this is the preferred behavior. */ -#include #include #include -#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) { diff --git a/src/basic/strxcpyx.h b/src/basic/strxcpyx.h index 4a648ed033b..7d045fe8d22 100644 --- a/src/basic/strxcpyx.h +++ b/src/basic/strxcpyx.h @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include - -#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) { diff --git a/src/basic/sync-util.c b/src/basic/sync-util.c index eb9c9f1a6e8..d9a53175ab4 100644 --- a/src/basic/sync-util.c +++ b/src/basic/sync-util.c @@ -2,6 +2,7 @@ #include #include +#include #include "alloc-util.h" #include "errno-util.h" diff --git a/src/basic/sync-util.h b/src/basic/sync-util.h index e449440a530..c464a656d44 100644 --- a/src/basic/sync-util.h +++ b/src/basic/sync-util.h @@ -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); diff --git a/src/basic/sysctl-util.c b/src/basic/sysctl-util.c index 5ffb31ec012..ae70abe6278 100644 --- a/src/basic/sysctl-util.c +++ b/src/basic/sysctl-util.c @@ -1,16 +1,12 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include #include -#include #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; diff --git a/src/basic/sysctl-util.h b/src/basic/sysctl-util.h index f3ae6fe7cf2..ef08376916c 100644 --- a/src/basic/sysctl-util.h +++ b/src/basic/sysctl-util.h @@ -1,13 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#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) { \ diff --git a/src/basic/syslog-util.c b/src/basic/syslog-util.c index 18194f70d97..fd910ca76d4 100644 --- a/src/basic/syslog-util.c +++ b/src/basic/syslog-util.c @@ -1,15 +1,14 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #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" diff --git a/src/basic/syslog-util.h b/src/basic/syslog-util.h index d7aa97fb7d8..dff09db2396 100644 --- a/src/basic/syslog-util.h +++ b/src/basic/syslog-util.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include +#include "forward.h" int log_facility_unshifted_to_string_alloc(int i, char **s); int log_facility_unshifted_from_string(const char *s); diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 00cdd02eca8..51b3a83d29d 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -1,42 +1,32 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include -#include #include #include #include #include #include -#include -#include #include #include #include #include -#include -#include -#include #include +#include #include #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" @@ -47,12 +37,10 @@ #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)); diff --git a/src/basic/terminal-util.h b/src/basic/terminal-util.h index 376d1fe3012..17dbdfdfd58 100644 --- a/src/basic/terminal-util.h +++ b/src/basic/terminal-util.h @@ -1,17 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include -#include -#include -#include - -#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); diff --git a/src/basic/time-util.c b/src/basic/time-util.c index 86c8d71a4a2..1a86f7fdee5 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -1,13 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include -#include #include #include -#include #include -#include #include #include @@ -19,11 +14,11 @@ #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" diff --git a/src/basic/time-util.h b/src/basic/time-util.h index 83d7e660ac8..90c17c39b17 100644 --- a/src/basic/time-util.h +++ b/src/basic/time-util.h @@ -1,24 +1,15 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include -#include -#include #include -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; diff --git a/src/basic/tmpfile-util.c b/src/basic/tmpfile-util.c index 0debd249ad0..6e2069de7cb 100644 --- a/src/basic/tmpfile-util.c +++ b/src/basic/tmpfile-util.c @@ -1,23 +1,16 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include +#include +#include #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" diff --git a/src/basic/tmpfile-util.h b/src/basic/tmpfile-util.h index 5b94837d35a..b39680f078b 100644 --- a/src/basic/tmpfile-util.h +++ b/src/basic/tmpfile-util.h @@ -1,9 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include +#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) { diff --git a/src/basic/uid-classification.h b/src/basic/uid-classification.h index c60daf5dcc3..bd87ffc80d7 100644 --- a/src/basic/uid-classification.h +++ b/src/basic/uid-classification.h @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include - -#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); diff --git a/src/basic/uid-range.c b/src/basic/uid-range.c index 542f00cadaa..109bef51cbb 100644 --- a/src/basic/uid-range.c +++ b/src/basic/uid-range.c @@ -1,15 +1,11 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include #include #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; diff --git a/src/basic/uid-range.h b/src/basic/uid-range.h index e1965cf9b7d..5f3c0335243 100644 --- a/src/basic/uid-range.h +++ b/src/basic/uid-range.h @@ -1,11 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include - -#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); diff --git a/src/basic/umask-util.h b/src/basic/umask-util.h index 00417fa3045..1f9ea2bf2b1 100644 --- a/src/basic/umask-util.h +++ b/src/basic/umask-util.h @@ -1,11 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include #include -#include -#include "macro.h" +#include "forward.h" static inline void umaskp(mode_t *u) { umask(*u); diff --git a/src/basic/unaligned.h b/src/basic/unaligned.h index 04580cfb636..61ee82b7730 100644 --- a/src/basic/unaligned.h +++ b/src/basic/unaligned.h @@ -2,9 +2,9 @@ #pragma once #include -#include -#include "unaligned-fundamental.h" +#include "forward.h" +#include "unaligned-fundamental.h" /* IWYU pragma: export */ /* BE */ diff --git a/src/basic/unit-def.c b/src/basic/unit-def.c index d9ef13b103a..89c7f937908 100644 --- a/src/basic/unit-def.c +++ b/src/basic/unit-def.c @@ -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" diff --git a/src/basic/unit-def.h b/src/basic/unit-def.h index a55b6c3be0b..a8779769e31 100644 --- a/src/basic/unit-def.h +++ b/src/basic/unit-def.h @@ -1,11 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - -#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. diff --git a/src/basic/unit-name.c b/src/basic/unit-name.c index f38f6386c12..6a42ece0b3e 100644 --- a/src/basic/unit-name.c +++ b/src/basic/unit-name.c @@ -1,25 +1,18 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include -#include -#include -#include - #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. */ diff --git a/src/basic/unit-name.h b/src/basic/unit-name.h index 44354541c4c..50fe3ac8e98 100644 --- a/src/basic/unit-name.h +++ b/src/basic/unit-name.h @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include - -#include "macro.h" -#include "unit-def.h" +#include "forward.h" #define UNIT_NAME_MAX 256 diff --git a/src/basic/user-util.c b/src/basic/user-util.c index 3936192f391..3950a5aa14b 100644 --- a/src/basic/user-util.c +++ b/src/basic/user-util.c @@ -1,9 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include -#include -#include #include #include #include @@ -22,11 +19,9 @@ #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, diff --git a/src/basic/user-util.h b/src/basic/user-util.h index 983db1138e2..c2c7d3983d5 100644 --- a/src/basic/user-util.h +++ b/src/basic/user-util.h @@ -7,12 +7,8 @@ #endif #include #include -#include -#include -#include -#include -#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 */ diff --git a/src/basic/utf8.c b/src/basic/utf8.c index 633d86c6cf7..8a0cfc012ec 100644 --- a/src/basic/utf8.c +++ b/src/basic/utf8.c @@ -7,14 +7,9 @@ * Copyright (C) 2000 Red Hat, Inc. */ -#include -#include -#include - #include "alloc-util.h" #include "gunicode.h" #include "hexdecoct.h" -#include "macro.h" #include "string-util.h" #include "utf8.h" diff --git a/src/basic/utf8.h b/src/basic/utf8.h index 3b1a468c4f4..e5368205bd5 100644 --- a/src/basic/utf8.h +++ b/src/basic/utf8.h @@ -1,12 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include - -#include "macro.h" +#include "forward.h" #define UTF8_REPLACEMENT_CHARACTER "\xef\xbf\xbd" #define UTF8_BYTE_ORDER_MARK "\xef\xbb\xbf" diff --git a/src/basic/virt.c b/src/basic/virt.c index 5717a1d2b41..f11d5c235ac 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -3,8 +3,6 @@ #if defined(__i386__) || defined(__x86_64__) #include #endif -#include -#include #include #include #include @@ -12,16 +10,14 @@ #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" diff --git a/src/basic/virt.h b/src/basic/virt.h index e4fdaca9769..cac3f4496c6 100644 --- a/src/basic/virt.h +++ b/src/basic/virt.h @@ -1,11 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include - -#include "errno-list.h" -#include "macro.h" +#include "forward.h" typedef enum Virtualization { VIRTUALIZATION_NONE = 0, diff --git a/src/basic/xattr-util.c b/src/basic/xattr-util.c index 9256bd4b1a4..15072add780 100644 --- a/src/basic/xattr-util.c +++ b/src/basic/xattr-util.c @@ -1,23 +1,18 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include -#include -#include -#include #include #include #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" diff --git a/src/basic/xattr-util.h b/src/basic/xattr-util.h index 773e736cfb9..cf68933bfe3 100644 --- a/src/basic/xattr-util.h +++ b/src/basic/xattr-util.h @@ -1,12 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include -#include -#include -#include - -#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) { diff --git a/src/fundamental/chid-fundamental.h b/src/fundamental/chid-fundamental.h index 5c210e006a3..a0e77dd9b02 100644 --- a/src/fundamental/chid-fundamental.h +++ b/src/fundamental/chid-fundamental.h @@ -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 */ diff --git a/src/fundamental/edid-fundamental.c b/src/fundamental/edid-fundamental.c index 9657d967044..bfd314e4445 100644 --- a/src/fundamental/edid-fundamental.c +++ b/src/fundamental/edid-fundamental.c @@ -1,5 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#if !SD_BOOT +#include +#endif + #include "edid-fundamental.h" #include "efivars-fundamental.h" diff --git a/src/fundamental/edid-fundamental.h b/src/fundamental/edid-fundamental.h index 52473784d90..2a76c4524de 100644 --- a/src/fundamental/edid-fundamental.h +++ b/src/fundamental/edid-fundamental.h @@ -5,13 +5,12 @@ # include "efi-string.h" # include "util.h" #else -# include # include # include # include #endif -#include "string-util-fundamental.h" +#include "macro-fundamental.h" /* EDID structure, version 1.4 */ typedef struct EdidHeader { diff --git a/src/fundamental/sha256-fundamental.c b/src/fundamental/sha256-fundamental.c index 108c43b45aa..bbf84ee9d60 100644 --- a/src/fundamental/sha256-fundamental.c +++ b/src/fundamental/sha256-fundamental.c @@ -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" diff --git a/src/fundamental/string-util-fundamental.c b/src/fundamental/string-util-fundamental.c index c2b58889db2..0141b42e397 100644 --- a/src/fundamental/string-util-fundamental.c +++ b/src/fundamental/string-util-fundamental.c @@ -1,9 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#if !SD_BOOT -# include -#endif - #include "macro-fundamental.h" #include "string-util-fundamental.h" diff --git a/src/fundamental/tpm2-pcr.h b/src/fundamental/tpm2-pcr.h index d8728bf88e9..1d39ba59596 100644 --- a/src/fundamental/tpm2-pcr.h +++ b/src/fundamental/tpm2-pcr.h @@ -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 { diff --git a/src/fundamental/uki.h b/src/fundamental/uki.h index 6752b2ae77c..8d67b13b8b5 100644 --- a/src/fundamental/uki.h +++ b/src/fundamental/uki.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "macro-fundamental.h" +#include /* 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! */