]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
iovec-util: Reduce transitive includes
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 5 May 2025 12:15:47 +0000 (14:15 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 7 May 2025 13:04:46 +0000 (22:04 +0900)
27 files changed:
src/analyze/analyze-pcrs.c
src/analyze/analyze-srk.c
src/basic/iovec-util.c
src/basic/iovec-util.h
src/basic/log-context.c
src/bootctl/bootctl-install.c
src/bootctl/bootctl-set-efivar.c
src/bootctl/bootctl-status.c
src/bootctl/bootctl-util.c
src/cryptsetup/cryptsetup-keyfile.c
src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-fido2.c
src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-tpm2.c
src/cryptsetup/cryptsetup-tokens/luks2-fido2.c
src/home/homectl-fido2.c
src/home/user-record-sign.c
src/libsystemd-network/icmp6-packet.c
src/libsystemd-network/ndisc-option.c
src/libsystemd-network/sd-dhcp-server-lease.c
src/libsystemd/sd-netlink/netlink-message-nfnl.c
src/network/networkd-serialize.c
src/resolve/resolved-dnstls.c
src/shared/bootspec.c
src/shared/creds-util.c
src/shared/fido2-util.c
src/shared/kernel-image.c
src/shared/openssl-util.h
src/shared/pkcs11-util.c

index 23f8f0773d8cd5f92a5ec5c64194f21f63be1e6d..f00f4c95a128a42fff6e6eac7489971425d69239 100644 (file)
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include "alloc-util.h"
 #include "analyze.h"
 #include "analyze-pcrs.h"
 #include "fileio.h"
index adbc51316afd47772897c78400206211e4e9eb22..973f92e64cf029b7513571f826db62ad3474029f 100644 (file)
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include "alloc-util.h"
 #include "analyze.h"
 #include "analyze-srk.h"
 #include "fileio.h"
index 76f7f5f29eb4b27b57c911c11deb28d943a35543..ec8af57e6424ff50d2765de03c8dd1eb6d8043ba 100644 (file)
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include "alloc-util.h"
 #include "iovec-util.h"
 #include "string-util.h"
 
@@ -51,6 +52,20 @@ bool iovec_increment(struct iovec *iovec, size_t n, size_t k) {
         return true;
 }
 
+struct iovec* iovec_make_string(struct iovec *iovec, const char *s) {
+        assert(iovec);
+
+        *iovec = IOVEC_MAKE(s, strlen_ptr(s));
+        return iovec;
+}
+
+void iovec_done_erase(struct iovec *iovec) {
+        assert(iovec);
+
+        iovec->iov_base = erase_and_free(iovec->iov_base);
+        iovec->iov_len = 0;
+}
+
 char* set_iovec_string_field(struct iovec *iovec, size_t *n_iovec, const char *field, const char *value) {
         char *x;
 
@@ -83,6 +98,33 @@ void iovec_array_free(struct iovec *iovec, size_t n_iovec) {
         free(iovec);
 }
 
+int iovec_memcmp(const struct iovec *a, const struct iovec *b) {
+
+        if (a == b)
+                return 0;
+
+        return memcmp_nn(a ? a->iov_base : NULL,
+                         a ? a->iov_len : 0,
+                         b ? b->iov_base : NULL,
+                         b ? b->iov_len : 0);
+}
+
+struct iovec* iovec_memdup(const struct iovec *source, struct iovec *ret) {
+        assert(ret);
+
+        if (!iovec_is_set(source))
+                *ret = (struct iovec) {};
+        else {
+                void *p = memdup(source->iov_base, source->iov_len);
+                if (!p)
+                        return NULL;
+
+                *ret = IOVEC_MAKE(p, source->iov_len);
+        }
+
+        return ret;
+}
+
 struct iovec* iovec_append(struct iovec *iovec, const struct iovec *append) {
         assert(iovec_is_valid(iovec));
 
index ace20098c88caf71a7a0891e212da3c03e8b345c..d194195e7455a110d453788f0864ee34b5266d52 100644 (file)
@@ -5,7 +5,6 @@
 #include <sys/types.h>
 #include <sys/uio.h>
 
-#include "alloc-util.h"
 #include "iovec-util-fundamental.h"
 #include "macro.h"
 
@@ -16,12 +15,7 @@ size_t iovec_total_size(const struct iovec *iovec, size_t n) _nonnull_if_nonzero
 
 bool iovec_increment(struct iovec *iovec, size_t n, size_t k) _nonnull_if_nonzero_(1, 2);
 
-static inline struct iovec* iovec_make_string(struct iovec *iovec, const char *s) {
-        assert(iovec);
-        /* We don't use strlen_ptr() here, because we don't want to include string-util.h for now */
-        *iovec = IOVEC_MAKE(s, s ? strlen(s) : 0);
-        return iovec;
-}
+struct iovec* iovec_make_string(struct iovec *iovec, const char *s);
 
 #define IOVEC_MAKE_STRING(s) \
         *iovec_make_string(&(struct iovec) {}, s)
@@ -32,43 +26,15 @@ static inline struct iovec* iovec_make_string(struct iovec *iovec, const char *s
                 .iov_len = STRLEN(s),           \
         }
 
-static inline void iovec_done_erase(struct iovec *iovec) {
-        assert(iovec);
-
-        iovec->iov_base = erase_and_free(iovec->iov_base);
-        iovec->iov_len = 0;
-}
+void iovec_done_erase(struct iovec *iovec);
 
 char* set_iovec_string_field(struct iovec *iovec, size_t *n_iovec, const char *field, const char *value);
 char* set_iovec_string_field_free(struct iovec *iovec, size_t *n_iovec, const char *field, char *value);
 
 void iovec_array_free(struct iovec *iovec, size_t n_iovec) _nonnull_if_nonzero_(1, 2);
 
-static inline int iovec_memcmp(const struct iovec *a, const struct iovec *b) {
-
-        if (a == b)
-                return 0;
-
-        return memcmp_nn(a ? a->iov_base : NULL,
-                         a ? a->iov_len : 0,
-                         b ? b->iov_base : NULL,
-                         b ? b->iov_len : 0);
-}
-
-static inline struct iovec* iovec_memdup(const struct iovec *source, struct iovec *ret) {
-        assert(ret);
-
-        if (!iovec_is_set(source))
-                *ret = (struct iovec) {};
-        else {
-                void *p = memdup(source->iov_base, source->iov_len);
-                if (!p)
-                        return NULL;
-
-                *ret = IOVEC_MAKE(p, source->iov_len);
-        }
+int iovec_memcmp(const struct iovec *a, const struct iovec *b) _pure_;
 
-        return ret;
-}
+struct iovec* iovec_memdup(const struct iovec *source, struct iovec *ret);
 
 struct iovec* iovec_append(struct iovec *iovec, const struct iovec *append);
index 8ab468ed9d86d68bae22e97c5aae4c3d01654205..fd40c055a4c14983ac317662968af8723d33c55b 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <threads.h>
 
+#include "alloc-util.h"
 #include "env-util.h"
 #include "iovec-util.h"
 #include "log.h"
index 20c3336009f2d5022fe24da0d67bf338db6b6272..8927464c4652a9ece1da2a4db29f6c5e5411d900 100644 (file)
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include "alloc-util.h"
 #include "bootctl.h"
 #include "bootctl-install.h"
 #include "bootctl-random-seed.h"
index 75cae290977ced35d2a2b8e14357f88e72c7d776..d53458c49108413b56c8bb9331d4f1d254934cb2 100644 (file)
@@ -3,6 +3,7 @@
 #include <uchar.h>
 #include <unistd.h>
 
+#include "alloc-util.h"
 #include "bootctl.h"
 #include "bootctl-set-efivar.h"
 #include "efi-loader.h"
index 6021c1a5aede9b9634ba3ca574786d98f74c054c..38fe5273bec3a595340b2de41aaa09d92ca470e1 100644 (file)
@@ -4,6 +4,7 @@
 #include <sys/mman.h>
 #include <unistd.h>
 
+#include "alloc-util.h"
 #include "bootctl.h"
 #include "bootctl-status.h"
 #include "bootctl-util.h"
index bc0b0d7c9c99b2434c64cde242155e430dc4cdb9..41eadbdf1b55b5dcbeae8d9491eb6f9ddcd75738 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <sys/mman.h>
 
+#include "alloc-util.h"
 #include "bootctl.h"
 #include "bootctl-util.h"
 #include "errno-util.h"
index d513f5d0a9851f86bafedc7090ac550134f48963..fb80cecd3467c9c556359fdfeca24f223c322b0c 100644 (file)
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include "alloc-util.h"
 #include "cryptsetup-keyfile.h"
 #include "fileio.h"
 #include "log.h"
index 9e94c974c9b52d2bf1fd9951f051d80c19ae0d7d..787d35b216227ce3ec5e31e3942082a83ad5424e 100644 (file)
@@ -4,6 +4,7 @@
 #include <libcryptsetup.h>
 #include <string.h>
 
+#include "alloc-util.h"
 #include "cryptsetup-token.h"
 #include "cryptsetup-token-util.h"
 #include "hexdecoct.h"
index e067950da7070986e0bdd2815955ce89afe84ab2..967b26df4d7c496f43205eebb7978c17a74079aa 100644 (file)
@@ -3,6 +3,7 @@
 #include <errno.h>
 #include <libcryptsetup.h>
 
+#include "alloc-util.h"
 #include "cryptsetup-token.h"
 #include "cryptsetup-token-util.h"
 #include "hexdecoct.h"
index 67714af690d1224e5ed3682a44dcf71876955f8c..18b0e4f37f93fea9fc959845a96710cd60b281b0 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <libcryptsetup.h>
 
+#include "alloc-util.h"
 #include "cryptsetup-token-util.h"
 #include "hexdecoct.h"
 #include "json-util.h"
index 772edcf95b037648f14c845e946250636898c95e..1b89e5889062ac71899883ef41d60904216f7583 100644 (file)
@@ -4,6 +4,7 @@
 #include <fido.h>
 #endif
 
+#include "alloc-util.h"
 #include "ask-password-api.h"
 #include "errno-util.h"
 #include "fido2-util.h"
index 2cdd20efe57a8cc05034de320ee0e5d3d31183e9..1f0bc88e4171059e8ec9591977ddefbc6ae27377 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <openssl/pem.h>
 
+#include "alloc-util.h"
 #include "fd-util.h"
 #include "fileio.h"
 #include "json-util.h"
index 02865a40c25e929745d72ef42c829b26abd3a81e..fe531ba14aa8cfeb37d57cd0facd93d483ef3ff0 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <netinet/icmp6.h>
 
+#include "alloc-util.h"
 #include "icmp6-packet.h"
 #include "icmp6-util.h"
 #include "in-addr-util.h"
index daa7aba5eabbdf83b1dc61170f3281eaf6d24007..1d4be8e2dd20a75d9c61ad8cb9dd135e0b206da8 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/ipv6.h>
 #include <netinet/icmp6.h>
 
+#include "alloc-util.h"
 #include "dns-domain.h"
 #include "dns-resolver-internal.h"
 #include "ether-addr-util.h"
index 32706bf842b04a1c9f0871328a96d5bfb962b79f..8b4c1012b5c4115948be28aa65283ff506a5927e 100644 (file)
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include "alloc-util.h"
 #include "dhcp-server-lease-internal.h"
 #include "fd-util.h"
 #include "fs-util.h"
index 66049d3106dbb3bb9fcf288413d5d310776170a1..72bcdde1bdd60be0056462daff8d18d5a2333753 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "sd-netlink.h"
 
+#include "alloc-util.h"
 #include "iovec-util.h"
 #include "log.h"
 #include "netlink-internal.h"
index 78c13b81c157aba3cedd92fbe939fd68a0f316e1..8e29bc518a149195f7175150494c09d9f3b80386 100644 (file)
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include "af-list.h"
+#include "alloc-util.h"
 #include "daemon-util.h"
 #include "fd-util.h"
 #include "fileio.h"
index c56f62e1e337f35c0423f250c072839e38e8f680..a03919cfedd0400024be4e9fcec4c11a697a17cd 100644 (file)
@@ -8,6 +8,7 @@
 #include <openssl/err.h>
 #include <openssl/x509v3.h>
 
+#include "alloc-util.h"
 #include "io-util.h"
 #include "openssl-util.h"
 #include "resolved-dns-server.h"
index 15021ae2510e41b1b7cdf5061c7751c029cd851e..e5ca2ccbb3c7fab9a73a943d4d29e3e8f4ae3766 100644 (file)
@@ -3,6 +3,7 @@
 #include <fnmatch.h>
 #include <unistd.h>
 
+#include "alloc-util.h"
 #include "bootspec.h"
 #include "bootspec-fundamental.h"
 #include "chase.h"
index 67707dee1ecfa04b20f6f28213cfdc7327f389e8..6eca4aa88c5b125cf6e441b95608c410b74e54b0 100644 (file)
@@ -10,6 +10,7 @@
 #include "sd-json.h"
 #include "sd-varlink.h"
 
+#include "alloc-util.h"
 #include "blockdev-util.h"
 #include "capability-util.h"
 #include "chattr-util.h"
index 8c893d6b23c38b0928218d9d3d99a945fdcb4a33..b0ec7ec41007e4112d48f1cb8652b812f07f414d 100644 (file)
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include "alloc-util.h"
 #include "fido2-util.h"
 #include "fileio.h"
 #include "libfido2-util.h"
index 090281de5e1c1e858140c501463b577ed4ed4026..3e31ec92ef2e39e7b1a62c0aae105264d7097f49 100644 (file)
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include "alloc-util.h"
 #include "env-file.h"
 #include "fd-util.h"
 #include "fileio.h"
index 240d6f26e6370d2fff9e38e569b96a3a3b94070d..a32e19d37d7a3f8bfd31103c95e4be90ca418b5b 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "ask-password-api.h"
 #include "iovec-util.h"
-#include "macro.h"
+#include "memory-util.h"
 #include "sha256.h"
 
 typedef enum CertificateSourceType {
index 04c6d691c66c3159d9f5d8c4c0db04a5c0c4a90c..1104e1e33a2695c16af6365eb531046a5dbb3af4 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <fcntl.h>
 
+#include "alloc-util.h"
 #include "ask-password-api.h"
 #include "dlfcn-util.h"
 #include "env-util.h"